diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index 735bf90b9ba9d..fe94434490c71 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -16,10 +16,10 @@ Please fill in the *entire* template below. --> -**TypeScript Version:** 3.0.0-dev.201xxxxx +**TypeScript Version:** 3.1.0-dev.201xxxxx -**Search Terms:** +**Search Terms:** **Code** @@ -32,6 +32,6 @@ Please fill in the *entire* template below. **Actual behavior:** -**Playground Link:** +**Playground Link:** **Related Issues:** diff --git a/.mailmap b/.mailmap index 774aa4174c374..79e90f32785b0 100644 --- a/.mailmap +++ b/.mailmap @@ -163,7 +163,7 @@ Rostislav Galimsky Richard Knoll Richard Knoll Richard Karmazín Rowan Wyborn -Ryan Cavanaugh Ryan Cavanaugh Ryan Cavanaugh +Ryan Cavanaugh Ryan Cavanaugh Ryan Cavanaugh Ryan Cavanaugh Ryohei Ikegami Sarangan Rajamanickam Sébastien Arod @@ -340,4 +340,21 @@ EcoleKeine # Ecole Keine Khải rhysd # @rhysd Zen <843968788@qq.com> Zzzen <843968788@qq.com> # @Zzzen -bluelovers # @bluelovers \ No newline at end of file +bluelovers # @bluelovers +Dan Freeman +David Sherret +David Staheli +Elizabeth Dinella +John Doe +Kevin Gibbons +Markus Johnsson +Martin Probst +Mateusz Burzyński +Steven # @styfle +Pi Lanningham +Sam Bostock +Vimal Raghubir +Vyacheslav Pukhanov +dangoo # Daniel Gooss +krk # Kerem Kat +micnic # Nicu Micleușanu diff --git a/.npmignore b/.npmignore index 78c9417e52b3e..6054bfbdb3705 100644 --- a/.npmignore +++ b/.npmignore @@ -19,8 +19,10 @@ Jakefile.js .circleci .vscode/ .parallelperf.json +.mailmap test.config package-lock.json yarn.lock .github/ CONTRIBUTING.md +TEST-results.xml diff --git a/.travis.yml b/.travis.yml index d7610ed7603cf..9479fffe76331 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ branches: - release-2.7 - release-2.8 - release-2.9 + - release-3.0 install: - npm uninstall typescript --no-save diff --git a/AUTHORS.md b/AUTHORS.md index 0c31c45e2ede2..2ee14e49b41d4 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -74,7 +74,9 @@ TypeScript is authored by: * Dafrok Zhang * Dahan Gong * Dan Corder +* Dan Freeman * Dan Quirk +* Daniel Gooss * Daniel Hollocher * Daniel Król * Daniel Lehenbauer @@ -82,7 +84,9 @@ TypeScript is authored by: * David Kmenta * David Li * David Sheldrick +* David Sherret * David Souther +* David Staheli * Denis Nedelyaev * Derek P Sifford * Dhruv Rajvanshi @@ -96,6 +100,7 @@ TypeScript is authored by: * @e-cloud * Ecole Keine * Elisée Maurer +* Elizabeth Dinella * Emilio García-Pumarino * Eric Grube * Eric Tsang @@ -161,6 +166,7 @@ TypeScript is authored by: * Joel Day * Joey Wilson * Johannes Rieken +* John Doe * John Vilk * Jonathan Bond-Caron * Jonathan Park @@ -184,7 +190,9 @@ TypeScript is authored by: * Keith Mashinter * Ken Howard * Kenji Imamula +* Kerem Kat * Kevin Donnelly +* Kevin Gibbons * Kevin Lang * Khải * Kitson Kelly @@ -201,10 +209,13 @@ TypeScript is authored by: * Manish Giri * Marin Marinov * Marius Schulz +* Markus Johnsson * Martin Hiller +* Martin Probst * Martin Vseticka * Martyn Janes * Masahiro Wakame +* Mateusz Burzyński * Matt Bierner * Matt McCutchen * Matt Mitchell @@ -223,10 +234,10 @@ TypeScript is authored by: * Mohamed Hegazy * Mohsen Azimi * Myles Megyesi -* Natalie Coley * Nathan Shively-Sanders * Nathan Yee * Nicolas Henry +* Nicu Micleușanu * @nieltg * Nima Zahedi * Noah Chen @@ -248,6 +259,7 @@ TypeScript is authored by: * Peter Burns * Philip Bulley * Philippe Voinov +* Pi Lanningham * Piero Cangianiello * @piloopin * Prayag Verma @@ -270,6 +282,7 @@ TypeScript is authored by: * Rowan Wyborn * Ryan Cavanaugh * Ryohei Ikegami +* Sam Bostock * Sam El-Husseini * Sarangan Rajamanickam * Sean Barag @@ -290,6 +303,7 @@ TypeScript is authored by: * Stas Vilchik * Stephan Ginthör * Steve Lucco +* @styfle * Sudheesh Singanamalla * Sébastien Arod * @T18970237136 @@ -316,8 +330,10 @@ TypeScript is authored by: * Vidar Tonaas Fauske * Viktor Zozulyak * Vilic Vane +* Vimal Raghubir * Vladimir Kurchatkin * Vladimir Matveev +* Vyacheslav Pukhanov * Wenlu Wang * Wesley Wigham * William Orr diff --git a/Gulpfile.js b/Gulpfile.js index e202b2d983c2b..b31462755adb1 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -24,6 +24,10 @@ const baselineAccept = require("./scripts/build/baselineAccept"); const cmdLineOptions = require("./scripts/build/options"); const exec = require("./scripts/build/exec"); const browserify = require("./scripts/build/browserify"); +const debounce = require("./scripts/build/debounce"); +const prepend = require("./scripts/build/prepend"); +const { removeSourceMaps } = require("./scripts/build/sourcemaps"); +const { CancelSource, CancelError } = require("./scripts/build/cancellation"); const { libraryTargets, generateLibs } = require("./scripts/build/lib"); const { runConsoleTests, cleanTestDirs, writeTestConfigFile, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests"); @@ -44,17 +48,9 @@ const generateLocalizedDiagnosticMessagesJs = "scripts/generateLocalizedDiagnost const buildProtocolJs = "scripts/buildProtocol.js"; const produceLKGJs = "scripts/produceLKG.js"; const word2mdJs = "scripts/word2md.js"; -gulp.task("scripts", /*help*/ false, () => project.compile(scriptsProject), { - aliases: [ - configurePrereleaseJs, - processDiagnosticMessagesJs, - generateLocalizedDiagnosticMessagesJs, - produceLKGJs, - buildProtocolJs, - word2mdJs - ] -}); -gulp.task("clean-scripts", /*help*/ false, () => project.clean(scriptsProject)); +const scriptsTaskAliases = [configurePrereleaseJs, processDiagnosticMessagesJs, generateLocalizedDiagnosticMessagesJs, produceLKGJs, buildProtocolJs, word2mdJs]; +gulp.task("scripts", /*help*/ false, () => project.compile(scriptsProject), { aliases: scriptsTaskAliases }); +gulp.task("clean:scripts", /*help*/ false, () => project.clean(scriptsProject), { aliases: scriptsTaskAliases.map(alias => `clean:${alias}`)}); // Nightly management tasks gulp.task( @@ -73,7 +69,7 @@ gulp.task( const importDefinitelyTypedTestsProject = "scripts/importDefinitelyTypedTests/tsconfig.json"; const importDefinitelyTypedTestsJs = "scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js"; gulp.task(importDefinitelyTypedTestsJs, /*help*/ false, () => project.compile(importDefinitelyTypedTestsProject)); -gulp.task("clean:" + importDefinitelyTypedTestsJs, /*help*/ false, () => project.clean(importDefinitelyTypedTestsProject)); +gulp.task(`clean:${importDefinitelyTypedTestsJs}`, /*help*/ false, () => project.clean(importDefinitelyTypedTestsProject)); gulp.task( "importDefinitelyTypedTests", @@ -95,7 +91,7 @@ gulp.task(diagnosticInformationMapTs, /*help*/ false, [processDiagnosticMessages return exec(host, [processDiagnosticMessagesJs, diagnosticMessagesJson]); } }); -gulp.task("clean:" + diagnosticInformationMapTs, /*help*/ false, () => del([diagnosticInformationMapTs, diagnosticMessagesGeneratedJson])); +gulp.task(`clean:${diagnosticInformationMapTs}`, /*help*/ false, () => del([diagnosticInformationMapTs, diagnosticMessagesGeneratedJson])); const builtGeneratedDiagnosticMessagesJson = "built/local/diagnosticMessages.generated.json"; gulp.task(builtGeneratedDiagnosticMessagesJson, /*help*/ false, [diagnosticInformationMapTs], () => @@ -140,9 +136,10 @@ gulp.task(typescriptServicesProject, /*help*/ false, () => { // NOTE: flatten services so that we can properly strip @internal project.flatten(servicesProject, typescriptServicesProject, { compilerOptions: { - "removeComments": true, + "removeComments": false, "stripInternal": true, - "outFile": "typescriptServices.js" + "declarationMap": false, + "outFile": "typescriptServices.out.js" // must align with same task in jakefile. We fix this name below. } }); }); @@ -150,7 +147,16 @@ gulp.task(typescriptServicesProject, /*help*/ false, () => { const typescriptServicesJs = "built/local/typescriptServices.js"; const typescriptServicesDts = "built/local/typescriptServices.d.ts"; gulp.task(typescriptServicesJs, /*help*/ false, ["lib", "generate-diagnostics", typescriptServicesProject], () => - project.compile(typescriptServicesProject, { dts: files => files.pipe(convertConstEnums()) }), + project.compile(typescriptServicesProject, { + js: files => files + .pipe(prepend.file(copyright)) + .pipe(rename("typescriptServices.js")), + dts: files => files + .pipe(removeSourceMaps()) + .pipe(prepend.file(copyright)) + .pipe(convertConstEnums()) + .pipe(rename("typescriptServices.d.ts")) + }), { aliases: [typescriptServicesDts] }); const typescriptJs = "built/local/typescript.js"; @@ -179,29 +185,39 @@ gulp.task(typescriptStandaloneDts, /*help*/ false, [typescriptServicesDts], () = // build all 'typescriptServices'-related outputs gulp.task("services", /*help*/ false, [typescriptServicesJs, typescriptServicesDts, typescriptJs, typescriptDts, typescriptStandaloneDts]); +const useCompiler = cmdLineOptions.lkg ? "lkg" : "built"; +const useCompilerDeps = cmdLineOptions.lkg ? ["lib", "generate-diagnostics"] : [typescriptServicesJs]; + const tscProject = "src/tsc/tsconfig.json"; const tscJs = "built/local/tsc.js"; -gulp.task(tscJs, /*help*/ false, [typescriptServicesJs], () => project.compile(tscProject, { typescript: "built" })); +gulp.task(tscJs, /*help*/ false, useCompilerDeps, () => + project.compile(tscProject, { + typescript: useCompiler, + js: files => files.pipe(prepend.file(copyright)) + })); const tscReleaseProject = "src/tsc/tsconfig.release.json"; const tscReleaseJs = "built/local/tsc.release.js"; -gulp.task(tscReleaseJs, /*help*/ false, () => project.compile(tscReleaseProject)); +gulp.task(tscReleaseJs, /*help*/ false, () => + project.compile(tscReleaseProject, { + js: files => files.pipe(prepend.file(copyright)) + })); const cancellationTokenProject = "src/cancellationToken/tsconfig.json"; const cancellationTokenJs = "built/local/cancellationToken.js"; -gulp.task(cancellationTokenJs, /*help*/ false, [typescriptServicesJs], () => project.compile(cancellationTokenProject, { typescript: "built" })); +gulp.task(cancellationTokenJs, /*help*/ false, useCompilerDeps, () => project.compile(cancellationTokenProject, { typescript: useCompiler })); const typingsInstallerProject = "src/typingsInstaller/tsconfig.json"; const typingsInstallerJs = "built/local/typingsInstaller.js"; -gulp.task(typingsInstallerJs, /*help*/ false, [typescriptServicesJs], () => project.compile(typingsInstallerProject, { typescript: "built" })); +gulp.task(typingsInstallerJs, /*help*/ false, useCompilerDeps, () => project.compile(typingsInstallerProject, { typescript: useCompiler })); const tsserverProject = "src/tsserver/tsconfig.json"; const tsserverJs = "built/local/tsserver.js"; -gulp.task(tsserverJs, /*help*/ false, [typescriptServicesJs], () => project.compile(tsserverProject, { typescript: "built" })); +gulp.task(tsserverJs, /*help*/ false, useCompilerDeps, () => project.compile(tsserverProject, { typescript: useCompiler })); const watchGuardProject = "src/watchGuard/tsconfig.json"; const watchGuardJs = "built/local/watchGuard.js"; -gulp.task(watchGuardJs, /*help*/ false, [typescriptServicesJs], () => project.compile(watchGuardProject, { typescript: "built" })); +gulp.task(watchGuardJs, /*help*/ false, useCompilerDeps, () => project.compile(watchGuardProject, { typescript: useCompiler })); const typesMapJson = "built/local/typesMap.json"; gulp.task(typesMapJson, /*help*/ false, [], () => @@ -216,21 +232,28 @@ gulp.task(tsserverlibraryProject, /*help*/ false, () => { project.flatten("src/tsserver/tsconfig.json", tsserverlibraryProject, { exclude: ["src/tsserver/server.ts"], compilerOptions: { - "removeComments": true, + "removeComments": false, "stripInternal": true, - "outFile": "tsserverlibrary.js" + "declarationMap": false, + "outFile": "tsserverlibrary.out.js" // must align with same task in jakefile. We fix this name below. } }); }); const tsserverlibraryJs = "built/local/tsserverlibrary.js"; const tsserverlibraryDts = "built/local/tsserverlibrary.d.ts"; -gulp.task(tsserverlibraryJs, /*help*/ false, [typescriptServicesJs, tsserverlibraryProject], () => +gulp.task(tsserverlibraryJs, /*help*/ false, useCompilerDeps.concat([tsserverlibraryProject]), () => project.compile(tsserverlibraryProject, { + js: files => files + .pipe(prepend.file(copyright)) + .pipe(rename("tsserverlibrary.js")), dts: files => files + .pipe(removeSourceMaps()) + .pipe(prepend.file(copyright)) .pipe(convertConstEnums()) - .pipe(append("\nexport = ts;\nexport as namespace ts;")), - typescript: "built" + .pipe(append("\nexport = ts;\nexport as namespace ts;")) + .pipe(rename("tsserverlibrary.d.ts")), + typescript: useCompiler }), { aliases: [tsserverlibraryDts] }); gulp.task( @@ -294,29 +317,29 @@ gulp.task( // Task to build the tests infrastructure using the built compiler const testRunnerProject = "src/testRunner/tsconfig.json"; const runJs = "built/local/run.js"; -gulp.task(runJs, /*help*/ false, [typescriptServicesJs, tsserverlibraryDts], () => project.compile(testRunnerProject, { typescript: "built" })); +gulp.task(runJs, /*help*/ false, useCompilerDeps, () => project.compile(testRunnerProject, { typescript: useCompiler })); gulp.task( "tests", "Builds the test infrastructure using the built compiler", - [runJs]); + [runJs, tsserverlibraryDts]); gulp.task( "runtests-parallel", "Runs all the tests in parallel using the built run.js file. Optional arguments are: --t[ests]=category1|category2|... --d[ebug]=true.", - ["build-rules", "tests"], - () => runConsoleTests(runJs, "min", /*runInParallel*/ true)); + ["build-rules", "tests", "services", tsserverlibraryDts], + () => runConsoleTests(runJs, "min", /*runInParallel*/ true, /*watchMode*/ false)); gulp.task( "runtests", "Runs the tests using the built run.js file. Optional arguments are: --t[ests]=regex --r[eporter]=[list|spec|json|] --d[ebug]=true --color[s]=false --lint=true.", - ["build-rules", "tests"], - () => runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false)); + ["build-rules", "tests", "services", tsserverlibraryDts], + () => runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false)); const webTestServerProject = "tests/webTestServer.tsconfig.json"; const webTestServerJs = "tests/webTestServer.js"; -gulp.task(webTestServerJs, /*help*/ false, [typescriptServicesJs], () => project.compile(webTestServerProject, { typescript: "built" })); -gulp.task("clean:" + webTestServerJs, /*help*/ false, () => project.clean(webTestServerProject)); +gulp.task(webTestServerJs, /*help*/ false, useCompilerDeps, () => project.compile(webTestServerProject, { typescript: useCompiler })); +gulp.task(`clean:${webTestServerJs}`, /*help*/ false, () => project.clean(webTestServerProject)); const bundlePath = path.resolve("built/local/bundle.js"); @@ -392,8 +415,8 @@ gulp.task( // Webhost const webtscProject = "tests/webhost/webtsc.tsconfig.json"; const webtscJs = "tests/webhost/webtsc.js"; -gulp.task(webtscJs, /*help*/ false, [typescriptServicesJs], () => project.compile(webtscProject, { typescript: "built" })); -gulp.task("clean:" + webtscJs, /*help*/ false, () => project.clean(webtscProject)); +gulp.task(webtscJs, /*help*/ false, useCompilerDeps, () => project.compile(webtscProject, { typescript: useCompiler })); +gulp.task(`clean:${webtscJs}`, /*help*/ false, () => project.clean(webtscProject)); gulp.task("webhost", "Builds the tsc web host", [webtscJs], () => gulp.src("built/local/lib.d.ts") @@ -402,8 +425,8 @@ gulp.task("webhost", "Builds the tsc web host", [webtscJs], () => // Perf compiler const perftscProject = "tests/perftsc.tsconfig.json"; const perftscJs = "built/local/perftsc.js"; -gulp.task(perftscJs, /*help*/ false, [typescriptServicesJs], () => project.compile(perftscProject, { typescript: "built" })); -gulp.task("clean:" + perftscJs, /*help*/ false, () => project.clean(perftscProject)); +gulp.task(perftscJs, /*help*/ false, useCompilerDeps, () => project.compile(perftscProject, { typescript: useCompiler })); +gulp.task(`clean:${perftscJs}`, /*help*/ false, () => project.clean(perftscProject)); gulp.task( "perftsc", @@ -423,7 +446,7 @@ gulp.task(loggedIOJs, /*help*/ false, [], (done) => { const instrumenterProject = "src/instrumenter/tsconfig.json"; const instrumenterJs = "built/local/instrumenter.js"; gulp.task(instrumenterJs, /*help*/ false, () => project.compile(instrumenterProject)); -gulp.task("clean:" + instrumenterJs, /*help*/ false, () => project.clean(instrumenterProject)); +gulp.task(`clean:${instrumenterJs}`, /*help*/ false, () => project.clean(instrumenterProject)); gulp.task( "tsc-instrumented", @@ -479,43 +502,102 @@ gulp.task( gulp.task( "watch-tsc", /*help*/ false, - ["watch-diagnostics", "watch-lib", typescriptServicesJs], - () => project.watch(tscProject, { typescript: "built" })); + ["watch-diagnostics", "watch-lib"].concat(useCompilerDeps), + () => project.watch(tscProject, { typescript: useCompiler })); + +const watchServicesPatterns = [ + "src/compiler/**/*", + "src/jsTypings/**/*", + "src/services/**/*" +]; gulp.task( "watch-services", /*help*/ false, - ["watch-diagnostics", "watch-lib", typescriptServicesJs], - () => project.watch(servicesProject, { typescript: "built" })); + ["watch-diagnostics", "watch-lib"], + () => gulp.watch(watchServicesPatterns, ["services"])); + +const watchLsslPatterns = [ + ...watchServicesPatterns, + "src/server/**/*", + "src/tsserver/tsconfig.json" +]; + +gulp.task( + "watch-lssl", + /*help*/ false, + () => gulp.watch(watchLsslPatterns, ["lssl"])); gulp.task( "watch-server", /*help*/ false, - ["watch-diagnostics", "watch-lib", typescriptServicesJs], - () => project.watch(tsserverProject, { typescript: "built" })); + ["watch-diagnostics", "watch-lib"].concat(useCompilerDeps), + () => project.watch(tsserverProject, { typescript: useCompiler })); gulp.task( "watch-local", /*help*/ false, ["watch-lib", "watch-tsc", "watch-services", "watch-server"]); +gulp.task( + "watch-runner", + /*help*/ false, + useCompilerDeps, + () => project.watch(testRunnerProject, { typescript: useCompiler })); + +const watchPatterns = [ + runJs, + typescriptDts, + tsserverlibraryDts +]; + gulp.task( "watch", - "Watches for changes to the build inputs for built/local/run.js executes runtests-parallel.", - [typescriptServicesJs], - () => project.watch(testRunnerProject, { typescript: "built" }, ["runtests-parallel"])); + "Watches for changes to the build inputs for built/local/run.js, then executes runtests-parallel.", + ["build-rules", "watch-runner", "watch-services", "watch-lssl"], + () => { + /** @type {CancelSource | undefined} */ + let runTestsSource; + + const fn = debounce(() => { + runTests().catch(error => { + if (error instanceof CancelError) { + log.warn("Operation was canceled"); + } + else { + log.error(error); + } + }); + }, /*timeout*/ 100, { max: 500 }); + + gulp.watch(watchPatterns, () => project.wait().then(fn)); + + // NOTE: gulp.watch is far too slow when watching tests/cases/**/* as it first enumerates *every* file + const testFilePattern = /(\.ts|[\\/]tsconfig\.json)$/; + fs.watch("tests/cases", { recursive: true }, (_, file) => { + if (testFilePattern.test(file)) project.wait().then(fn); + }); + + function runTests() { + if (runTestsSource) runTestsSource.cancel(); + runTestsSource = new CancelSource(); + return cmdLineOptions.tests || cmdLineOptions.failed + ? runConsoleTests(runJs, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ true, runTestsSource.token) + : runConsoleTests(runJs, "min", /*runInParallel*/ true, /*watchMode*/ true, runTestsSource.token); + } + }); -gulp.task("clean-built", /*help*/ false, ["clean:" + diagnosticInformationMapTs], () => del(["built"])); +gulp.task("clean-built", /*help*/ false, [`clean:${diagnosticInformationMapTs}`], () => del(["built"])); gulp.task( "clean", "Cleans the compiler output, declare files, and tests", [ - "clean:" + importDefinitelyTypedTestsJs, - "clean:" + webtscJs, - "clean:" + perftscJs, - "clean:" + instrumenterJs, - "clean:" + webTestServerJs, - "clean-scripts", + `clean:${importDefinitelyTypedTestsJs}`, + `clean:${webtscJs}`, + `clean:${perftscJs}`, + `clean:${instrumenterJs}`, + `clean:${webTestServerJs}`, + "clean:scripts", "clean-rules", "clean-built" ]); \ No newline at end of file diff --git a/Jakefile.js b/Jakefile.js index 2019df45dc1db..4a650b612fe36 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -9,6 +9,9 @@ const fold = require("travis-fold"); const ts = require("./lib/typescript"); const del = require("del"); const getDirSize = require("./scripts/build/getDirSize"); +const { base64VLQFormatEncode } = require("./scripts/build/sourcemaps"); +const needsUpdate = require("./scripts/build/needsUpdate"); +const { flatten } = require("./scripts/build/project"); // add node_modules to path so we don't need global modules, prefer the modules by adding them first var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter; @@ -64,9 +67,14 @@ Paths.typesMapOutput = "built/local/typesMap.json"; Paths.typescriptFile = "built/local/typescript.js"; Paths.servicesFile = "built/local/typescriptServices.js"; Paths.servicesDefinitionFile = "built/local/typescriptServices.d.ts"; +Paths.servicesOutFile = "built/local/typescriptServices.out.js"; +Paths.servicesDefinitionOutFile = "built/local/typescriptServices.out.d.ts"; Paths.typescriptDefinitionFile = "built/local/typescript.d.ts"; Paths.typescriptStandaloneDefinitionFile = "built/local/typescript_standalone.d.ts"; +Paths.tsserverLibraryFile = "built/local/tsserverlibrary.js"; Paths.tsserverLibraryDefinitionFile = "built/local/tsserverlibrary.d.ts"; +Paths.tsserverLibraryOutFile = "built/local/tsserverlibrary.out.js"; +Paths.tsserverLibraryDefinitionOutFile = "built/local/tsserverlibrary.out.d.ts"; Paths.baselines = {}; Paths.baselines.local = "tests/baselines/local"; Paths.baselines.localTest262 = "tests/baselines/test262/local"; @@ -101,7 +109,9 @@ const ConfigFileFor = { runjs: "src/testRunner", lint: "scripts/tslint", scripts: "scripts", - all: "src" + all: "src", + typescriptServices: "built/local/typescriptServices.tsconfig.json", + tsserverLibrary: "built/local/tsserverlibrary.tsconfig.json", }; const ExpectedLKGFiles = [ @@ -124,13 +134,18 @@ desc("Builds the full compiler and services"); task(TaskNames.local, [ TaskNames.buildFoldStart, TaskNames.coreBuild, + Paths.servicesDefinitionFile, + Paths.typescriptFile, + Paths.typescriptDefinitionFile, + Paths.typescriptStandaloneDefinitionFile, + Paths.tsserverLibraryDefinitionFile, TaskNames.localize, TaskNames.buildFoldEnd ]); task("default", [TaskNames.local]); -const RunTestsPrereqs = [TaskNames.lib, Paths.servicesDefinitionFile, Paths.tsserverLibraryDefinitionFile]; +const RunTestsPrereqs = [TaskNames.lib, Paths.servicesDefinitionFile, Paths.typescriptDefinitionFile, Paths.tsserverLibraryDefinitionFile]; desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true."); task(TaskNames.runtestsParallel, RunTestsPrereqs, function () { tsbuild([ConfigFileFor.runjs], true, () => { @@ -172,6 +187,9 @@ task(TaskNames.lkg, [ TaskNames.release, TaskNames.local, Paths.servicesDefinitionFile, + Paths.typescriptFile, + Paths.typescriptDefinitionFile, + Paths.typescriptStandaloneDefinitionFile, Paths.tsserverLibraryDefinitionFile, Paths.releaseCompiler, ...libraryTargets @@ -333,64 +351,146 @@ file(Paths.diagnosticInformationMap, [Paths.diagnosticMessagesJson], function () }); }, { async: true }); -// tsserverlibrary.d.ts -file(Paths.tsserverLibraryDefinitionFile, [TaskNames.coreBuild], function() { - const sources = ["compiler.d.ts", "jsTyping.d.ts", "services.d.ts", "server.d.ts"].map(f => path.join(Paths.builtLocal, f)); - let output = ""; - for (const f of sources) { - output = output + "\n" + removeConstModifierFromEnumDeclarations(readFileSync(f)); - } - output = output + "\nexport = ts;\nexport as namespace ts;"; - fs.writeFileSync(Paths.tsserverLibraryDefinitionFile, output, { encoding: "utf-8" }); +file(ConfigFileFor.tsserverLibrary, [], function () { + flatten("src/tsserver/tsconfig.json", ConfigFileFor.tsserverLibrary, { + exclude: ["src/tsserver/server.ts"], + compilerOptions: { + "removeComments": false, + "stripInternal": true, + "declarationMap": false, + "outFile": "tsserverlibrary.out.js" + } + }) }); -// typescriptservices.d.ts -file(Paths.servicesDefinitionFile, [TaskNames.coreBuild], function() { - // Generate a config file - const files = []; - recur(`src/services/tsconfig.json`); +// tsserverlibrary.js +// tsserverlibrary.d.ts +file(Paths.tsserverLibraryFile, [TaskNames.coreBuild, ConfigFileFor.tsserverLibrary], function() { + tsbuild(ConfigFileFor.tsserverLibrary, false, () => { + if (needsUpdate([Paths.tsserverLibraryOutFile, Paths.tsserverLibraryDefinitionOutFile], [Paths.tsserverLibraryFile, Paths.tsserverLibraryDefinitionFile])) { + const copyright = readFileSync(Paths.copyright); + + let libraryDefinitionContent = readFileSync(Paths.tsserverLibraryDefinitionOutFile); + libraryDefinitionContent = copyright + removeConstModifierFromEnumDeclarations(libraryDefinitionContent); + libraryDefinitionContent += "\nexport = ts;\nexport as namespace ts;"; + fs.writeFileSync(Paths.tsserverLibraryDefinitionFile, libraryDefinitionContent, "utf8"); + + let libraryContent = readFileSync(Paths.tsserverLibraryOutFile); + libraryContent = copyright + libraryContent; + fs.writeFileSync(Paths.tsserverLibraryFile, libraryContent, "utf8"); + + // adjust source map for tsserverlibrary.js + let libraryMapContent = readFileSync(Paths.tsserverLibraryOutFile + ".map"); + const map = JSON.parse(libraryMapContent); + const lineStarts = /**@type {*}*/(ts).computeLineStarts(copyright); + let prependMappings = ""; + for (let i = 1; i < lineStarts.length; i++) { + prependMappings += ";"; + } + + const offset = copyright.length - lineStarts[lineStarts.length - 1]; + if (offset > 0) { + prependMappings += base64VLQFormatEncode(offset) + ","; + } + + const outputMap = { + version: map.version, + file: map.file, + sources: map.sources, + sourceRoot: map.sourceRoot, + mappings: prependMappings + map.mappings, + names: map.names, + sourcesContent: map.sourcesContent + }; + + libraryMapContent = JSON.stringify(outputMap); + fs.writeFileSync(Paths.tsserverLibraryFile + ".map", libraryMapContent); + } + complete(); + }); +}, { async: true }); +task(Paths.tsserverLibraryDefinitionFile, [Paths.tsserverLibraryFile]); - const config = { - extends: "../../src/tsconfig-base", +file(ConfigFileFor.typescriptServices, [], function () { + flatten("src/services/tsconfig.json", ConfigFileFor.typescriptServices, { compilerOptions: { + "removeComments": false, "stripInternal": true, - "outFile": "typescriptServices.js" - }, - files - }; - - const configFilePath = `built/local/typescriptServices.tsconfig.json`; - fs.writeFileSync(configFilePath, JSON.stringify(config, undefined, 2)); - tsbuild(configFilePath, false, () => { - const servicesContent = readFileSync(Paths.servicesDefinitionFile); - const servicesContentWithoutConstEnums = removeConstModifierFromEnumDeclarations(servicesContent); - fs.writeFileSync(Paths.servicesDefinitionFile, servicesContentWithoutConstEnums); - - // Also build typescript.js, typescript.js.map, and typescript.d.ts - jake.cpR(Paths.servicesFile, Paths.typescriptFile); - if (fs.existsSync(Paths.servicesFile + ".map")) { - jake.cpR(Paths.servicesFile + ".map", Paths.typescriptFile + ".map"); + "declarationMap": false, + "outFile": "typescriptServices.out.js" } + }); +}); + +// typescriptServices.js +// typescriptServices.d.ts +file(Paths.servicesFile, [TaskNames.coreBuild, ConfigFileFor.typescriptServices], function() { + tsbuild(ConfigFileFor.typescriptServices, false, () => { + if (needsUpdate([Paths.servicesOutFile, Paths.servicesDefinitionOutFile], [Paths.servicesFile, Paths.servicesDefinitionFile])) { + const copyright = readFileSync(Paths.copyright); + + let servicesDefinitionContent = readFileSync(Paths.servicesDefinitionOutFile); + servicesDefinitionContent = copyright + removeConstModifierFromEnumDeclarations(servicesDefinitionContent); + fs.writeFileSync(Paths.servicesDefinitionFile, servicesDefinitionContent, "utf8"); + + let servicesContent = readFileSync(Paths.servicesOutFile); + servicesContent = copyright + servicesContent; + fs.writeFileSync(Paths.servicesFile, servicesContent, "utf8"); + + // adjust source map for typescriptServices.js + let servicesMapContent = readFileSync(Paths.servicesOutFile + ".map"); + const map = JSON.parse(servicesMapContent); + const lineStarts = /**@type {*}*/(ts).computeLineStarts(copyright); + let prependMappings = ""; + for (let i = 1; i < lineStarts.length; i++) { + prependMappings += ";"; + } - fs.writeFileSync(Paths.typescriptDefinitionFile, servicesContentWithoutConstEnums + "\r\nexport = ts", { encoding: "utf-8" }); - // And typescript_standalone.d.ts - fs.writeFileSync(Paths.typescriptStandaloneDefinitionFile, servicesContentWithoutConstEnums.replace(/declare (namespace|module) ts(\..+)? \{/g, 'declare module "typescript" {'), { encoding: "utf-8"}); + const offset = copyright.length - lineStarts[lineStarts.length - 1]; + if (offset > 0) { + prependMappings += base64VLQFormatEncode(offset) + ","; + } + + const outputMap = { + version: map.version, + file: map.file, + sources: map.sources, + sourceRoot: map.sourceRoot, + mappings: prependMappings + map.mappings, + names: map.names, + sourcesContent: map.sourcesContent + }; + + servicesMapContent = JSON.stringify(outputMap); + fs.writeFileSync(Paths.servicesFile + ".map", servicesMapContent); + } complete(); }); +}, { async: true }); +task(Paths.servicesDefinitionFile, [Paths.servicesFile]); - function recur(configPath) { - const cfgFile = readJson(configPath); - if (cfgFile.references) { - for (const ref of cfgFile.references) { - recur(path.join(path.dirname(configPath), ref.path, "tsconfig.json")); - } - } - for (const file of cfgFile.files) { - files.push(path.join(`../../`, path.dirname(configPath), file)); +// typescript.js +// typescript.d.ts +file(Paths.typescriptFile, [Paths.servicesFile], function() { + if (needsUpdate([Paths.servicesFile, Paths.servicesDefinitionFile], [Paths.typescriptFile, Paths.typescriptDefinitionFile])) { + jake.cpR(Paths.servicesFile, Paths.typescriptFile); + if (fs.existsSync(Paths.servicesFile + ".map")) { + jake.cpR(Paths.servicesFile + ".map", Paths.typescriptFile + ".map"); } + const content = readFileSync(Paths.servicesDefinitionFile); + fs.writeFileSync(Paths.typescriptDefinitionFile, content + "\r\nexport = ts;", { encoding: "utf-8" }); } -}, { async: true }); +}); +task(Paths.typescriptDefinitionFile, [Paths.typescriptFile]); + +// typescript_standalone.d.ts +file(Paths.typescriptStandaloneDefinitionFile, [Paths.servicesDefinitionFile], function() { + if (needsUpdate(Paths.servicesDefinitionFile, Paths.typescriptStandaloneDefinitionFile)) { + const content = readFileSync(Paths.servicesDefinitionFile); + fs.writeFileSync(Paths.typescriptStandaloneDefinitionFile, content.replace(/declare (namespace|module) ts(\..+)? \{/g, 'declare module "typescript" {'), { encoding: "utf-8"}); + } +}); function getLibraryTargets() { /** @type {{ libs: string[], paths?: Record, sources?: Record }} */ @@ -717,7 +817,7 @@ function diagnosticsToString(diagnostics, pretty) { * Concatenate a list of sourceFiles to a destinationFile * @param {string} destinationFile * @param {string[]} sourceFiles - * @param {string} extraContent + * @param {string=} extraContent */ function concatenateFiles(destinationFile, sourceFiles, extraContent) { var temp = "temptemp"; @@ -765,4 +865,4 @@ function getDiffTool() { */ function removeConstModifierFromEnumDeclarations(text) { return text.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4'); -} +} \ No newline at end of file diff --git a/lib/cs/diagnosticMessages.generated.json b/lib/cs/diagnosticMessages.generated.json index e5e989e667992..32a067f4fe864 100644 --- a/lib/cs/diagnosticMessages.generated.json +++ b/lib/cs/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Deklarace oboru názvů nemůže být umístěná před třídou nebo funkcí, se kterou se slučuje.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Deklarace oboru názvů je povolená jenom v oboru názvů nebo v modulu.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Import stylu oboru názvů není možné vyvolat nebo konstruovat a způsobí selhání za běhu.", - "A_non_dry_build_would_build_project_0_6357": "Build nedodržující princip DRY by vytvořil projekt {0}.", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Build nedodržující princip DRY by odstranil následující soubory: {0}", + "A_non_dry_build_would_build_project_0_6357": "Build bez příznaku -dry by vytvořil projekt {0}.", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Build bez příznaku -dry by odstranil následující soubory: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Inicializátor parametru je povolený jenom v implementaci funkce nebo konstruktoru.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Vlastnost parametru se nedá deklarovat pomocí parametru rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Vlastnost parametru je povolená jenom v implementaci konstruktoru.", diff --git a/lib/de/diagnosticMessages.generated.json b/lib/de/diagnosticMessages.generated.json index 99b3594c8f76a..afb8baa15b678 100644 --- a/lib/de/diagnosticMessages.generated.json +++ b/lib/de/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Eine Namespacedeklaration darf nicht vor der Klasse oder Funktion positioniert werden, mit der sie zusammengeführt wird.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Eine Namespacedeklaration ist nur in einem Namespace oder Modul zulässig.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Ein Import im Namespacestil kann nicht aufgerufen oder erstellt werden und verursacht zur Laufzeit einen Fehler.", - "A_non_dry_build_would_build_project_0_6357": "Bei einem echten Build würde das Projekt \"{0}\" erstellt.", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Bei einem echten Build würden die folgenden Dateien gelöscht: {0}", + "A_non_dry_build_would_build_project_0_6357": "Bei einem Build mit dem Flag \"-dry\" würde das Projekt \"{0}\" erstellt.", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Bei einem Build mit dem Flag \"-dry\" würden die folgenden Dateien gelöscht: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Ein Parameterinitialisierer ist nur in einer Funktions- oder Konstruktorimplementierung zulässig.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Eine Parametereigenschaft darf nicht mithilfe eines rest-Parameters deklariert werden.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Eine Parametereigenschaft ist nur in einer Konstruktorimplementierung zulässig.", diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg index 7199fab2a5237..185925b4fae37 100644 --- a/lib/enu/diagnosticMessages.generated.json.lcg +++ b/lib/enu/diagnosticMessages.generated.json.lcg @@ -363,6 +363,12 @@ + + + + + + @@ -393,6 +399,18 @@ + + + + + + + + + + + + @@ -495,12 +513,6 @@ - - - - - - @@ -603,6 +615,12 @@ + + + + + + @@ -657,6 +675,12 @@ + + + + + + @@ -1683,6 +1707,12 @@ + + + + + + @@ -1743,6 +1773,12 @@ + + + + + + @@ -1755,6 +1791,12 @@ + + + + + + @@ -1869,6 +1911,12 @@ + + + + + + @@ -2805,6 +2853,12 @@ + + + + + + @@ -3405,9 +3459,9 @@ - + - + @@ -4203,6 +4257,12 @@ + + + + + + @@ -4257,6 +4317,12 @@ + + + + + + @@ -4593,6 +4659,12 @@ + + + + + + @@ -5109,6 +5181,18 @@ + + + + + + + + + + + + @@ -5355,6 +5439,12 @@ + + + + + + @@ -5619,6 +5709,12 @@ + + + + + + @@ -6177,6 +6273,18 @@ + + + + + + + + + + + + @@ -6189,6 +6297,12 @@ + + + + + + diff --git a/lib/es/diagnosticMessages.generated.json b/lib/es/diagnosticMessages.generated.json index 7ff3b1ecfc246..0e0e31a2b1131 100644 --- a/lib/es/diagnosticMessages.generated.json +++ b/lib/es/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Una declaración de espacio de nombres no se puede situar antes que una clase o función con la que se combina.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Una declaración de espacio de nombres solo se permite en un espacio de nombres o en un módulo.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "No se puede llamar o construir una importación de estilo de espacio de nombres, y provocará un error en tiempo de ejecución.", - "A_non_dry_build_would_build_project_0_6357": "Una compilación no DRY compilaría el proyecto \"{0}\"", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Una compilación no DRY eliminaría los siguientes archivos: {0}", + "A_non_dry_build_would_build_project_0_6357": "Una compilación no -dry compilaría el proyecto \"{0}\"", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Una compilación no -dry eliminaría los archivos siguientes: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Un inicializador de parámetros solo se permite en una implementación de función o de constructor.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Una propiedad de parámetro no se puede declarar mediante un parámetro rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Una propiedad de parámetro solo se permite en una implementación de constructor.", diff --git a/lib/fr/diagnosticMessages.generated.json b/lib/fr/diagnosticMessages.generated.json index f84436339532b..1699b44df8bee 100644 --- a/lib/fr/diagnosticMessages.generated.json +++ b/lib/fr/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Une déclaration d'espace de noms ne peut pas se trouver avant une classe ou une fonction avec laquelle elle est fusionnée.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Une déclaration d'espace de noms est autorisée uniquement dans un espace de noms ou un module.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Impossible d'appeler ou de construire une importation de style d'espace de noms, ce qui va entraîner un échec au moment de l'exécution.", - "A_non_dry_build_would_build_project_0_6357": "Une build non-DRY générerait le projet '{0}'", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Une build non-DRY supprimerait les fichiers suivants : {0}", + "A_non_dry_build_would_build_project_0_6357": "Une build non-dry va générer le projet '{0}'", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Une build non-dry va supprimer les fichiers suivants : {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Un initialiseur de paramètre est uniquement autorisé dans une implémentation de fonction ou de constructeur.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Impossible de déclarer une propriété de paramètre à l'aide d'un paramètre rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Une propriété de paramètre est uniquement autorisée dans une implémentation de constructeur.", diff --git a/lib/it/diagnosticMessages.generated.json b/lib/it/diagnosticMessages.generated.json index ac6e8d9335a6b..9f8ef7d48f462 100644 --- a/lib/it/diagnosticMessages.generated.json +++ b/lib/it/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Una dichiarazione di spazio dei nomi non può essere specificata prima di una classe o funzione con cui è stato eseguito il merge.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Una dichiarazione di spazio dei nomi è consentita solo in uno spazio dei nomi o in un modulo.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Non è possibile chiamare o costruire un'importazione in stile spazio dei nomi. Questo comporterà un errore in fase di runtime.", - "A_non_dry_build_would_build_project_0_6357": "Se si esegue una compilazione non di prova, verrà compilato il progetto '{0}'", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Se si esegue una compilazione non di prova, i file seguenti verranno eliminati: {0}", + "A_non_dry_build_would_build_project_0_6357": "Se si esegue una compilazione senza flag -dry, verrà compilato il progetto '{0}'", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Se si esegue una compilazione senza flag -dry, i file seguenti verranno eliminati: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Un inizializzatore di parametro è consentito solo in un'implementazione di funzione o costruttore.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Non è possibile dichiarare una proprietà di parametro usando un parametro REST.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Una proprietà di parametro è consentita solo in un'implementazione di costruttore.", diff --git a/lib/ja/diagnosticMessages.generated.json b/lib/ja/diagnosticMessages.generated.json index 846237d617d60..6877a89c7539e 100644 --- a/lib/ja/diagnosticMessages.generated.json +++ b/lib/ja/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "名前空間宣言は、それとマージするクラスや関数より前に配置できません。", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "名前空間宣言は、名前空間かモジュールでのみ使用できます。", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "名前空間スタイルのインポートを呼び出したり、構築したりすることはできません。実行時にエラーが発生する原因となります。", - "A_non_dry_build_would_build_project_0_6357": "非ドライ ビルドはプロジェクト '{0}' をビルドします", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非ドライ ビルドは、次のファイルを削除します: {0}", + "A_non_dry_build_would_build_project_0_6357": "非 -dry ビルドを実行した場合、プロジェクト '{0}' がビルドされます", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 -dry ビルドを実行した場合、次のファイルが削除されます: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "パラメーター初期化子は、関数またはコンストラクターの実装でのみ指定できます。", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "パラメーター プロパティは、rest パラメーターを使用して宣言することはできません。", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "パラメーター プロパティは、コンストラクターの実装でのみ指定できます。", diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index e695f8ccb6c2c..c5d6cf984db76 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "네임스페이스 선언은 해당 선언이 병합된 클래스나 함수 앞에 있을 수 없습니다.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "네임스페이스 선언은 네임스페이스 또는 모듈에서만 사용할 수 있습니다.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "네임스페이스 스타일 가져오기를 호출하거나 생성할 수 없으며 런타임 시 오류가 발생합니다.", - "A_non_dry_build_would_build_project_0_6357": "DRY가 아닌 빌드는 프로젝트 '{0}'을(를) 빌드합니다.", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "DRY가 아닌 빌드는 다음 파일을 삭제합니다. {0}", + "A_non_dry_build_would_build_project_0_6357": "-dry가 아닌 빌드는 프로젝트 '{0}'을(를) 빌드합니다.", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "-dry가 아닌 빌드는 다음 파일을 삭제합니다. {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "매개 변수 이니셜라이저는 함수 또는 생성자 구현에서만 허용됩니다.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "rest 매개 변수를 사용하여 매개 변수 속성을 선언할 수 없습니다.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "매개 변수 속성은 생성자 구현에서만 허용됩니다.", diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index a6bb70e10239e..c6a02b32cc232 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -29,8 +29,7 @@ interface Map { } interface MapConstructor { - new (): Map; - new (entries?: ReadonlyArray<[K, V]> | null): Map; + new (entries?: ReadonlyArray<[K, V]> | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; @@ -50,8 +49,7 @@ interface WeakMap { } interface WeakMapConstructor { - new (): WeakMap; - new (entries?: ReadonlyArray<[K, V]> | null): WeakMap; + new (entries?: ReadonlyArray<[K, V]> | null): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -66,8 +64,7 @@ interface Set { } interface SetConstructor { - new (): Set; - new (values?: ReadonlyArray | null): Set; + new (values?: ReadonlyArray | null): Set; readonly prototype: Set; } declare var Set: SetConstructor; @@ -85,8 +82,7 @@ interface WeakSet { } interface WeakSetConstructor { - new (): WeakSet; - new (values?: ReadonlyArray | null): WeakSet; + new (values?: ReadonlyArray | null): WeakSet; readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index a5fb5671d8160..793f587059bbd 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -155,7 +155,7 @@ interface MapConstructor { interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { @@ -203,7 +203,7 @@ interface SetConstructor { interface WeakSet { } interface WeakSetConstructor { - new (iterable: Iterable): WeakSet; + new (iterable: Iterable): WeakSet; } interface Promise { } diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index f06f588f54093..8e8592bd61a12 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -22,3 +22,4 @@ and limitations under the License. /// /// /// +/// diff --git a/lib/lib.esnext.intl.d.ts b/lib/lib.esnext.intl.d.ts new file mode 100644 index 0000000000000..73a45eedf2076 --- /dev/null +++ b/lib/lib.esnext.intl.d.ts @@ -0,0 +1,32 @@ +/*! ***************************************************************************** +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 Intl { + type NumberFormatPartTypes = "currency" | "decimal" | "fraction" | "group" | "infinity" | "integer" | "literal" | "minusSign" | "nan" | "plusSign" | "percentSign"; + + interface NumberFormatPart { + type: NumberFormatPartTypes; + value: string; + } + + interface NumberFormat { + formatToParts(number?: number): NumberFormatPart[]; + } + } diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index c5b17f6056096..bfab76b80ab4a 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Deklaracja przestrzeni nazw nie może występować przed klasą lub funkcją, z którą ją scalono.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Deklaracja przestrzeni nazw jest dozwolona tylko w przestrzeni nazw lub module.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Nie można wywołać lub skonstruować importu stylu przestrzeni nazw. Spowoduje to błąd w czasie wykonania.", - "A_non_dry_build_would_build_project_0_6357": "Kompilacja inna niż DRY spowodowałaby skompilowanie projektu „{0}”", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Kompilacja inna niż DRY spowodowałaby usunięcie następujących plików: {0}", + "A_non_dry_build_would_build_project_0_6357": "Kompilacja inna niż -dry spowodowałaby skompilowanie projektu „{0}”", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Kompilacja inna niż -dry spowodowałaby usunięcie następujących plików: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Inicjator parametru jest dozwolony tylko w implementacji funkcji lub konstruktora.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Właściwości parametru nie można zadeklarować za pomocą parametru rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Właściwość parametru jest dozwolona tylko w implementacji konstruktora.", diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index cd239619457fe..1500a9b598707 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -9,7 +9,9 @@ declare namespace ts.server.protocol { GetSpanOfEnclosingComment = "getSpanOfEnclosingComment", Change = "change", Close = "close", + /** @deprecated Prefer CompletionInfo -- see comment on CompletionsResponse */ Completions = "completions", + CompletionInfo = "completionInfo", CompletionDetails = "completionEntryDetails", CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList", CompileOnSaveEmitFile = "compileOnSaveEmitFile", @@ -464,7 +466,8 @@ declare namespace ts.server.protocol { command: CommandTypes.GetEditsForFileRename; arguments: GetEditsForFileRenameRequestArgs; } - interface GetEditsForFileRenameRequestArgs extends FileRequestArgs { + /** Note: Paths may also be directories. */ + interface GetEditsForFileRenameRequestArgs { readonly oldFilePath: string; readonly newFilePath: string; } @@ -1343,6 +1346,10 @@ declare namespace ts.server.protocol { * Optional prefix to apply to possible completions. */ prefix?: string; + /** + * Character that was responsible for triggering completion. + * Should be `undefined` if a user manually requested completion. + */ triggerCharacter?: CompletionsTriggerCharacter; /** * @deprecated Use UserPreferences.includeCompletionsForModuleExports @@ -1485,9 +1492,19 @@ declare namespace ts.server.protocol { */ source?: SymbolDisplayPart[]; } + /** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */ interface CompletionsResponse extends Response { body?: CompletionEntry[]; } + interface CompletionInfoResponse extends Response { + body?: CompletionInfo; + } + interface CompletionInfo { + readonly isGlobalCompletion: boolean; + readonly isMemberCompletion: boolean; + readonly isNewIdentifierLocation: boolean; + readonly entries: ReadonlyArray; + } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } @@ -1570,10 +1587,50 @@ declare namespace ts.server.protocol { */ argumentCount: number; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; /** * Arguments of a signature help request. */ interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + /** + * Reason why signature help was invoked. + * See each individual possible + */ + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; } /** * Signature help request; value of command field is "signatureHelp". @@ -1733,11 +1790,16 @@ declare namespace ts.server.protocol { } /** * Represents additional spans returned with a diagnostic which are relevant to it - * Like DiagnosticWithLinePosition, this is provided in two forms: - * - start and length of the span - * - startLocation and endLocation a pair of Location objects storing the start/end line offset of the span */ interface DiagnosticRelatedInformation { + /** + * The category of the related information message, e.g. "error", "warning", or "suggestion". + */ + category: string; + /** + * The code used ot identify the related information + */ + code: number; /** * Text of related or additional information. */ @@ -1897,7 +1959,7 @@ declare namespace ts.server.protocol { /** * An item found in a navto response. */ - interface NavtoItem { + interface NavtoItem extends FileSpan { /** * The symbol's name. */ @@ -1909,27 +1971,15 @@ declare namespace ts.server.protocol { /** * exact, substring, or prefix. */ - matchKind?: string; + matchKind: string; /** * If this was a case sensitive or insensitive match. */ - isCaseSensitive?: boolean; + isCaseSensitive: boolean; /** * Optional modifiers for the kind (such as 'public'). */ kindModifiers?: string; - /** - * The file in which the symbol is found. - */ - file: string; - /** - * The location within file at which the symbol is found. - */ - start: Location; - /** - * One past the last character of the symbol. - */ - end: Location; /** * Name of symbol's container symbol (if any); for example, * the class name if symbol is a class member. diff --git a/lib/pt-br/diagnosticMessages.generated.json b/lib/pt-br/diagnosticMessages.generated.json index abae5e7a64f39..86442c1764017 100644 --- a/lib/pt-br/diagnosticMessages.generated.json +++ b/lib/pt-br/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Uma declaração de namespace não pode estar localizada antes de uma classe ou função com a qual ela é mesclada.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Uma declaração de namespace só é permitida e um namespace ou módulo.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Uma importação de estilo do namespace não pode ser chamada nem construída e causará uma falha no tempo de execução.", - "A_non_dry_build_would_build_project_0_6357": "Um build não dry compilaria o projeto '{0}'", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Um build não dry excluiria os seguintes arquivos: {0}", + "A_non_dry_build_would_build_project_0_6357": "Um build não -dry compilaria o projeto '{0}'", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "Um build não -dry excluiria os seguintes arquivos: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Um inicializador de parâmetro só é permitido em uma implementação de função ou de construtor.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Uma propriedade de parâmetro não pode ser declarada usando um parâmetro rest.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Uma propriedade de parâmetro somente é permitida em uma implementação de construtor.", diff --git a/lib/ru/diagnosticMessages.generated.json b/lib/ru/diagnosticMessages.generated.json index 1da5b76d7a9e7..90d11ced2778d 100644 --- a/lib/ru/diagnosticMessages.generated.json +++ b/lib/ru/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Объявление пространства имен не может располагаться раньше класса или функции, с которыми оно объединено.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Объявление пространства имен разрешено использовать только в пространстве имен или модуле.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Импорт стиля пространства имен не может быть вызван или создан и приведет к сбою во время выполнения.", - "A_non_dry_build_would_build_project_0_6357": "При выполнении сборки в рабочем режиме будет собран проект \"{0}\"", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "При выполнении сборки в рабочем режиме будут удалены следующие файлы: {0}", + "A_non_dry_build_would_build_project_0_6357": "При сборке без флага -dry будет собран проект \"{0}\"", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "При сборке без флага -dry будут удалены следующие файлы: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Инициализатор параметра разрешено использовать только в реализации функции или конструктора.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Свойство параметра невозможно объявить с помощью параметра REST.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Свойство параметра допускается только в реализации конструктора.", diff --git a/lib/tr/diagnosticMessages.generated.json b/lib/tr/diagnosticMessages.generated.json index cbfdb9d00275d..611ccb3a4ad33 100644 --- a/lib/tr/diagnosticMessages.generated.json +++ b/lib/tr/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "Bir ad alanı bildirimi, birleştirildiği sınıf veya işlevden önce gelemez.", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "Ad alanı bildirimine yalnızca bir ad alanında veya modülde izin verilir.", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "Bir ad alanı stili içeri aktarma işlemi çağrılamadığından veya oluşturulamadığından çalışma zamanında hataya yol açacak.", - "A_non_dry_build_would_build_project_0_6357": "DRY dışı bir derleme '{0}' projesini derler", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "DRY dışı bir derleme şu dosyaları siler: {0}", + "A_non_dry_build_would_build_project_0_6357": "non-dry bir derleme '{0}' projesini derler", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "non-dry bir derleme şu dosyaları siler: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "Parametre başlatıcısına yalnızca bir işlevde veya oluşturucu uygulamasında izin verilir.", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "Parametre özelliği, rest parametresi kullanılarak bildirilemez.", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "Parametre özelliğine yalnızca bir oluşturucu uygulamasında izin verilir.", diff --git a/lib/tsc.js b/lib/tsc.js index c4211aa1b3b45..e3884ccf3bd67 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -1,3 +1,19 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + + "use strict";"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -10,6 +26,33 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +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 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, 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 __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; @@ -783,23 +826,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1587,8 +1613,9 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; - function tryRemovePrefix(str, prefix) { - return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2559,6 +2586,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -2710,7 +2740,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -2830,6 +2859,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -2860,7 +2891,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -2930,6 +2961,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -2979,6 +3011,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -3126,6 +3159,9 @@ var ts; Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -3212,6 +3248,8 @@ var ts; Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -3511,6 +3549,10 @@ var ts; Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true), All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -3542,6 +3584,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -3573,6 +3617,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -3717,6 +3762,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -5663,7 +5712,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274) { + while (node && node.kind !== 277) { node = node.parent; } return node; @@ -5671,11 +5720,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213: - case 241: - case 220: - case 221: - case 222: + case 216: + case 244: + case 223: + case 224: + case 225: return true; } return false; @@ -5768,7 +5817,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 300 && node._children.length > 0) { + if (node.kind === 303 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -5847,10 +5896,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; function makeIdentifierFromModuleName(moduleName) { return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } @@ -5862,7 +5907,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 && node.parent.kind === 269; + return node.kind === 235 && node.parent.kind === 272; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -5886,11 +5931,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 239 && (!node.body); + return node && node.kind === 242 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 || - node.kind === 239 || + return node.kind === 277 || + node.kind === 242 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5904,9 +5949,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 274: + case 277: return ts.isExternalModule(node.parent); - case 240: + case 243: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5918,22 +5963,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274: - case 241: - case 269: - case 239: - case 220: - case 221: - case 222: + case 277: + case 244: + case 272: + case 242: + case 223: + case 224: + case 225: case 155: case 154: case 156: case 157: - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: return true; - case 213: + case 216: return !ts.isFunctionLike(parentNode); } return false; @@ -5947,22 +5992,22 @@ var ts; case 160: case 163: case 164: - case 284: - case 235: - case 205: - case 236: + case 287: + case 238: + case 207: + case 239: + case 240: + case 300: case 237: - case 297: - case 234: case 154: case 155: case 156: case 157: - case 192: - case 193: - case 292: - case 298: - case 288: + case 194: + case 195: + case 295: + case 301: + case 291: return true; default: ts.assertTypeIsNever(node); @@ -5972,8 +6017,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244: - case 243: + case 247: + case 246: return true; default: return false; @@ -5982,15 +6027,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 244: - case 243: - case 214: - case 235: - case 234: - case 239: - case 237: - case 236: + case 247: + case 246: + case 217: case 238: + case 237: + case 242: + case 240: + case 239: + case 241: return true; default: return false; @@ -6006,7 +6051,7 @@ var ts; } ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -6033,7 +6078,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185: + case 187: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -6078,7 +6123,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213) { + if (node.body && node.body.kind === 216) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6090,31 +6135,31 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274: + case 277: 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 232: - case 182: case 235: - case 205: - case 236: - case 239: + case 184: case 238: - case 273: - case 234: - case 192: + case 207: + case 239: + case 242: + case 241: + case 276: + case 237: + case 194: case 154: case 156: case 157: - case 237: + case 240: case 152: case 151: errorNode = node.name; break; - case 193: + case 195: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6143,35 +6188,34 @@ var ts; return file.scriptKind === 6; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2) - || !!(ts.getCombinedModifierFlags(node) & 2048); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 && n.expression.kind === 97; + return n.kind === 189 && n.expression.kind === 97; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 && n.expression.kind === 91; + return n.kind === 189 && n.expression.kind === 91; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 && - n.argument.kind === 178 && + return n.kind === 181 && + n.argument.kind === 180 && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 + return node.kind === 219 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -6182,9 +6226,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 || node.kind === 148 || - node.kind === 192 || - node.kind === 193 || - node.kind === 191) ? + node.kind === 194 || + node.kind === 195 || + node.kind === 193) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -6199,7 +6243,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 <= node.kind && node.kind <= 179) { + if (161 <= node.kind && node.kind <= 181) { return true; } switch (node.kind) { @@ -6213,45 +6257,45 @@ var ts; case 131: return true; case 105: - return node.parent.kind !== 196; - case 207: + return node.parent.kind !== 198; + case 209: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148: - return node.parent.kind === 177 || node.parent.kind === 172; + return node.parent.kind === 179 || node.parent.kind === 174; case 71: if (node.parent.kind === 146 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 && node.parent.name === node) { + else if (node.parent.kind === 187 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 71 || node.kind === 146 || node.kind === 185, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 71 || node.kind === 146 || node.kind === 187, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); case 146: - case 185: + case 187: case 99: { var parent = node.parent; if (parent.kind === 165) { return false; } - if (parent.kind === 179) { + if (parent.kind === 181) { return !parent.isTypeOf; } - if (161 <= parent.kind && parent.kind <= 179) { + if (161 <= parent.kind && parent.kind <= 181) { return true; } switch (parent.kind) { - case 207: + case 209: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148: return node === parent.constraint; case 152: case 151: case 149: - case 232: + case 235: return node === parent.type; - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: case 155: case 154: case 153: @@ -6262,12 +6306,12 @@ var ts; case 159: case 160: return node === parent.type; - case 190: + case 192: return node === parent.type; - case 187: - case 188: - return ts.contains(parent.typeArguments, node); case 189: + case 190: + return ts.contains(parent.typeArguments, node); + case 191: return false; } } @@ -6289,23 +6333,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225: + case 228: return visitor(node); - case 241: - case 213: - case 217: - case 218: - case 219: + case 244: + case 216: case 220: case 221: case 222: - case 226: - case 227: - case 266: - case 267: - case 228: + case 223: + case 224: + case 225: + case 229: case 230: case 269: + case 270: + case 231: + case 233: + case 272: return ts.forEachChild(node, traverse); } } @@ -6315,19 +6359,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203: + case 205: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238: - case 236: + case 241: case 239: - case 237: - case 235: - case 205: + case 242: + case 240: + case 238: + case 207: return; default: if (ts.isFunctionLike(node)) { @@ -6357,12 +6401,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236: - case 235: - case 205: + case 239: + case 238: + case 207: case 166: return node.members; - case 184: + case 186: return node.properties; } } @@ -6370,14 +6414,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182: - case 273: + case 184: + case 276: case 149: - case 270: + case 273: case 152: case 151: - case 271: - case 232: + case 274: + case 235: return true; } } @@ -6389,12 +6433,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 - && node.parent.parent.kind === 214; + return node.parent.kind === 236 + && node.parent.parent.kind === 217; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -6406,8 +6450,8 @@ var ts; case 155: case 156: case 157: - case 234: - case 192: + case 237: + case 194: return true; } return false; @@ -6418,7 +6462,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228) { + if (node.statement.kind !== 231) { return node.statement; } node = node.statement; @@ -6426,17 +6470,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 && ts.isFunctionLike(node.parent); + return node && node.kind === 216 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 && node.parent.kind === 184; + return node && node.kind === 154 && node.parent.kind === 186; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 && - (node.parent.kind === 184 || - node.parent.kind === 205); + (node.parent.kind === 186 || + node.parent.kind === 207); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6449,7 +6493,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270) { + if (property.kind === 273) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -6486,7 +6530,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274); + ts.Debug.assert(node.kind !== 277); while (true) { node = node.parent; if (!node) { @@ -6507,13 +6551,13 @@ var ts; node = node.parent; } break; - case 193: + case 195: if (!includeArrowFunctions) { continue; } - case 234: - case 192: - case 239: + case 237: + case 194: + case 242: case 152: case 151: case 154: @@ -6524,8 +6568,8 @@ var ts; case 158: case 159: case 160: - case 238: - case 274: + case 241: + case 277: return node; } } @@ -6536,8 +6580,8 @@ var ts; if (container) { switch (container.kind) { case 155: - case 234: - case 192: + case 237: + case 194: return container; } } @@ -6554,9 +6598,9 @@ var ts; case 147: node = node.parent; break; - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: if (!stopOnFunctions) { continue; } @@ -6581,14 +6625,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 || func.kind === 193) { + if (func.kind === 194 || func.kind === 195) { var prev = func; var parent = func.parent; - while (parent.kind === 191) { + while (parent.kind === 193) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 && parent.expression === prev) { + if (parent.kind === 189 && parent.expression === prev) { return parent; } } @@ -6596,13 +6640,13 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 || kind === 186) + return (kind === 187 || kind === 188) && node.expression.kind === 97; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 185 || kind === 186) + return (kind === 187 || kind === 188) && node.expression.kind === 99; } ts.isThisProperty = isThisProperty; @@ -6610,7 +6654,7 @@ var ts; switch (node.kind) { case 162: return node.typeName; - case 207: + case 209: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -6623,10 +6667,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189: + case 191: return node.tag; - case 257: - case 256: + case 260: + case 259: return node.tagName; default: return node.expression; @@ -6635,21 +6679,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235: + case 238: return true; case 152: - return parent.kind === 235; + return parent.kind === 238; case 156: case 157: case 154: return node.body !== undefined - && parent.kind === 235; + && parent.kind === 238; case 149: return parent.body !== undefined && (parent.kind === 155 || parent.kind === 154 || parent.kind === 157) - && grandparent.kind === 235; + && grandparent.kind === 238; } return false; } @@ -6665,7 +6709,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235: + case 238: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); case 154: case 157: @@ -6677,9 +6721,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 || - parent.kind === 256 || - parent.kind === 258) { + if (parent.kind === 260 || + parent.kind === 259 || + parent.kind === 261) { return parent.tagName === node; } return false; @@ -6692,37 +6736,37 @@ var ts; case 101: case 86: case 12: - case 183: - case 184: case 185: case 186: case 187: case 188: case 189: - case 208: case 190: - case 209: case 191: + case 210: case 192: - case 205: + case 211: case 193: - case 196: case 194: + case 207: case 195: case 198: - case 199: + case 196: + case 197: case 200: case 201: - case 204: case 202: - case 13: + case 203: case 206: - case 255: - case 256: + case 204: + case 13: + case 208: + case 258: case 259: - case 203: - case 197: - case 210: + case 262: + case 205: + case 199: + case 212: return true; case 146: while (node.parent.kind === 146) { @@ -6745,47 +6789,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232: + case 235: case 149: case 152: case 151: + case 276: case 273: - case 270: - case 182: + case 184: return parent.initializer === node; - case 216: - case 217: - case 218: case 219: - case 225: - case 226: - case 227: - case 266: + case 220: + case 221: + case 222: + case 228: case 229: + case 230: + case 269: + case 232: return parent.expression === node; - case 220: + case 223: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236) || forStatement.condition === node || forStatement.incrementor === node; - case 221: - case 222: + case 224: + case 225: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236) || forInStatement.expression === node; - case 190: - case 208: + case 192: + case 210: return node === parent.expression; - case 211: + case 214: return node === parent.expression; case 147: return node === parent.expression; case 150: - case 265: - case 264: - case 272: + case 268: + case 267: + case 275: return true; - case 207: + case 209: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -6793,7 +6837,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 && node.moduleReference.kind === 254; + return node.kind === 246 && node.moduleReference.kind === 257; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -6802,7 +6846,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 && node.moduleReference.kind !== 254; + return node.kind === 246 && node.moduleReference.kind !== 257; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -6834,7 +6878,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187) { + if (callExpression.kind !== 189) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -6914,11 +6958,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 || e.kind === 193 ? initializer : undefined; + return e.kind === 194 || e.kind === 195 ? initializer : undefined; } - if (initializer.kind === 192 || - initializer.kind === 205 || - initializer.kind === 193) { + if (initializer.kind === 194 || + initializer.kind === 207 || + initializer.kind === 195) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -6990,6 +7034,13 @@ var ts; return 0; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + return 6; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99) { return 4; } @@ -6997,10 +7048,7 @@ var ts; return 2; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - return 6; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { return 3; } var nextToLast = lhs; @@ -7017,7 +7065,7 @@ var ts; } return 0; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -7031,7 +7079,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 && + expr.parent && expr.parent.kind === 219 && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -7041,14 +7089,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244: - case 250: + case 247: + case 253: return node.parent; - case 254: + case 257: return node.parent.parent; - case 187: + case 189: return node.parent; - case 178: + case 180: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -7058,12 +7106,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244: - case 250: + case 247: + case 253: return node.moduleSpecifier; - case 243: - return node.moduleReference.kind === 254 ? node.moduleReference.expression : undefined; - case 179: + case 246: + return node.moduleReference.kind === 257 ? node.moduleReference.expression : undefined; + case 181: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -7072,11 +7120,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244: + case 247: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243: + case 246: return node; - case 250: + case 253: return undefined; default: return ts.Debug.assertNever(node); @@ -7084,7 +7132,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 && !!node.importClause && !!node.importClause.name; + return node.kind === 247 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -7093,8 +7141,8 @@ var ts; case 149: case 154: case 153: - case 271: - case 270: + case 274: + case 273: case 152: case 151: return node.questionToken !== undefined; @@ -7104,14 +7152,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 && + return node.kind === 287 && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 || node.kind === 292; + return node.kind === 301 || node.kind === 295; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -7136,12 +7184,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214: + case 217: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152: return node.initializer; - case 270: + case 273: return node.initializer; } } @@ -7151,52 +7199,50 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 + node.body.kind === 242 ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - if (parent.kind === 270 || parent.kind === 152 || getNestedModuleDeclaration(parent)) { - getJSDocCommentsAndTagsWorker(parent); - } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 || - node.kind === 185 && node.parent && node.parent.kind === 216) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); } if (node.kind === 149) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; } - if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { - result = ts.addRange(result, node.initializer.jsDoc); - } - if (ts.hasJSDocNodes(node)) { - result = ts.addRange(result, node.jsDoc); - } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 || + parent.kind === 152 || + parent.kind === 219 && node.kind === 187 || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58) { + return parent; + } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } function getParameterSymbolFromJSDoc(node) { if (node.symbol) { return node.symbol; @@ -7244,38 +7290,38 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 200: + case 202: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 ? 1 : 2 : 0; - case 198: - case 199: + case 200: + case 201: var unaryOperator = parent.operator; return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; - case 221: - case 222: + case 224: + case 225: return parent.initializer === node ? 1 : 0; - case 191: - case 183: - case 204: - case 209: + case 193: + case 185: + case 206: + case 211: node = parent; break; - case 271: + case 274: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 270: + case 273: if (parent.name === node) { return 0; } @@ -7294,22 +7340,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 213: - case 214: - case 226: + case 216: case 217: - case 227: - case 241: - case 266: - case 267: - case 228: + case 229: case 220: - case 221: - case 222: - case 218: - case 219: case 230: + case 244: case 269: + case 270: + case 231: + case 223: + case 224: + case 225: + case 221: + case 222: + case 233: + case 272: return true; } return false; @@ -7326,26 +7372,26 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173); + return walkUp(node, 175); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191); + return walkUp(node, 193); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191) { + while (node.kind === 193) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function isDeleteTarget(node) { - if (node.kind !== 185 && node.kind !== 186) { + if (node.kind !== 187 && node.kind !== 188) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194; + return node && node.kind === 196; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -7399,9 +7445,9 @@ var ts; case 153: case 156: case 157: + case 276: case 273: - case 270: - case 185: + case 187: return parent.name === node; case 146: if (parent.right === node) { @@ -7411,24 +7457,24 @@ var ts; return parent.kind === 165 || parent.kind === 162; } return false; - case 182: - case 248: + case 184: + case 251: return parent.propertyName === node; - case 252: - case 262: + case 255: + case 265: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 243 || - node.kind === 242 || - node.kind === 245 && !!node.name || - node.kind === 246 || - node.kind === 248 || - node.kind === 252 || - node.kind === 249 && exportAssignmentIsAlias(node) || + return node.kind === 246 || + node.kind === 245 || + node.kind === 248 && !!node.name || + node.kind === 249 || + node.kind === 251 || + node.kind === 255 || + node.kind === 252 && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -7437,11 +7483,21 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108); return heritageClause ? heritageClause.types : undefined; @@ -7449,7 +7505,7 @@ var ts; ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -7514,13 +7570,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 234: - case 192: + case 237: + case 194: case 154: if (node.asteriskToken) { flags |= 1; } - case 193: + case 195: if (hasModifier(node, 256)) { flags |= 2; } @@ -7534,9 +7590,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: case 154: return node.body !== undefined && node.asteriskToken === undefined @@ -7627,7 +7683,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182) { + while (node.kind === 184) { node = node.parent.parent; } return node; @@ -7636,14 +7692,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 - || kind === 192 - || kind === 234 - || kind === 193 + || kind === 194 + || kind === 237 + || kind === 195 || kind === 154 || kind === 156 || kind === 157 - || kind === 239 - || kind === 274; + || kind === 242 + || kind === 277; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -7657,23 +7713,23 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188: + case 190: return hasArguments ? 0 : 1; + case 200: + case 197: case 198: - case 195: case 196: - case 194: - case 197: - case 201: + case 199: case 203: + case 205: return 1; - case 200: + case 202: switch (operator) { case 40: case 58: @@ -7697,15 +7753,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200) { + if (expression.kind === 202) { return expression.operatorToken.kind; } - else if (expression.kind === 198 || expression.kind === 199) { + else if (expression.kind === 200 || expression.kind === 201) { return expression.operator; } else { @@ -7715,15 +7771,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303: + case 306: return 0; - case 204: + case 206: return 1; - case 203: + case 205: return 2; - case 201: + case 203: return 4; - case 200: + case 202: switch (operatorKind) { case 26: return 0; @@ -7744,21 +7800,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } + case 200: + case 197: case 198: - case 195: case 196: - case 194: - case 197: - return 16; case 199: + return 16; + case 201: return 17; - case 187: + case 189: return 18; - case 188: + case 190: return hasArguments ? 19 : 18; - case 189: - case 185: - case 186: + case 191: + case 187: + case 188: return 19; case 99: case 97: @@ -7768,19 +7824,19 @@ var ts; case 86: case 8: case 9: - case 183: - case 184: - case 192: - case 193: - case 205: - case 255: - case 256: + case 185: + case 186: + case 194: + case 195: + case 207: + case 258: case 259: + case 262: case 12: case 13: - case 202: - case 191: - case 206: + case 204: + case 193: + case 208: return 20; default: return -1; @@ -7836,6 +7892,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -7843,6 +7900,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -8221,7 +8295,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286); + ts.Debug.assert(node.parent.kind === 289); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); @@ -8232,7 +8306,7 @@ var ts; } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 && tag.parent.tags.some(isJSDocTypeAlias)); } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); @@ -8476,8 +8550,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 184 - || kind === 183; + return kind === 186 + || kind === 185; } return false; } @@ -8487,7 +8561,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 + return node.kind === 209 && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 @@ -8509,16 +8583,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 && node.parent.right === node) || - (node.parent.kind === 185 && node.parent.name === node); + (node.parent.kind === 187 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 && + return expression.kind === 186 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 && + return expression.kind === 185 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -8798,8 +8872,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238: - case 239: + case 241: + case 242: return parseNode === parseNode.parent.name; } } @@ -8865,20 +8939,20 @@ var ts; if (!parent) return 0; switch (parent.kind) { - case 199: - case 198: + case 201: + case 200: var operator = parent.operator; return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; - case 200: + case 202: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; - case 185: + case 187: return parent.name !== node ? 0 : accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && parent.parent.kind === 216 ? 1 : 2; + return parent.parent && parent.parent.kind === 219 ? 1 : 2; } } function compareDataObjects(dst, src) { @@ -8967,7 +9041,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -9036,6 +9110,10 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); } @@ -9138,7 +9216,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239) { return current; } } @@ -9163,42 +9241,37 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235) { node = node.parent; } - if (node && node.kind === 233) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232) { - node = node.parent; - } - if (node && node.kind === 233) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; function validateLocaleAndSetLanguage(locale, sys, errors) { @@ -9286,10 +9359,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; function nameForNamelessJSDocTypedef(declaration) { var hostNode = declaration.parent.parent; if (!hostNode) { @@ -9299,17 +9368,17 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 214: + case 217: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216: + case 219: var expr = hostNode.expression; switch (expr.kind) { - case 185: + case 187: return expr.name; - case 186: + case 188: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -9318,10 +9387,10 @@ var ts; return undefined; case 1: return undefined; - case 191: { + case 193: { return getDeclarationIdentifier(hostNode.expression); } - case 228: { + case 231: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -9333,7 +9402,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -9343,28 +9412,19 @@ var ts; return !!node.name; } ts.isNamedDeclaration = isNamedDeclaration; - function getNameOfDeclaration(declaration) { - if (!declaration) { - return undefined; - } + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205: - case 192: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71: return declaration; - case 299: - case 293: { + case 302: + case 296: { var name = declaration.name; if (name.kind === 146) { return name.right; } break; } - case 200: { + case 202: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1: @@ -9376,17 +9436,22 @@ var ts; return undefined; } } - case 292: - return declaration.name; - case 298: + case 301: return getNameOfJSDocTypedef(declaration); - case 249: { + case 252: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -9619,540 +9684,540 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169; + return node.kind === 171; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170; + return node.kind === 172; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171; + return node.kind === 173; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172; + return node.kind === 174; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173; + return node.kind === 175; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174; + return node.kind === 176; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175; + return node.kind === 177; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176; + return node.kind === 178; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177; + return node.kind === 179; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178; + return node.kind === 180; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179; + return node.kind === 181; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 180; + return node.kind === 182; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181; + return node.kind === 183; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182; + return node.kind === 184; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 183; + return node.kind === 185; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184; + return node.kind === 186; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185; + return node.kind === 187; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186; + return node.kind === 188; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187; + return node.kind === 189; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188; + return node.kind === 190; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189; + return node.kind === 191; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190; + return node.kind === 192; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191; + return node.kind === 193; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302) { + while (node.kind === 305) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192; + return node.kind === 194; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193; + return node.kind === 195; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194; + return node.kind === 196; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195; + return node.kind === 197; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196; + return node.kind === 198; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197; + return node.kind === 199; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198; + return node.kind === 200; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199; + return node.kind === 201; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200; + return node.kind === 202; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201; + return node.kind === 203; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202; + return node.kind === 204; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203; + return node.kind === 205; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204; + return node.kind === 206; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205; + return node.kind === 207; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206; + return node.kind === 208; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207; + return node.kind === 209; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208; + return node.kind === 210; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209; + return node.kind === 211; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210; + return node.kind === 212; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 211; + return node.kind === 214; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212; + return node.kind === 215; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 213; + return node.kind === 216; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214; + return node.kind === 217; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215; + return node.kind === 218; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216; + return node.kind === 219; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217; + return node.kind === 220; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218; + return node.kind === 221; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219; + return node.kind === 222; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220; + return node.kind === 223; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221; + return node.kind === 224; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222; + return node.kind === 225; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223; + return node.kind === 226; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224; + return node.kind === 227; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 || node.kind === 223; + return node.kind === 227 || node.kind === 226; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225; + return node.kind === 228; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226; + return node.kind === 229; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227; + return node.kind === 230; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228; + return node.kind === 231; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229; + return node.kind === 232; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230; + return node.kind === 233; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231; + return node.kind === 234; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232; + return node.kind === 235; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233; + return node.kind === 236; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234; + return node.kind === 237; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235; + return node.kind === 238; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236; + return node.kind === 239; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237; + return node.kind === 240; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238; + return node.kind === 241; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239; + return node.kind === 242; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240; + return node.kind === 243; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241; + return node.kind === 244; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242; + return node.kind === 245; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243; + return node.kind === 246; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244; + return node.kind === 247; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245; + return node.kind === 248; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246; + return node.kind === 249; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247; + return node.kind === 250; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248; + return node.kind === 251; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249; + return node.kind === 252; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250; + return node.kind === 253; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251; + return node.kind === 254; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252; + return node.kind === 255; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253; + return node.kind === 256; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 254; + return node.kind === 257; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 255; + return node.kind === 258; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256; + return node.kind === 259; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257; + return node.kind === 260; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258; + return node.kind === 261; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259; + return node.kind === 262; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260; + return node.kind === 263; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261; + return node.kind === 264; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262; + return node.kind === 265; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263; + return node.kind === 266; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264; + return node.kind === 267; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265; + return node.kind === 268; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 266; + return node.kind === 269; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267; + return node.kind === 270; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268; + return node.kind === 271; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269; + return node.kind === 272; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 270; + return node.kind === 273; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271; + return node.kind === 274; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272; + return node.kind === 275; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 273; + return node.kind === 276; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 274; + return node.kind === 277; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275; + return node.kind === 278; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276; + return node.kind === 279; } ts.isUnparsedSource = isUnparsedSource; function isJSDocTypeExpression(node) { - return node.kind === 278; + return node.kind === 281; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279; + return node.kind === 282; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280; + return node.kind === 283; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281; + return node.kind === 284; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282; + return node.kind === 285; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283; + return node.kind === 286; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284; + return node.kind === 287; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285; + return node.kind === 288; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286; + return node.kind === 289; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290; + return node.kind === 293; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291; + return node.kind === 294; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295; + return node.kind === 298; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293; + return node.kind === 296; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294; + return node.kind === 297; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296; + return node.kind === 299; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297; + return node.kind === 300; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298; + return node.kind === 301; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299; + return node.kind === 302; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 || node.kind === 293; + return node.kind === 302 || node.kind === 296; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287; + return node.kind === 290; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292; + return node.kind === 295; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288; + return node.kind === 291; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 300; + return n.kind === 303; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -10248,8 +10313,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 - || kind === 180 - || kind === 181; + || kind === 182 + || kind === 183; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -10262,13 +10327,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234: + case 237: case 154: case 155: case 156: case 157: - case 192: - case 193: + case 194: + case 195: return true; default: return false; @@ -10278,11 +10343,11 @@ var ts; switch (kind) { case 153: case 158: - case 288: + case 291: case 159: case 160: case 163: - case 284: + case 287: case 164: return true; default: @@ -10302,11 +10367,11 @@ var ts; || kind === 156 || kind === 157 || kind === 160 - || kind === 212; + || kind === 215; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 || node.kind === 205); + return node && (node.kind === 238 || node.kind === 207); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -10339,16 +10404,16 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 - || kind === 271 - || kind === 272 + return kind === 273 + || kind === 274 + || kind === 275 || kind === 154 || kind === 156 || kind === 157; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 161 && kind <= 179) + return (kind >= 161 && kind <= 181) || kind === 119 || kind === 142 || kind === 134 @@ -10361,14 +10426,14 @@ var ts; || kind === 140 || kind === 95 || kind === 131 - || kind === 207 - || kind === 279 - || kind === 280 - || kind === 281 + || kind === 209 || kind === 282 || kind === 283 || kind === 284 - || kind === 285; + || kind === 285 + || kind === 286 + || kind === 287 + || kind === 288; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -10386,29 +10451,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 - || kind === 180; + return kind === 183 + || kind === 182; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 - || kind === 184; + return kind === 185 + || kind === 186; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 - || kind === 206; + return kind === 184 + || kind === 208; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232: + case 235: case 149: - case 182: + case 184: return true; } return false; @@ -10421,8 +10486,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180: - case 184: + case 182: + case 186: return true; } return false; @@ -10430,8 +10495,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181: case 183: + case 185: return true; } return false; @@ -10439,24 +10504,24 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 + return kind === 187 || kind === 146 - || kind === 179; + || kind === 181; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 + return kind === 187 || kind === 146; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257: - case 256: - case 187: - case 188: + case 260: + case 259: case 189: + case 190: + case 191: case 150: return true; default: @@ -10465,12 +10530,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 || node.kind === 188; + return node.kind === 189 || node.kind === 190; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 + return kind === 204 || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; @@ -10480,32 +10545,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 185: - case 186: - case 188: case 187: - case 255: - case 256: - case 259: + case 188: + case 190: case 189: - case 183: + case 258: + case 259: + case 262: case 191: - case 184: - case 205: - case 192: + case 185: + case 193: + case 186: + case 207: + case 194: case 71: case 12: case 8: case 9: case 13: - case 202: + case 204: case 86: case 95: case 99: case 101: case 97: - case 209: - case 210: + case 211: + case 212: case 91: return true; default: @@ -10518,13 +10583,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198: - case 199: - case 194: - case 195: + case 200: + case 201: case 196: case 197: - case 190: + case 198: + case 199: + case 192: return true; default: return isLeftHandSideExpressionKind(kind); @@ -10532,9 +10597,9 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199: + case 201: return true; - case 198: + case 200: return expr.operator === 43 || expr.operator === 44; default: @@ -10548,15 +10613,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201: case 203: - case 193: - case 200: - case 204: - case 208: + case 205: + case 195: + case 202: case 206: - case 303: - case 302: + case 210: + case 208: + case 306: + case 305: return true; default: return isUnaryExpressionKind(kind); @@ -10564,16 +10629,16 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 - || kind === 208; + return kind === 192 + || kind === 210; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 302; + return node.kind === 305; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 301; + return node.kind === 304; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10583,20 +10648,20 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220: + case 223: + case 224: + case 225: case 221: case 222: - case 218: - case 219: return true; - case 228: + case 231: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isForInOrOfStatement(node) { - return node.kind === 221 || node.kind === 222; + return node.kind === 224 || node.kind === 225; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -10615,108 +10680,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 240 - || kind === 239 + return kind === 243 + || kind === 242 || kind === 71; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 - || kind === 239; + return kind === 243 + || kind === 242; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 - || kind === 239; + || kind === 242; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 - || kind === 246; + return kind === 250 + || kind === 249; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 239 || node.kind === 238; + return node.kind === 242 || node.kind === 241; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 - || kind === 182 - || kind === 235 - || kind === 205 - || kind === 155 + return kind === 195 + || kind === 184 || kind === 238 - || kind === 273 - || kind === 252 - || kind === 234 - || kind === 192 + || kind === 207 + || kind === 155 + || kind === 241 + || kind === 276 + || kind === 255 + || kind === 237 + || kind === 194 || kind === 156 - || kind === 245 - || kind === 243 || kind === 248 - || kind === 236 - || kind === 262 + || kind === 246 + || kind === 251 + || kind === 239 + || kind === 265 || kind === 154 || kind === 153 - || kind === 239 || kind === 242 - || kind === 246 + || kind === 245 + || kind === 249 || kind === 149 - || kind === 270 + || kind === 273 || kind === 152 || kind === 151 || kind === 157 - || kind === 271 - || kind === 237 + || kind === 274 + || kind === 240 || kind === 148 - || kind === 232 - || kind === 298 - || kind === 292 - || kind === 299; + || kind === 235 + || kind === 301 + || kind === 295 + || kind === 302; } function isDeclarationStatementKind(kind) { - return kind === 234 - || kind === 253 - || kind === 235 - || kind === 236 - || kind === 237 + return kind === 237 + || kind === 256 || kind === 238 || kind === 239 - || kind === 244 - || kind === 243 - || kind === 250 - || kind === 249 - || kind === 242; + || kind === 240 + || kind === 241 + || kind === 242 + || kind === 247 + || kind === 246 + || kind === 253 + || kind === 252 + || kind === 245; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 224 - || kind === 223 - || kind === 231 - || kind === 218 - || kind === 216 - || kind === 215 + return kind === 227 + || kind === 226 + || kind === 234 || kind === 221 - || kind === 222 + || kind === 219 + || kind === 218 + || kind === 224 + || kind === 225 + || kind === 223 || kind === 220 - || kind === 217 + || kind === 231 || kind === 228 - || kind === 225 - || kind === 227 - || kind === 229 || kind === 230 - || kind === 214 - || kind === 219 - || kind === 226 - || kind === 301 - || kind === 305 - || kind === 304; + || kind === 232 + || kind === 233 + || kind === 217 + || kind === 222 + || kind === 229 + || kind === 304 + || kind === 308 + || kind === 307; } function isDeclaration(node) { if (node.kind === 148) { - return node.parent.kind !== 297 || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -10737,10 +10802,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213) + if (node.kind !== 216) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 || node.parent.kind === 269) { + if (node.parent.kind === 233 || node.parent.kind === 272) { return false; } } @@ -10748,7 +10813,7 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 254 + return kind === 257 || kind === 146 || kind === 71; } @@ -10757,52 +10822,52 @@ var ts; var kind = node.kind; return kind === 99 || kind === 71 - || kind === 185; + || kind === 187; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 255 - || kind === 265 - || kind === 256 + return kind === 258 + || kind === 268 + || kind === 259 || kind === 10 - || kind === 259; + || kind === 262; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 - || kind === 264; + return kind === 265 + || kind === 267; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 265; + || kind === 268; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 - || kind === 256; + return kind === 260 + || kind === 259; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 - || kind === 267; + return kind === 269 + || kind === 270; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 278 && node.kind <= 299; + return node.kind >= 281 && node.kind <= 302; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 286 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 289 && node.kind <= 299; + return node.kind >= 292 && node.kind <= 302; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -10838,22 +10903,22 @@ var ts; case 161: case 163: case 164: - case 173: case 175: case 177: - case 190: + case 179: case 192: - case 193: - case 208: - case 232: - case 234: + case 194: + case 195: + case 210: + case 235: case 237: - case 278: + case 240: case 281: - case 282: - case 283: case 284: case 285: + case 286: + case 287: + case 288: return true; } return false; @@ -10869,10 +10934,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262: - case 264: - case 270: - case 271: + case 265: + case 267: + case 273: + case 274: case 154: case 156: case 157: @@ -10883,7 +10948,7 @@ var ts; } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 162 || node.kind === 207; + return node.kind === 162 || node.kind === 209; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -10917,7 +10982,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 247 || node.kind === 251; + return node.kind === 250 || node.kind === 254; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -11054,6 +11119,12 @@ var ts; return diagnostic.file ? diagnostic.file.path : undefined; } function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0; + } + ts.compareDiagnostics = compareDiagnostics; + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -11061,7 +11132,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); + }) || 0; + } + return d1.relatedInformation ? -1 : 1; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -11497,17 +11580,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.tryRemovePrefix(path, dirPath); - if (a === undefined) - return undefined; - switch (a.charCodeAt(0)) { - case 47: - case 92: - return a.slice(1); - default: - return undefined; - } + function isDirectorySeparator(charCode) { + return charCode === 47 || charCode === 92; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; var reservedCharacterPattern = /[^\w\s\/]/g; @@ -11954,7 +12035,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 274) { + if (kind === 277) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71) { @@ -12004,14 +12085,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271: + case 274: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 272: + case 275: return visitNode(cbNode, node.expression); case 149: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -12036,20 +12117,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270: + case 273: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 232: + case 235: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 182: + case 184: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -12071,9 +12152,9 @@ var ts; case 155: case 156: case 157: - case 192: - case 234: - case 193: + case 194: + case 237: + case 195: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12098,290 +12179,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169: - case 170: - return visitNodes(cbNode, cbNodes, node.types); case 171: + case 172: + return visitNodes(cbNode, cbNodes, node.types); + case 173: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172: + case 174: return visitNode(cbNode, node.typeParameter); - case 179: + case 181: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173: case 175: + case 177: return visitNode(cbNode, node.type); - case 176: + case 178: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177: + case 179: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178: - return visitNode(cbNode, node.literal); case 180: - case 181: - return visitNodes(cbNode, cbNodes, node.elements); + return visitNode(cbNode, node.literal); + case 182: case 183: return visitNodes(cbNode, cbNodes, node.elements); - case 184: - return visitNodes(cbNode, cbNodes, node.properties); case 185: + return visitNodes(cbNode, cbNodes, node.elements); + case 186: + return visitNodes(cbNode, cbNodes, node.properties); + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187: - case 188: + case 189: + case 190: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189: + case 191: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190: + case 192: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191: - return visitNode(cbNode, node.expression); - case 194: - return visitNode(cbNode, node.expression); - case 195: + case 193: return visitNode(cbNode, node.expression); case 196: return visitNode(cbNode, node.expression); + case 197: + return visitNode(cbNode, node.expression); case 198: + return visitNode(cbNode, node.expression); + case 200: return visitNode(cbNode, node.operand); - case 203: + case 205: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197: - return visitNode(cbNode, node.expression); case 199: + return visitNode(cbNode, node.expression); + case 201: return visitNode(cbNode, node.operand); - case 200: + case 202: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208: + case 210: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209: + case 211: return visitNode(cbNode, node.expression); - case 210: + case 212: return visitNode(cbNode, node.name); - case 201: + case 203: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204: + case 206: return visitNode(cbNode, node.expression); - case 213: - case 240: + case 216: + case 243: return visitNodes(cbNode, cbNodes, node.statements); - case 274: + case 277: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214: + case 217: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233: + case 236: return visitNodes(cbNode, cbNodes, node.declarations); - case 216: + case 219: return visitNode(cbNode, node.expression); - case 217: + case 220: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218: + case 221: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219: + case 222: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220: + case 223: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221: + case 224: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222: + case 225: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223: - case 224: + case 226: + case 227: return visitNode(cbNode, node.label); - case 225: + case 228: return visitNode(cbNode, node.expression); - case 226: + case 229: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227: + case 230: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241: + case 244: return visitNodes(cbNode, cbNodes, node.clauses); - case 266: + case 269: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267: + case 270: return visitNodes(cbNode, cbNodes, node.statements); - case 228: + case 231: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229: + case 232: return visitNode(cbNode, node.expression); - case 230: + case 233: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269: + case 272: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150: return visitNode(cbNode, node.expression); - case 235: - case 205: + case 238: + case 207: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 236: + case 239: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 237: + case 240: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 238: + case 241: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273: + case 276: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239: + case 242: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243: + case 246: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244: + case 247: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245: + case 248: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242: + case 245: return visitNode(cbNode, node.name); - case 246: + case 249: return visitNode(cbNode, node.name); - case 247: - case 251: - return visitNodes(cbNode, cbNodes, node.elements); case 250: + case 254: + return visitNodes(cbNode, cbNodes, node.elements); + case 253: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248: - case 252: + case 251: + case 255: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249: + case 252: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202: + case 204: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211: + case 214: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147: return visitNode(cbNode, node.expression); - case 268: + case 271: return visitNodes(cbNode, cbNodes, node.types); - case 207: + case 209: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254: + case 257: return visitNode(cbNode, node.expression); - case 253: + case 256: return visitNodes(cbNode, cbNodes, node.decorators); - case 303: + case 306: return visitNodes(cbNode, cbNodes, node.elements); - case 255: + case 258: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259: + case 262: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256: - case 257: + case 259: + case 260: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263: + case 266: return visitNodes(cbNode, cbNodes, node.properties); - case 262: + case 265: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264: + case 267: return visitNode(cbNode, node.expression); - case 265: + case 268: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258: + case 261: return visitNode(cbNode, node.tagName); - case 278: - return visitNode(cbNode, node.type); - case 282: - return visitNode(cbNode, node.type); + case 169: + case 170: case 281: - return visitNode(cbNode, node.type); - case 283: - return visitNode(cbNode, node.type); + case 285: case 284: + case 286: + case 288: + return visitNode(cbNode, node.type); + case 287: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285: - return visitNode(cbNode, node.type); - case 286: + case 289: return visitNodes(cbNode, cbNodes, node.tags); - case 293: - case 299: + case 296: + case 302: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -12390,17 +12469,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294: + case 297: return visitNode(cbNode, node.typeExpression); - case 296: + case 299: return visitNode(cbNode, node.typeExpression); - case 290: + case 293: return visitNode(cbNode, node.class); - case 297: + case 300: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298: + case 301: if (node.typeExpression && - node.typeExpression.kind === 278) { + node.typeExpression.kind === 281) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -12408,18 +12487,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292: + case 295: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295: + case 298: return visitNode(cbNode, node.typeExpression); - case 288: + case 291: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 287: + case 290: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -12427,7 +12506,7 @@ var ts; } } return; - case 302: + case 305: return visitNode(cbNode, node.expression); } } @@ -12534,7 +12613,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216); + var statement = createNode(219); switch (token()) { case 21: statement.expression = parseArrayLiteralExpression(); @@ -12644,13 +12723,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -12677,7 +12753,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(274, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(277, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13310,7 +13386,7 @@ var ts; case 156: case 157: case 152: - case 212: + case 215: return true; case 154: var methodDeclaration = node; @@ -13324,8 +13400,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266: - case 267: + case 269: + case 270: return true; } } @@ -13334,42 +13410,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 234: - case 214: - case 213: + case 237: case 217: case 216: - case 229: - case 225: + case 220: + case 219: + case 232: + case 228: + case 230: case 227: + case 226: case 224: + case 225: case 223: - case 221: case 222: - case 220: - case 219: - case 226: - case 215: - case 230: - case 228: + case 229: case 218: + case 233: case 231: - case 244: - case 243: - case 250: - case 249: - case 239: - case 235: - case 236: + case 221: + case 234: + case 247: + case 246: + case 253: + case 252: + case 242: case 238: - case 237: + case 239: + case 241: + case 240: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273; + return node.kind === 276; } function isReusableTypeMember(node) { if (node) { @@ -13385,7 +13461,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232) { + if (node.kind !== 235) { return false; } var variableDeclarator = node; @@ -13476,7 +13552,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -13515,7 +13596,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202); + var template = createNode(204); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); var list = []; @@ -13527,7 +13608,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211); + var span = createNode(214); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18) { @@ -13585,9 +13666,9 @@ var ts; case 163: case 164: { var _a = node, parameters = _a.parameters, type = _a.type; - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173: + case 175: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -13601,14 +13682,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174); + var node = createNode(176); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279); + var result = createNode(282); if (postFixEquals) { - return createJSDocPostfixType(283, result); + return createPostfixType(286, result); } else { nextToken(); @@ -13616,7 +13697,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282); + var result = createNode(285); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -13630,18 +13711,18 @@ var ts; token() === 29 || token() === 58 || token() === 49) { - var result = createNode(280, pos); + var result = createNode(283, pos); return finishNode(result); } else { - var result = createNode(281, pos); + var result = createNode(284, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284); + var result = createNodeWithJSDoc(287); nextToken(); fillSignature(56, 4 | 32, result); return finishNode(result); @@ -13663,12 +13744,12 @@ var ts; var dotdotdot = parseOptionalToken(24); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285, dotdotdot.pos); + var variadic = createNode(288, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58) { - return createJSDocPostfixType(283, type); + return createPostfixType(286, type); } return type; } @@ -13930,7 +14011,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177); + var node = createNode(179); parseExpected(17); if (token() === 132 || token() === 37 || token() === 38) { node.readonlyToken = parseTokenNode(); @@ -13952,13 +14033,26 @@ var ts; parseExpected(18); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24)) { + var node = createNode(170, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152) && type.kind === 284 && type.pos === type.type.pos) { + type.kind = 169; + } + return type; + } function parseTupleType() { var node = createNode(168); - node.elementTypes = parseBracketedList(20, parseType, 21, 22); + node.elementTypes = parseBracketedList(20, parseTupleElementType, 21, 22); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173); + var node = createNode(175); parseExpected(19); node.type = parseType(); parseExpected(20); @@ -13976,10 +14070,10 @@ var ts; return token() === 23 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178); + var node = createNode(180); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198); + unaryMinusExpression = createNode(200); unaryMinusExpression.operator = 38; nextToken(); } @@ -14000,7 +14094,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288; - var node = createNode(179); + var node = createNode(181); if (parseOptional(103)) { node.isTypeOf = true; } @@ -14123,18 +14217,18 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51: - type = createJSDocPostfixType(282, type); + type = createPostfixType(285, type); break; case 55: if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(281, type); + type = createPostfixType(284, type); break; case 21: parseExpected(21); if (isStartOfType()) { - var node = createNode(176, type.pos); + var node = createNode(178, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22); @@ -14153,21 +14247,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175); + var node = createNode(177); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172); + var node = createNode(174); parseExpected(126); var typeParameter = createNode(148); typeParameter.name = parseIdentifier(); @@ -14200,10 +14294,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170, parseTypeOperatorOrHigher, 48); + return parseUnionOrIntersectionType(172, parseTypeOperatorOrHigher, 48); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169, parseIntersectionTypeOrHigher, 49); + return parseUnionOrIntersectionType(171, parseIntersectionTypeOrHigher, 49); } function isStartOfFunctionType() { if (token() === 27) { @@ -14274,7 +14368,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85)) { - var node = createNode(171, type.pos); + var node = createNode(173, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); parseExpected(55); @@ -14396,7 +14490,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203); + var node = createNode(205); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 39 || isStartOfExpression())) { @@ -14412,11 +14506,11 @@ var ts; ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193, asyncModifier.pos); + node = createNode(195, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193, identifier.pos); + node = createNode(195, identifier.pos); } var parameter = createNode(149, identifier.pos); parameter.name = identifier; @@ -14564,7 +14658,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193); + var node = createNodeWithJSDoc(195); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; if (!fillSignature(56, isAsync, node) && !allowAmbiguity) { @@ -14595,7 +14689,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(201, leftOperand.pos); + var node = createNode(203, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -14647,39 +14741,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200, left.pos); + var node = createNode(202, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208, left.pos); + var node = createNode(210, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198); + var node = createNode(200); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194); + var node = createNode(196); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195); + var node = createNode(197); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196); + var node = createNode(198); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14694,7 +14788,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197); + var node = createNode(199); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14711,7 +14805,7 @@ var ts; if (token() === 40) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190) { + if (simpleUnaryExpression.kind === 192) { parseErrorAt(pos, end, 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 { @@ -14764,7 +14858,7 @@ var ts; } function parseUpdateExpression() { if (token() === 43 || token() === 44) { - var node = createNode(198); + var node = createNode(200); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -14776,7 +14870,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199, expression.pos); + var node = createNode(201, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14795,7 +14889,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(210, fullStart); + var node = createNode(212, fullStart); node.keywordToken = 91; node.name = parseIdentifierName(); expression = finishNode(node); @@ -14819,7 +14913,7 @@ var ts; if (token() === 19 || token() === 23 || token() === 21) { return expression; } - var node = createNode(185, expression.pos); + var node = createNode(187, expression.pos); node.expression = expression; parseExpectedToken(23, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -14828,8 +14922,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257) { - var node = createNode(255, opening.pos); + if (opening.kind === 260) { + var node = createNode(258, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14838,22 +14932,22 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260) { - var node = createNode(259, opening.pos); + else if (opening.kind === 263) { + var node = createNode(262, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256); + ts.Debug.assert(opening.kind === 259); result = opening; } if (inExpressionContext && token() === 27) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(200, result.pos); + var badNode = createNode(202, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -14909,7 +15003,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263); + var jsxAttributes = createNode(266); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -14917,7 +15011,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(27); if (token() === 29) { - var node_1 = createNode(260, fullStart); + var node_1 = createNode(263, fullStart); scanJsxText(); return finishNode(node_1); } @@ -14926,7 +15020,7 @@ var ts; var attributes = parseJsxAttributes(); var node; if (token() === 29) { - node = createNode(257, fullStart); + node = createNode(260, fullStart); scanJsxText(); } else { @@ -14938,7 +15032,7 @@ var ts; parseExpected(29, undefined, false); scanJsxText(); } - node = createNode(256, fullStart); + node = createNode(259, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -14950,7 +15044,7 @@ var ts; var expression = token() === 99 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23)) { - var propertyAccess = createNode(185, expression.pos); + var propertyAccess = createNode(187, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14958,7 +15052,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265); + var node = createNode(268); if (!parseExpected(17)) { return undefined; } @@ -14980,7 +15074,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262); + var node = createNode(265); node.name = parseIdentifierName(); if (token() === 58) { switch (scanJsxAttributeValue()) { @@ -14995,7 +15089,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264); + var node = createNode(267); parseExpected(17); parseExpected(24); node.expression = parseExpression(); @@ -15003,7 +15097,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258); + var node = createNode(261); parseExpected(28); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -15016,7 +15110,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261); + var node = createNode(264); parseExpected(28); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -15031,7 +15125,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190); + var node = createNode(192); parseExpected(27); node.type = parseType(); parseExpected(29); @@ -15042,7 +15136,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23); if (dotToken) { - var propertyAccess = createNode(185, expression.pos); + var propertyAccess = createNode(187, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15050,13 +15144,13 @@ var ts; } if (token() === 51 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209, expression.pos); + var nonNullExpression = createNode(211, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(21)) { - var indexedAccess = createNode(186, expression.pos); + var indexedAccess = createNode(188, expression.pos); indexedAccess.expression = expression; if (token() === 22) { indexedAccess.argumentExpression = createMissingNode(71, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -15083,7 +15177,7 @@ var ts; return token() === 13 || token() === 14; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189, tag.pos); + var tagExpression = createNode(191, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 @@ -15103,7 +15197,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187, expression.pos); + var callExpr = createNode(189, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -15111,7 +15205,7 @@ var ts; continue; } else if (token() === 19) { - var callExpr = createNode(187, expression.pos); + var callExpr = createNode(189, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15208,28 +15302,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191); + var node = createNodeWithJSDoc(193); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204); + var node = createNode(206); parseExpected(24); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 ? parseSpreadElement() : - token() === 26 ? createNode(206) : + token() === 26 ? createNode(208) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183); + var node = createNode(185); parseExpected(21); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15241,7 +15335,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); if (parseOptionalToken(24)) { - node.kind = 272; + node.kind = 275; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15262,7 +15356,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); if (isShorthandPropertyAssignment) { - node.kind = 271; + node.kind = 274; var equalsToken = parseOptionalToken(58); if (equalsToken) { node.equalsToken = equalsToken; @@ -15270,14 +15364,14 @@ var ts; } } else { - node.kind = 270; + node.kind = 273; parseExpected(56); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184); + var node = createNode(186); parseExpected(17); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15291,7 +15385,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(192); + var node = createNodeWithJSDoc(194); node.modifiers = parseModifiers(); parseExpected(89); node.asteriskToken = parseOptionalToken(39); @@ -15316,7 +15410,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94); if (parseOptional(23)) { - var node_2 = createNode(210, fullStart); + var node_2 = createNode(212, fullStart); node_2.keywordToken = 94; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -15333,7 +15427,7 @@ var ts; } break; } - var node = createNode(188, fullStart); + var node = createNode(190, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19) { @@ -15342,7 +15436,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213); + var node = createNode(216); if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15373,12 +15467,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215); + var node = createNode(218); parseExpected(25); return finishNode(node); } function parseIfStatement() { - var node = createNode(217); + var node = createNode(220); parseExpected(90); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15388,7 +15482,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218); + var node = createNode(221); parseExpected(81); node.statement = parseStatement(); parseExpected(106); @@ -15399,7 +15493,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219); + var node = createNode(222); parseExpected(106); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15423,7 +15517,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145) : parseOptional(145)) { - var forOfStatement = createNode(222, pos); + var forOfStatement = createNode(225, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -15431,14 +15525,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92)) { - var forInStatement = createNode(221, pos); + var forInStatement = createNode(224, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220, pos); + var forStatement = createNode(223, pos); forStatement.initializer = initializer; parseExpected(25); if (token() !== 25 && token() !== 20) { @@ -15456,7 +15550,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 ? 72 : 77); + parseExpected(kind === 227 ? 72 : 77); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15464,7 +15558,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225); + var node = createNode(228); parseExpected(96); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -15473,7 +15567,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226); + var node = createNode(229); parseExpected(107); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15482,7 +15576,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266); + var node = createNode(269); parseExpected(73); node.expression = allowInAnd(parseExpression); parseExpected(56); @@ -15490,7 +15584,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267); + var node = createNode(270); parseExpected(79); parseExpected(56); node.statements = parseList(3, parseStatement); @@ -15500,12 +15594,12 @@ var ts; return token() === 73 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227); + var node = createNode(230); parseExpected(98); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); - var caseBlock = createNode(241); + var caseBlock = createNode(244); parseExpected(17); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(18); @@ -15513,14 +15607,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(229); + var node = createNode(232); parseExpected(100); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(230); + var node = createNode(233); parseExpected(102); node.tryBlock = parseBlock(false); node.catchClause = token() === 74 ? parseCatchClause() : undefined; @@ -15531,7 +15625,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269); + var result = createNode(272); parseExpected(74); if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); @@ -15544,7 +15638,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231); + var node = createNode(234); parseExpected(78); parseSemicolon(); return finishNode(node); @@ -15553,12 +15647,12 @@ var ts; var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); if (expression.kind === 71 && parseOptional(56)) { - node.kind = 228; + node.kind = 231; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216; + node.kind = 219; node.expression = expression; parseSemicolon(); } @@ -15696,16 +15790,16 @@ var ts; case 17: return parseBlock(false); case 104: - return parseVariableStatement(createNodeWithJSDoc(232)); + return parseVariableStatement(createNodeWithJSDoc(235)); case 110: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232)); + return parseVariableStatement(createNodeWithJSDoc(235)); } break; case 89: - return parseFunctionDeclaration(createNodeWithJSDoc(234)); + return parseFunctionDeclaration(createNodeWithJSDoc(237)); case 75: - return parseClassDeclaration(createNodeWithJSDoc(235)); + return parseClassDeclaration(createNodeWithJSDoc(238)); case 90: return parseIfStatement(); case 81: @@ -15715,9 +15809,9 @@ var ts; case 88: return parseForOrForInOrForOfStatement(); case 77: - return parseBreakOrContinueStatement(223); + return parseBreakOrContinueStatement(226); case 72: - return parseBreakOrContinueStatement(224); + return parseBreakOrContinueStatement(227); case 96: return parseReturnStatement(); case 107: @@ -15811,7 +15905,7 @@ var ts; } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(253, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -15833,16 +15927,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 26) { - return createNode(206); + return createNode(208); } - var node = createNode(182); + var node = createNode(184); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182); + var node = createNode(184); node.dotDotDotToken = parseOptionalToken(24); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -15858,14 +15952,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180); + var node = createNode(182); parseExpected(17); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(18); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181); + var node = createNode(183); parseExpected(21); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(22); @@ -15887,7 +15981,7 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232); + var node = createNode(235); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 && token() === 51 && !scanner.hasPrecedingLineBreak()) { @@ -15900,7 +15994,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233); + var node = createNode(236); switch (token()) { case 104: break; @@ -15929,13 +16023,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20; } function parseVariableStatement(node) { - node.kind = 214; + node.kind = 217; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234; + node.kind = 237; parseExpected(89); node.asteriskToken = parseOptionalToken(39); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); @@ -16078,7 +16172,7 @@ var ts; } function parseClassElement() { if (token() === 25) { - var result = createNode(212); + var result = createNode(215); nextToken(); return finishNode(result); } @@ -16111,10 +16205,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 205); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 207); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235); + return parseClassDeclarationOrExpression(node, 238); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -16148,14 +16242,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 || tok === 108); - var node = createNode(268); + var node = createNode(271); node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207); + var node = createNode(209); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -16172,7 +16266,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236; + node.kind = 239; parseExpected(109); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -16181,7 +16275,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237; + node.kind = 240; parseExpected(139); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -16191,13 +16285,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(273); + var node = createNodeWithJSDoc(276); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238; + node.kind = 241; parseExpected(83); node.name = parseIdentifier(); if (parseExpected(17)) { @@ -16210,7 +16304,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240); + var node = createNode(243); if (parseExpected(17)) { node.statements = parseList(1, parseStatement); parseExpected(18); @@ -16221,7 +16315,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239; + node.kind = 242; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); @@ -16231,7 +16325,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239; + node.kind = 242; if (token() === 144) { node.name = parseIdentifier(); node.flags |= 512; @@ -16275,7 +16369,7 @@ var ts; return nextToken() === 41; } function parseNamespaceExportDeclaration(node) { - node.kind = 242; + node.kind = 245; parseExpected(118); parseExpected(130); node.name = parseIdentifier(); @@ -16292,7 +16386,7 @@ var ts; return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 244; + node.kind = 247; if (identifier || token() === 39 || token() === 17) { @@ -16304,7 +16398,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243; + node.kind = 246; node.name = identifier; parseExpected(58); node.moduleReference = parseModuleReference(); @@ -16312,13 +16406,13 @@ var ts; return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(245, fullStart); + var importClause = createNode(248, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(26)) { - importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(247); + importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(250); } return finishNode(importClause); } @@ -16328,7 +16422,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(254); + var node = createNode(257); parseExpected(133); parseExpected(19); node.expression = parseModuleSpecifier(); @@ -16346,7 +16440,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(246); + var namespaceImport = createNode(249); parseExpected(39); parseExpected(118); namespaceImport.name = parseIdentifier(); @@ -16354,14 +16448,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 247 ? parseImportSpecifier : parseExportSpecifier, 17, 18); + node.elements = parseBracketedList(22, kind === 250 ? parseImportSpecifier : parseExportSpecifier, 17, 18); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252); + return parseImportOrExportSpecifier(255); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248); + return parseImportOrExportSpecifier(251); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16380,19 +16474,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 && checkIdentifierIsKeyword) { + if (kind === 251 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250; + node.kind = 253; if (parseOptional(39)) { parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251); + node.exportClause = parseNamedImportsOrExports(254); if (token() === 143 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); @@ -16402,7 +16496,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249; + node.kind = 252; if (parseOptional(58)) { node.isExportEquals = true; } @@ -16420,10 +16514,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 243 && node.moduleReference.kind === 254 - || node.kind === 244 - || node.kind === 249 - || node.kind === 250 + || node.kind === 246 && node.moduleReference.kind === 257 + || node.kind === 247 + || node.kind === 252 + || node.kind === 253 ? node : undefined; } @@ -16452,7 +16546,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278, scanner.getTokenPos()); + var result = createNode(281, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -16500,15 +16594,14 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - if (!isJSDocLikeText(content, start)) { - return result; - } - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { var state = 1; var margin; var indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4; @@ -16581,9 +16674,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -16595,7 +16687,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286, start); + var result = createNode(289, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -16707,6 +16799,16 @@ var ts; indent += whitespace.length; } break; + case 17: + state = 2; + if (lookAhead(function () { return nextJSDocToken() === 57 && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39: if (state === 0) { state = 1; @@ -16725,7 +16827,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289, atToken.pos); + var result = createNode(292, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -16782,8 +16884,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(299, atToken.pos) : - createNode(293, atToken.pos); + createNode(302, atToken.pos) : + createNode(296, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -16803,18 +16905,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 293 || child.kind === 299) { + if (child.kind === 296 || child.kind === 302) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287, start_2); + jsdocTypeLiteral = createNode(290, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167) { jsdocTypeLiteral.isArrayType = true; @@ -16825,27 +16927,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294, atToken.pos); + var result = createNode(297, 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 === 296; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296, atToken.pos); + var result = createNode(299, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290, atToken.pos); + var result = createNode(293, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -16853,7 +16955,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17); - var node = createNode(207); + var node = createNode(209); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -16865,7 +16967,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23)) { - var prop = createNode(185, node.pos); + var prop = createNode(187, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -16873,13 +16975,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291, atToken.pos); + var tag = createNode(294, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295, atToken.pos); + var tag = createNode(298, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); @@ -16889,7 +16991,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298, atToken.pos); + var typedefTag = createNode(301, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -16905,9 +17007,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287, start_3); + jsdocTypeLiteral = createNode(290, start_3); } - if (child.kind === 296) { + if (child.kind === 299) { if (childTypeTag) { break; } @@ -16938,7 +17040,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23)) { - var jsDocNamespaceNode = createNode(239, pos); + var jsDocNamespaceNode = createNode(242, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -16952,7 +17054,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292, atToken.pos); + var callbackTag = createNode(295, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -16961,7 +17063,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288, start); + var jsdocSignature = createNode(291, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -16969,7 +17071,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57)) { var tag = parseTag(indent); - if (tag && tag.kind === 294) { + if (tag && tag.kind === 297) { return tag; } } @@ -17014,9 +17116,9 @@ var ts; case 57: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 && + if (child && (child.kind === 296 || child.kind === 302) && target !== 4 && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -17089,7 +17191,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297, atToken.pos); + var result = createNode(300, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -17678,6 +17780,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; ts.libs = libEntries.map(function (entry) { return entry[0]; }); ts.libMap = ts.createMapFromEntries(libEntries); @@ -18768,7 +18871,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 270) { + if (element.kind !== 273) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -18839,13 +18942,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198: + case 200: if (valueExpression.operator !== 38 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 184: + case 186: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -18855,7 +18958,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 183: + case 185: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -20557,21 +20660,21 @@ var ts; ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateWorker(node) { switch (node.kind) { - case 236: - case 237: + case 239: + case 240: return 0; - case 238: - if (ts.isConst(node)) { + case 241: + if (ts.isEnumConst(node)) { return 2; } break; - case 244: - case 243: + case 247: + case 246: if (!(ts.hasModifier(node, 1))) { return 0; } break; - case 240: { + case 243: { var state_1 = 0; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -20590,7 +20693,7 @@ var ts; }); return state_1; } - case 239: + case 242: return getModuleInstanceState(node); case 71: if (node.isInJSDocNamespace) { @@ -20707,7 +20810,7 @@ var ts; } } function getDeclarationName(node) { - if (node.kind === 249) { + if (node.kind === 252) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -20731,27 +20834,27 @@ var ts; return "__constructor"; case 163: case 158: - case 288: + case 291: return "__call"; case 164: case 159: return "__new"; case 160: return "__index"; - case 250: + case 253: return "__export"; - case 274: + case 277: return "export="; - case 200: + case 202: if (ts.getSpecialPropertyAssignmentKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284: + case 287: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); case 149: - ts.Debug.assert(node.parent.kind === 284, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 287, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -20801,7 +20904,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 249 && !node.isExportEquals)) { + (node.kind === 252 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20826,7 +20929,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 2097152) { - if (node.kind === 252 || (node.kind === 243 && hasExportModifier)) { + if (node.kind === 255 || (node.kind === 246 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20856,7 +20959,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 193) { + if (node.kind !== 195) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -20896,7 +20999,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 274) { + if (node.kind === 277) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -20945,8 +21048,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -20978,76 +21081,77 @@ var ts; return; } switch (node.kind) { - case 219: + case 222: bindWhileStatement(node); break; - case 218: + case 221: bindDoStatement(node); break; - case 220: + case 223: bindForStatement(node); break; - case 221: - case 222: + case 224: + case 225: bindForInOrForOfStatement(node); break; - case 217: + case 220: bindIfStatement(node); break; - case 225: - case 229: + case 228: + case 232: bindReturnOrThrow(node); break; - case 224: - case 223: + case 227: + case 226: bindBreakOrContinueStatement(node); break; - case 230: + case 233: bindTryStatement(node); break; - case 227: + case 230: bindSwitchStatement(node); break; - case 241: + case 244: bindCaseBlock(node); break; - case 266: + case 269: bindCaseClause(node); break; - case 228: + case 231: bindLabeledStatement(node); break; - case 198: + case 200: bindPrefixUnaryExpressionFlow(node); break; - case 199: + case 201: bindPostfixUnaryExpressionFlow(node); break; - case 200: + case 202: bindBinaryExpressionFlow(node); break; - case 194: + case 196: bindDeleteExpressionFlow(node); break; - case 201: + case 203: bindConditionalExpressionFlow(node); break; - case 232: + case 235: bindVariableDeclarationFlow(node); break; - case 187: + case 189: bindCallExpressionFlow(node); break; - case 298: - case 292: + case 301: + case 295: bindJSDocTypeAlias(node); break; - case 274: + case 277: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213: - case 240: + } + case 216: + case 243: bindEachFunctionsFirst(node.statements); break; default: @@ -21060,15 +21164,15 @@ var ts; switch (expr.kind) { case 71: case 99: - case 185: - return isNarrowableReference(expr); case 187: + return isNarrowableReference(expr); + case 189: return hasNarrowableArgument(expr); - case 191: + case 193: return isNarrowingExpression(expr.expression); - case 200: + case 202: return isNarrowingBinaryExpression(expr); - case 198: + case 200: return expr.operator === 51 && isNarrowingExpression(expr.operand); } return false; @@ -21077,7 +21181,7 @@ var ts; return expr.kind === 71 || expr.kind === 99 || expr.kind === 97 || - expr.kind === 185 && isNarrowableReference(expr.expression); + expr.kind === 187 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -21088,7 +21192,7 @@ var ts; } } } - if (expr.expression.kind === 185 && + if (expr.expression.kind === 187 && isNarrowableReference(expr.expression.expression)) { return true; } @@ -21121,9 +21225,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191: + case 193: return isNarrowableOperand(expr.expression); - case 200: + case 202: switch (expr.operatorToken.kind) { case 58: return isNarrowableOperand(expr.left); @@ -21200,33 +21304,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217: - case 219: - case 218: - return parent.expression === node; case 220: - case 201: + case 222: + case 221: + return parent.expression === node; + case 223: + case 203: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191) { + if (node.kind === 193) { node = node.expression; } - else if (node.kind === 198 && node.operator === 51) { + else if (node.kind === 200 && node.operator === 51) { node = node.operand; } else { - return node.kind === 200 && (node.operatorToken.kind === 53 || + return node.kind === 202 && (node.operatorToken.kind === 53 || node.operatorToken.kind === 54); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 || - node.parent.kind === 198 && + while (node.parent.kind === 193 || + node.parent.kind === 200 && node.parent.operator === 51) { node = node.parent; } @@ -21268,7 +21372,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 + var enclosingLabeledStatement = node.parent.kind === 231 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -21300,13 +21404,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222) { + if (node.kind === 225) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233) { + if (node.initializer.kind !== 236) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21328,7 +21432,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225) { + if (node.kind === 228) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21348,7 +21452,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21411,7 +21515,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -21477,13 +21581,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218) { + if (!node.statement || node.statement.kind !== 221) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 && node.operatorToken.kind === 58) { + if (node.kind === 202 && node.operatorToken.kind === 58) { bindAssignmentTargetFlow(node.left); } else { @@ -21494,10 +21598,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183) { + else if (node.kind === 185) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204) { + if (e.kind === 206) { bindAssignmentTargetFlow(e.expression); } else { @@ -21505,16 +21609,16 @@ var ts; } } } - else if (node.kind === 184) { + else if (node.kind === 186) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270) { + if (p.kind === 273) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271) { + else if (p.kind === 274) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272) { + else if (p.kind === 275) { bindAssignmentTargetFlow(p.expression); } } @@ -21570,7 +21674,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 && node.left.kind === 186) { + if (operator === 58 && node.left.kind === 188) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21581,7 +21685,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185) { + if (node.expression.kind === 187) { bindAssignmentTargetFlow(node.expression); } } @@ -21625,10 +21729,10 @@ var ts; } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 191) { + while (expr.kind === 193) { expr = expr.expression; } - if (expr.kind === 192 || expr.kind === 193) { + if (expr.kind === 194 || expr.kind === 195) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -21636,7 +21740,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185) { + if (node.expression.kind === 187) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21645,53 +21749,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205: - case 235: + case 207: case 238: - case 184: + case 241: + case 186: case 166: - case 287: - case 263: + case 290: + case 266: return 1; - case 236: - return 1 | 64; case 239: - case 237: - case 177: + return 1 | 64; + case 242: + case 240: + case 179: return 1 | 32; - case 274: + case 277: return 1 | 4 | 32; case 154: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } case 155: - case 234: + case 237: case 153: case 156: case 157: case 158: - case 288: - case 284: + case 291: + case 287: case 163: case 159: case 160: case 164: return 1 | 4 | 32 | 8; - case 192: - case 193: + case 194: + case 195: return 1 | 4 | 32 | 8 | 16; - case 240: + case 243: return 4; case 152: return node.initializer ? 4 : 0; - case 269: - case 220: - case 221: - case 222: - case 241: + case 272: + case 223: + case 224: + case 225: + case 244: return 2; - case 213: + case 216: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -21704,40 +21808,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 239: + case 242: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274: + case 277: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205: - case 235: - return declareClassMember(node, symbolFlags, symbolExcludes); + case 207: case 238: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 241: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166: - case 287: - case 184: - case 236: - case 263: + case 290: + case 186: + case 239: + case 266: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 163: case 164: case 158: case 159: - case 288: + case 291: case 160: case 154: case 153: case 155: case 156: case 157: - case 234: - case 192: - case 193: - case 284: - case 298: - case 292: case 237: - case 177: + case 194: + case 195: + case 287: + case 301: + case 295: + case 240: + case 179: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -21752,11 +21856,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 ? node : node.body; - if (body && (body.kind === 274 || body.kind === 240)) { + var body = node.kind === 277 ? node : node.body; + if (body && (body.kind === 277 || body.kind === 243)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 || stat.kind === 249) { + if (stat.kind === 253 || stat.kind === 252) { return true; } } @@ -21824,11 +21928,11 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 || prop.name.kind !== 71) { + if (prop.kind === 275 || prop.name.kind !== 71) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 270 || prop.kind === 271 || prop.kind === 154 + var currentKind = prop.kind === 273 || prop.kind === 274 || prop.kind === 154 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -21860,10 +21964,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239: + case 242: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274: + case 277: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21983,8 +22087,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 274 && - blockScopeContainer.kind !== 239 && + if (blockScopeContainer.kind !== 277 && + blockScopeContainer.kind !== 242 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -22048,7 +22152,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -22098,11 +22206,11 @@ var ts; break; } case 99: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185: + case 187: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -22110,7 +22218,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200: + case 202: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1: @@ -22137,19 +22245,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269: + case 272: return checkStrictModeCatchClause(node); - case 194: + case 196: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 199: + case 201: return checkStrictModePostfixUnaryExpression(node); - case 198: + case 200: return checkStrictModePrefixUnaryExpression(node); - case 226: + case 229: return checkStrictModeWithStatement(node); - case 174: + case 176: seenThisKeyword = true; return; case 161: @@ -22158,18 +22266,18 @@ var ts; return bindTypeParameter(node); case 149: return bindParameter(node); - case 232: + case 235: return bindVariableDeclarationOrBindingElement(node); - case 182: + case 184: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152: case 151: return bindPropertyWorker(node); - case 270: - case 271: - return bindPropertyOrMethodOrAccessor(node, 4, 0); case 273: + case 274: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 276: return bindPropertyOrMethodOrAccessor(node, 8, 68008959); case 158: case 159: @@ -22178,7 +22286,7 @@ var ts; case 154: case 153: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67208127); - case 234: + case 237: return bindFunctionDeclaration(node); case 155: return declareSymbolAndAddToSymbolTable(node, 16384, 0); @@ -22187,77 +22295,77 @@ var ts; case 157: return bindPropertyOrMethodOrAccessor(node, 65536, 67183551); case 163: - case 284: - case 288: + case 287: + case 291: case 164: return bindFunctionOrConstructorType(node); case 166: - case 287: - case 177: + case 290: + case 179: return bindAnonymousTypeWorker(node); - case 184: + case 186: return bindObjectLiteralExpression(node); - case 192: - case 193: + case 194: + case 195: return bindFunctionExpression(node); - case 187: + case 189: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 205: - case 235: + case 207: + case 238: inStrictMode = true; return bindClassLikeDeclaration(node); - case 236: + case 239: return bindBlockScopedDeclaration(node, 64, 67901832); - case 237: + case 240: return bindBlockScopedDeclaration(node, 524288, 67901928); - case 238: + case 241: return bindEnumDeclaration(node); - case 239: + case 242: return bindModuleDeclaration(node); - case 263: + case 266: return bindJsxAttributes(node); - case 262: + case 265: return bindJsxAttribute(node, 4, 0); - case 243: case 246: - case 248: - case 252: + case 249: + case 251: + case 255: return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); - case 242: - return bindNamespaceExportDeclaration(node); case 245: + return bindNamespaceExportDeclaration(node); + case 248: return bindImportClause(node); - case 250: + case 253: return bindExportDeclaration(node); - case 249: + case 252: return bindExportAssignment(node); - case 274: + case 277: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213: + case 216: if (!ts.isFunctionLike(node.parent)) { return; } - case 240: + case 243: return updateStrictModeStatementList(node.statements); - case 293: - if (node.parent.kind === 288) { + case 296: + if (node.parent.kind === 291) { return bindParameter(node); } - if (node.parent.kind !== 287) { + if (node.parent.kind !== 290) { break; } - case 299: + case 302: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 298: - case 292: + case 301: + case 295: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -22287,7 +22395,7 @@ var ts; bindAnonymousDeclaration(node, 2097152, getDeclarationName(node)); } else { - var flags = node.kind === 249 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 && ts.exportAssignmentIsAlias(node) ? 2097152 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863); @@ -22297,7 +22405,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274) { + if (node.parent.kind !== 277) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -22373,8 +22481,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 234: - case 192: + case 237: + case 194: var constructorSymbol = thisContainer.symbol; if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58) { var l = thisContainer.parent.left; @@ -22396,7 +22504,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); break; - case 274: + case 277: break; default: ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer)); @@ -22406,7 +22514,7 @@ var ts; if (node.expression.kind === 99) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -22447,9 +22555,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274; + : propertyAccess.parent.parent.kind === 277; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920)) && isToplevelNamespaceableInitializer) { var flags_1 = 1536 | 67108864; var excludeFlags_1 = 67215503 & ~67108864; @@ -22528,7 +22636,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235) { + if (node.kind === 238) { bindBlockScopedDeclaration(node, 32, 68008383); } else { @@ -22551,7 +22659,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128, 68008831) : bindBlockScopedDeclaration(node, 256, 68008191); } @@ -22572,7 +22680,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 && container.kind !== 288) { + if (node.kind === 296 && container.kind !== 291) { return; } if (inStrictMode && !(node.flags & 4194304)) { @@ -22645,7 +22753,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144, 67639784); } } - else if (node.parent.kind === 172) { + else if (node.parent.kind === 174) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -22670,10 +22778,10 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 215) || - node.kind === 235 || - (node.kind === 239 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 238 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 218) || + node.kind === 238 || + (node.kind === 242 && shouldReportErrorOnModuleDeclaration(node)) || + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -22714,43 +22822,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187: + case 189: return computeCallExpression(node, subtreeFlags); - case 188: + case 190: return computeNewExpression(node, subtreeFlags); - case 239: + case 242: return computeModuleDeclaration(node, subtreeFlags); - case 191: + case 193: return computeParenthesizedExpression(node, subtreeFlags); - case 200: + case 202: return computeBinaryExpression(node, subtreeFlags); - case 216: + case 219: return computeExpressionStatement(node, subtreeFlags); case 149: return computeParameter(node, subtreeFlags); - case 193: + case 195: return computeArrowFunction(node, subtreeFlags); - case 192: + case 194: return computeFunctionExpression(node, subtreeFlags); - case 234: + case 237: return computeFunctionDeclaration(node, subtreeFlags); - case 232: + case 235: return computeVariableDeclaration(node, subtreeFlags); - case 233: + case 236: return computeVariableDeclarationList(node, subtreeFlags); - case 214: + case 217: return computeVariableStatement(node, subtreeFlags); - case 228: + case 231: return computeLabeledStatement(node, subtreeFlags); - case 235: + case 238: return computeClassDeclaration(node, subtreeFlags); - case 205: + case 207: return computeClassExpression(node, subtreeFlags); - case 268: + case 271: return computeHeritageClause(node, subtreeFlags); - case 269: + case 272: return computeCatchClause(node, subtreeFlags); - case 207: + case 209: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155: return computeConstructor(node, subtreeFlags); @@ -22761,11 +22869,11 @@ var ts; case 156: case 157: return computeAccessor(node, subtreeFlags); - case 243: + case 246: return computeImportEquals(node, subtreeFlags); - case 185: + case 187: return computePropertyAccess(node, subtreeFlags); - case 186: + case 188: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -22809,10 +22917,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 && leftKind === 184) { + if (operatorTokenKind === 58 && leftKind === 186) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 58 && leftKind === 183) { + else if (operatorTokenKind === 58 && leftKind === 185) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 40 @@ -22850,8 +22958,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 208 - || expressionKind === 190) { + if (expressionKind === 210 + || expressionKind === 192) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -23150,12 +23258,12 @@ var ts; var excludeFlags = 939525441; switch (kind) { case 120: - case 197: + case 199: transformFlags |= 8 | 16; break; - case 190: - case 208: - case 302: + case 192: + case 210: + case 305: transformFlags |= 3; excludeFlags = 536872257; break; @@ -23165,35 +23273,35 @@ var ts; case 117: case 124: case 76: - case 238: - case 273: - case 209: + case 241: + case 276: + case 211: case 132: transformFlags |= 3; break; - case 255: - case 256: - case 257: - case 10: case 258: case 259: case 260: + case 10: case 261: case 262: case 263: case 264: case 265: + case 266: + case 267: + case 268: transformFlags |= 4; break; case 13: case 14: case 15: case 16: - case 202: - case 189: - case 271: + case 204: + case 191: + case 274: case 115: - case 210: + case 212: transformFlags |= 192; break; case 9: @@ -23206,13 +23314,13 @@ var ts; transformFlags |= 192; } break; - case 222: + case 225: if (node.awaitModifier) { transformFlags |= 8; } transformFlags |= 192; break; - case 203: + case 205: transformFlags |= 8 | 192 | 16777216; break; case 119: @@ -23242,14 +23350,16 @@ var ts; case 171: case 172: case 173: - case 236: - case 237: case 174: case 175: + case 239: + case 240: case 176: case 177: case 178: - case 242: + case 179: + case 180: + case 245: transformFlags = 3; excludeFlags = -3; break; @@ -23259,10 +23369,10 @@ var ts; transformFlags |= 65536; } break; - case 204: + case 206: transformFlags |= 192 | 524288; break; - case 272: + case 275: transformFlags |= 8 | 1048576; break; case 97: @@ -23272,18 +23382,18 @@ var ts; case 99: transformFlags |= 16384; break; - case 180: + case 182: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 940049729; break; - case 181: + case 183: transformFlags |= 192 | 8388608; excludeFlags = 940049729; break; - case 182: + case 184: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; @@ -23292,7 +23402,7 @@ var ts; case 150: transformFlags |= 3 | 4096; break; - case 184: + case 186: excludeFlags = 942740801; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -23304,31 +23414,31 @@ var ts; transformFlags |= 8; } break; - case 183: - case 188: + case 185: + case 190: excludeFlags = 940049729; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 218: - case 219: - case 220: case 221: + case 222: + case 223: + case 224: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 274: + case 277: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 225: + case 228: transformFlags |= 33554432 | 8; break; - case 223: - case 224: + case 226: + case 227: transformFlags |= 33554432; break; } @@ -23336,27 +23446,27 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 && kind <= 179) { + if (kind >= 161 && kind <= 181) { return -3; } switch (kind) { - case 187: - case 188: - case 183: + case 189: + case 190: + case 185: return 940049729; - case 239: + case 242: return 977327425; case 149: return 939525441; - case 193: + case 195: return 1003902273; - case 192: - case 234: + case 194: + case 237: return 1003935041; - case 233: + case 236: return 948962625; - case 235: - case 205: + case 238: + case 207: return 942011713; case 155: return 1003668801; @@ -23378,24 +23488,24 @@ var ts; case 158: case 159: case 160: - case 236: - case 237: + case 239: + case 240: return -3; - case 184: + case 186: return 942740801; - case 269: + case 272: return 940574017; - case 180: - case 181: + case 182: + case 183: return 940049729; - case 190: - case 208: - case 302: - case 191: + case 192: + case 210: + case 305: + case 193: case 97: return 536872257; - case 185: - case 186: + case 187: + case 188: return 671089985; default: return 939525441; @@ -23653,6 +23763,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -23726,7 +23837,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -23822,6 +23932,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -23876,7 +23987,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -23931,6 +24042,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; var patternAmbientModules; @@ -24028,140 +24140,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); - }, - buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0; } - symbolToString(symbol, enclosingDeclaration, meaning, flags | 4, emitTextWriterWrapper(writer)); - }, - buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildParameterDisplay: function (symbol, writer, enclosing, flags) { - var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { - var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 | 8192, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { - var printer = ts.createPrinter({ removeComments: true }); - var flags = 8192 | 3112960 | toNodeBuilderFlags(originalFlags); - var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; - var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); - printer.writeList(1296, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForTypeParametersAndDelimiters: function (typeParameters, writer, enclosing, flags) { - var printer = ts.createPrinter({ removeComments: true }); - var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); - printer.writeList(26896, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -24197,6 +24175,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -24315,22 +24318,56 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), 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 & 384 || source.flags & 384 + var isEitherEnum = !!(target.flags & 384 || source.flags & 384); + var isEitherBlockScoped = !!(target.flags & 2 || source.flags & 2); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 || source.flags & 2 + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -24397,7 +24434,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -24443,15 +24480,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 182) { - var errorBindingElement = ts.getAncestor(usage, 182); + if (declaration.kind === 184) { + var errorBindingElement = ts.getAncestor(usage, 184); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 232), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235), usage); } - else if (declaration.kind === 232) { + else if (declaration.kind === 235) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -24459,10 +24496,10 @@ var ts; } return true; } - if (usage.parent.kind === 252 || (usage.parent.kind === 249 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 || (usage.parent.kind === 252 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 249 && usage.isExportEquals) { + if (usage.kind === 252 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -24470,9 +24507,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214: - case 220: - case 222: + case 217: + case 223: + case 225: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } @@ -24527,7 +24564,7 @@ var ts; if (result = lookup(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 67901928 && lastLocation.kind !== 286) { + if (meaning & result.flags & 67901928 && lastLocation.kind !== 289) { useResult = result.flags & 262144 ? lastLocation === location.type || lastLocation.kind === 149 || @@ -24541,7 +24578,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171) { + else if (location.kind === 173) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -24553,13 +24590,13 @@ var ts; } } switch (location.kind) { - case 274: + case 277: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 239: + case 242: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 || ts.isAmbientModule(location)) { + if (location.kind === 277 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -24570,7 +24607,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - ts.getDeclarationOfKind(moduleExport, 252)) { + ts.getDeclarationOfKind(moduleExport, 255)) { break; } } @@ -24583,7 +24620,7 @@ var ts; } } break; - case 238: + case 241: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } @@ -24599,9 +24636,9 @@ var ts; } } break; - case 235: - case 205: - case 236: + case 238: + case 207: + case 239: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -24613,7 +24650,7 @@ var ts; } break loop; } - if (location.kind === 205 && meaning & 32) { + if (location.kind === 207 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -24621,7 +24658,7 @@ var ts; } } break; - case 207: + case 209: if (lastLocation === location.expression && location.parent.token === 85) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67901928))) { @@ -24634,7 +24671,7 @@ var ts; break; case 147: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239) { if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; @@ -24646,14 +24683,14 @@ var ts; case 155: case 156: case 157: - case 234: - case 193: + case 237: + case 195: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192: + case 194: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -24674,8 +24711,8 @@ var ts; location = location.parent; } break; - case 298: - case 292: + case 301: + case 295: location = ts.getJSDocHost(location); break; } @@ -24690,7 +24727,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274); + ts.Debug.assert(lastLocation.kind === 277); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -24749,7 +24786,7 @@ var ts; } if (result && isInExternalModule && (meaning & 67216319) === 67216319 && !(originalLocation.flags & 2097152)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 242) { + if (decls && decls.length === 1 && decls[0].kind === 245) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } @@ -24758,12 +24795,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234: - case 235: - case 236: - case 238: case 237: + case 238: case 239: + case 241: + case 240: + case 242: return true; default: return false; @@ -24824,9 +24861,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71: - case 185: + case 187: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207: + case 209: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -24888,18 +24925,26 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -24908,13 +24953,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243: + case 246: return node; - case 245: + case 248: return node.parent; - case 246: + case 249: return node.parent.parent; - case 248: + case 251: return node.parent.parent.parent; default: return undefined; @@ -24924,7 +24969,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254) { + if (node.moduleReference.kind === 257) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -25079,20 +25124,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243: + case 246: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245: + case 248: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246: + case 249: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248: + case 251: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252: + case 255: return getTargetOfExportSpecifier(node, 67216319 | 67901928 | 1920, dontRecursivelyResolve); - case 249: - case 200: + case 252: + case 202: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242: + case 245: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -25146,10 +25191,10 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249) { + if (node.kind === 252) { checkExpressionCached(node.expression); } - else if (node.kind === 252) { + else if (node.kind === 255) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -25165,7 +25210,7 @@ var ts; return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 243); + ts.Debug.assert(entityName.parent.kind === 246); return resolveEntityName(entityName, 67216319 | 67901928 | 1920, false, dontResolveAlias); } } @@ -25186,7 +25231,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 || name.kind === 185) { + else if (name.kind === 146 || name.kind === 187) { var left = name.kind === 146 ? name.left : name.expression; var right = name.kind === 146 ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location); @@ -25340,9 +25385,18 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages(undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)) + : undefined; errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -25365,7 +25419,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 | 3))) { + if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 277)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -25583,6 +25637,12 @@ var ts; var type = createType(131072); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -25597,25 +25657,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -25630,11 +25684,11 @@ var ts; } } switch (location.kind) { - case 274: + case 277: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 239: + case 242: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -25712,7 +25766,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -25797,10 +25851,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25845,8 +25899,8 @@ var ts; entityName.parent.kind === 147) { meaning = 67216319 | 1048576; } - else if (entityName.kind === 146 || entityName.kind === 185 || - entityName.parent.kind === 243) { + else if (entityName.kind === 146 || entityName.kind === 187 || + entityName.parent.kind === 246) { meaning = 1920; } else { @@ -25924,64 +25978,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -25989,6 +26012,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -26105,7 +26130,7 @@ var ts; var types = type.flags & 262144 ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 ? 169 : 170, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 ? 171 : 172, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -26169,7 +26194,7 @@ var ts; var isInstanceType = type === getInferredClassType(symbol) ? 67901928 : 67216319; return symbolToTypeNode(symbol, context, isInstanceType); } - else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 && context.flags & 2048) || + else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319); @@ -26202,7 +26227,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 || declaration.parent.kind === 240; + return declaration.parent.kind === 277 || declaration.parent.kind === 243; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || (context.visitedSymbols && context.visitedSymbols.has(id))) && @@ -26249,8 +26274,15 @@ var ts; } else if (type.target.objectFlags & 8) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -26447,7 +26479,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -26501,7 +26533,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -26509,7 +26541,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; - var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192; var dotDotDotToken = isRest ? ts.createToken(24) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -26518,7 +26550,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096; + var questionToken = isOptional ? ts.createToken(55) : undefined; var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined); return parameterNode; function cloneBindingName(node) { @@ -26526,7 +26559,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 182) { + if (clone.kind === 184) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 | 16777216); @@ -26600,16 +26633,45 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277); + if (file && file.moduleName !== undefined) { + return file.moduleName; + } + if (!file) { + if (context.tracker.trackReferencedAmbientModule) { + var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); + if (ts.length(ambientDecls)) { + for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { + var decl = ambientDecls_1[_i]; + context.tracker.trackReferencedAmbientModule(decl, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384)); - context.flags |= 16777216; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216; var isTypeOf = meaning === 67216319; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -26782,8 +26844,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173; }); - if (node.kind === 237) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175; }); + if (node.kind === 240) { return getSymbolOfNode(node); } } @@ -26791,11 +26853,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 && + node.parent.kind === 243 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 || ts.isAmbientModule(location); + return location.kind === 277 || ts.isAmbientModule(location); } function getNameOfSymbolAsWritten(symbol, context) { if (context && symbol.escapedName === "default" && !(context.flags & 16384) && @@ -26805,41 +26867,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { - var file = ts.getDeclarationOfKind(symbol, 274); - if (!file || !context.tracker.moduleResolverHost) { - if (context.tracker.trackReferencedAmbientModule) { - var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); - if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; - context.tracker.trackReferencedAmbientModule(decl); - } - } - } - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232) { + if (declaration.parent && declaration.parent.kind === 235) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205: - return "(Anonymous class)"; - case 192: - case 193: - return "(Anonymous function)"; + case 207: + case 194: + case 195: + if (context && !context.encounteredError && !(context.flags & 131072)) { + context.encounteredError = true; + } + return declaration.kind === 207 ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -26864,29 +26907,29 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292: - case 298: + case 295: + case 301: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 182: + case 184: return isDeclarationVisible(node.parent.parent); - case 232: + case 235: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } + case 242: + case 238: case 239: - case 235: - case 236: + case 240: case 237: - case 234: - case 238: - case 243: + case 241: + case 246: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 243 && parent.kind !== 274 && parent.flags & 4194304)) { + !(node.kind !== 246 && parent.kind !== 277 && parent.flags & 4194304)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); @@ -26904,26 +26947,26 @@ var ts; case 158: case 160: case 149: - case 240: + case 243: case 163: case 164: case 166: case 162: case 167: case 168: - case 169: - case 170: - case 173: + case 171: + case 172: + case 175: return isDeclarationVisible(node.parent); - case 245: - case 246: case 248: + case 249: + case 251: return false; case 148: - case 274: - case 242: + case 277: + case 245: return true; - case 249: + case 252: return false; default: return false; @@ -26932,10 +26975,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249) { + if (node.parent && node.parent.kind === 252) { exportSymbol = resolveName(node, node.escapedText, 67216319 | 67901928 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 252) { + else if (node.parent.kind === 255) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 | 67901928 | 1920 | 2097152); } var result; @@ -27016,12 +27059,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232: - case 233: + case 235: + case 236: + case 251: + case 250: + case 249: case 248: - case 247: - case 246: - case 245: return false; default: return true; @@ -27086,7 +27129,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180) { + if (pattern.kind === 182) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -27149,20 +27192,23 @@ var ts; } else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false, false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - type = createArrayType(elementType); + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -27171,7 +27217,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192)) { type = getTypeWithFacts(type, 131072); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2) : type; } @@ -27188,18 +27234,18 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 && expr.elements.length === 0; + return expr.kind === 185 && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 | 1048576) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } @@ -27213,7 +27259,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 4194304)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -27271,18 +27317,18 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 ? declaration : - declaration.kind === 185 ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : ts.getSpecialPropertyAssignmentKind(expression); if (special === 4) { var thisContainer = ts.getThisContainer(expression, false); declarationInConstructor = thisContainer.kind === 155 || - thisContainer.kind === 234 || - (thisContainer.kind === 192 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 || + (thisContainer.kind === 194 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -27302,7 +27348,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 && special === 2 && @@ -27378,7 +27424,7 @@ var ts; } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -27420,11 +27466,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -27434,7 +27482,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 + return pattern.kind === 182 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -27487,7 +27535,7 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 249) { + if (declaration.kind === 252) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol, 0)) { @@ -27678,8 +27726,8 @@ var ts; if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 || - symbol.valueDeclaration.kind === 185 && symbol.valueDeclaration.parent.kind === 200) { + else if (symbol.valueDeclaration.kind === 202 || + symbol.valueDeclaration.kind === 187 && symbol.valueDeclaration.parent.kind === 202) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -27804,51 +27852,51 @@ var ts; return undefined; } switch (node.kind) { - case 235: - case 205: - case 236: + case 238: + case 207: + case 239: case 158: case 159: case 153: case 163: case 164: - case 284: - case 234: - case 154: - case 192: - case 193: + case 287: case 237: - case 297: - case 298: - case 292: - case 177: - case 171: + case 154: + case 194: + case 195: + case 240: + case 300: + case 301: + case 295: + case 179: + case 173: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177) { + if (node.kind === 179) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171) { + else if (node.kind === 173) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 || node.kind === 205 || node.kind === 236) && + (node.kind === 238 || node.kind === 207 || node.kind === 239) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 236); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239); return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 || - node.kind === 235 || - node.kind === 205 || + if (node.kind === 239 || + node.kind === 238 || + node.kind === 207 || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -27878,14 +27926,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -27900,7 +27941,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -27931,7 +27972,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 | 64)) { if (type.symbol.flags & 32) { @@ -28005,7 +28046,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -28034,7 +28075,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236) { + if (declaration.kind === 239) { if (declaration.flags & 64) { return false; } @@ -28085,7 +28126,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237; + return ts.isJSDocTypeAlias(d) || d.kind === 240; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -28109,7 +28150,7 @@ var ts; if (expr.kind === 9) { return true; } - else if (expr.kind === 200) { + else if (expr.kind === 202) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -28123,12 +28164,12 @@ var ts; case 9: case 8: return true; - case 198: + case 200: return expr.operator === 38 && expr.operand.kind === 8; case 71: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 200: + case 202: return isStringConcatExpression(expr); default: return false; @@ -28142,7 +28183,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238) { + if (declaration.kind === 241) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9) { @@ -28169,7 +28210,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238) { + if (declaration.kind === 241) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); @@ -28254,7 +28295,7 @@ var ts; case 140: case 95: case 131: - case 178: + case 180: return true; case 167: return isThislessType(node.elementType); @@ -28533,6 +28574,28 @@ var ts; function cloneSignature(sig) { return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 : + i >= minLength_1 ? 4096 : 0; + var symbol = createSymbol(1, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1); @@ -28688,6 +28751,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper); @@ -28696,6 +28760,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call")); var constructSignatures = getSignaturesOfSymbol(members.get("__new")); @@ -28832,7 +28897,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 175 && + return constraintDeclaration.kind === 177 && constraintDeclaration.operator === 128; } function getModifiersTypeFromMappedType(type) { @@ -28940,6 +29005,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144)) { @@ -29329,10 +29405,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJavaScriptFile(node) && (node.type && node.type.kind === 283 + return ts.isInJavaScriptFile(node) && (node.type && node.type.kind === 286 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -29350,7 +29426,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -29365,7 +29441,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -29448,7 +29524,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178) { + if (type && type.kind === 180) { hasLiteralTypes = true; } var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -29488,9 +29564,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3, "args"); + var syntheticArgsSymbol = createSymbol(3, "args", 8192); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { parameters.pop(); } @@ -29590,9 +29665,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -29635,16 +29710,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -29735,22 +29807,28 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 172 && declaration.parent.parent.kind === 162) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174) { + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + else if (grandParent.kind === 149 && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -29838,7 +29916,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 290; + var missingAugmentsTag = isJs && node.parent.kind !== 293; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -29888,7 +29966,7 @@ var ts; switch (node.kind) { case 162: return node.typeName; - case 207: + case 209: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -29970,9 +30048,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286) { + while (node && !ts.isStatement(node) && node.kind !== 289) { var parent = node.parent; - if (parent.kind === 171 && node === parent.trueType) { + if (parent.kind === 173 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -30078,9 +30156,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235: - case 236: case 238: + case 239: + case 241: return declaration; } } @@ -30190,18 +30268,26 @@ var ts; } return links.resolvedType; } - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536); - typeParameters.push(typeParameter); - var property = createSymbol(4, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536); + if (i < maxLength) { + var property = createSymbol(4 | (i >= minLength ? 16777216 : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 | 4); type.typeParameters = typeParameters; @@ -30219,21 +30305,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -30577,7 +30689,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -30642,7 +30754,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -30662,6 +30774,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576) && isTypeAssignableToKind(indexType, 68 | 168 | 3072)) { if (isTypeAny(objectType)) { @@ -30672,7 +30790,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) { - var indexNode = accessNode.kind === 186 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -30689,14 +30807,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (64 | 128)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } @@ -30779,7 +30905,7 @@ var ts; if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188) && isGenericObjectType(objectType)) { if (objectType.flags & 3) { return objectType; } @@ -30896,7 +31022,7 @@ var ts; return true; } while (node) { - if (node.kind === 171) { + if (node.kind === 173) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -30993,7 +31119,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } else { - error(node, targetMeaning === 67216319 ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + var errorMessage = targetMeaning === 67216319 + ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here + : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -31187,7 +31316,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239)) { if (!ts.hasModifier(container, 32) && (container.kind !== 155 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -31206,8 +31335,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119: - case 279: - case 280: + case 282: + case 283: return anyType; case 142: return unknownType; @@ -31229,16 +31358,16 @@ var ts; return neverType; case 135: return node.flags & 65536 ? anyType : nonPrimitiveType; - case 174: + case 176: case 99: return getTypeFromThisTypeNode(node); - case 178: + case 180: return getTypeFromLiteralTypeNode(node); case 162: return getTypeFromTypeReference(node); case 161: return booleanType; - case 207: + case 209: return getTypeFromTypeReference(node); case 165: return getTypeFromTypeQueryNode(node); @@ -31247,37 +31376,40 @@ var ts; case 168: return getTypeFromTupleTypeNode(node); case 169: + return getTypeFromOptionalTypeNode(node); + case 171: return getTypeFromUnionTypeNode(node); - case 170: + case 172: return getTypeFromIntersectionTypeNode(node); - case 281: + case 284: return getTypeFromJSDocNullableTypeNode(node); - case 283: + case 286: return addOptionality(getTypeFromTypeNode(node.type)); - case 173: - case 282: - case 278: - return getTypeFromTypeNode(node.type); + case 175: + case 170: case 285: + case 281: + return getTypeFromTypeNode(node.type); + case 288: return getTypeFromJSDocVariadicType(node); case 163: case 164: case 166: + case 290: case 287: - case 284: - case 288: + case 291: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175: + case 177: return getTypeFromTypeOperatorNode(node); - case 176: + case 178: return getTypeFromIndexedAccessTypeNode(node); - case 177: + case 179: return getTypeFromMappedTypeNode(node); - case 171: + case 173: return getTypeFromConditionalTypeNode(node); - case 172: + case 174: return getTypeFromInferTypeNode(node); - case 179: + case 181: return getTypeFromImportTypeNode(node); case 71: case 146: @@ -31405,7 +31537,7 @@ var ts; symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(symbol.flags, symbol.escapedName, 1 | (ts.getCheckFlags(symbol) & 1024)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 | ts.getCheckFlags(symbol) & (1024 | 4096 | 8192)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -31416,11 +31548,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -31475,14 +31602,14 @@ var ts; function isTypeParameterPossiblyReferenced(tp, node) { if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 213 ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174: + case 176: return !!tp.isThisType; case 71: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -31604,31 +31731,31 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192: - case 193: + case 194: + case 195: case 154: return isContextSensitiveFunctionLikeDeclaration(node); - case 184: + case 186: return ts.some(node.properties, isContextSensitive); - case 183: + case 185: return ts.some(node.elements, isContextSensitive); - case 201: + case 203: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200: + case 202: return node.operatorToken.kind === 54 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270: + case 273: return isContextSensitive(node.initializer); - case 191: + case 193: return isContextSensitive(node.expression); - case 263: + case 266: return ts.some(node.properties, isContextSensitive); - case 262: { + case 265: { var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265: { + case 268: { var expression = node.expression; return !!expression && isContextSensitive(expression); } @@ -31642,14 +31769,14 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193) { + if (node.kind !== 195) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; } } var body = node.body; - return body.kind === 213 ? false : isContextSensitive(body); + return body.kind === 216 ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -31700,8 +31827,192 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268: + case 193: + return elaborateError(node.expression, source, target); + case 202: + switch (node.operatorToken.kind) { + case 58: + case 26: + return elaborateError(node.right, source, target); + } + break; + case 186: + return elaborateObjectLiteral(node, source, target); + case 185: + return elaborateArrayLiteral(node, source, target); + case 266: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + function elaborateElementwise(iterator, source, target) { + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + var resultObj = {}; + var specificSource = next ? checkExpressionForMutableLocation(next, 0, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, undefined, resultObj); + if (result && specificSource !== sourcePropType) { + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168) && getIndexInfoOfType(target, 1) || + getIndexInfoOfType(target, 0) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3, 3]; + return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3, 1]; + case 4: return [2]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3, 4]; + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3, 3]; + nameType = getLiteralType(i); + return [4, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3, 1]; + case 4: return [2]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240); + if (!type || (type.flags & 32768)) { + return [3, 7]; + } + _b = prop.kind; + switch (_b) { + case 157: return [3, 2]; + case 156: return [3, 2]; + case 154: return [3, 2]; + case 274: return [3, 2]; + case 273: return [3, 4]; + } + return [3, 6]; + case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3, 7]; + case 4: return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3, 1]; + case 8: return [2]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } function checkTypeComparableTo(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); @@ -31713,13 +32024,20 @@ var ts; if (source === target) { return -1; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0; + } var kind = target.declaration ? target.declaration.kind : 0; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 && kind !== 153 && kind !== 155; @@ -31739,14 +32057,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && @@ -31756,7 +32071,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0; } @@ -31826,27 +32141,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -31867,11 +32161,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 && errorReporter)) { + return relation === 1; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) { - enumRelation.set(id, false); + enumRelation.set(id, 3); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -31882,13 +32176,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64)); + enumRelation.set(id, 3); + } + else { + enumRelation.set(id, 2); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -31966,7 +32263,7 @@ var ts; function isIgnoredJsxProperty(source, sourceProp, targetMemberType) { return ts.getObjectFlags(source) & 4096 && !(isUnhyphenatedJsxName(sourceProp.escapedName) || targetMemberType); } - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -31994,12 +32291,16 @@ var ts; if (links.originatingImport && !ts.isImportCall(links.originatingImport)) { var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, undefined); if (helpfulRetry) { - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); } return result !== 0; function reportError(message, arg0, arg1, arg2) { @@ -32073,6 +32374,13 @@ var ts; if (target.flags & 2097152) { target = getSimplifiedType(target); } + if (target.flags & 262144 && source.flags & 131072 && + target.types.length <= 3 && maybeTypeOfKind(target, 24576)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576); + if (!(nullStrippedTarget.flags & (262144 | 32768))) { + target = nullStrippedTarget; + } + } if (source === target) return -1; if (relation === identityRelation) { @@ -32286,11 +32594,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], true); } return 0; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 262144) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4) { + return source.target === target.target; + } + if (overlapObjFlags & 16) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } function findMatchingDiscriminantType(source, target) { var match; var sourceProperties = getPropertiesOfObjectType(source); @@ -32405,7 +32731,6 @@ var ts; var related = relation.get(id); if (related !== undefined) { if (reportErrors && related === 2) { - relation.set(id, 3); } else { return related === 1 ? -1 : 0; @@ -32646,7 +32971,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -32669,6 +32994,33 @@ var ts; } } var result = -1; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -33110,15 +33462,21 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -33149,10 +33507,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0; @@ -33171,9 +33529,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -33217,7 +33572,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 | 32768)); @@ -33260,6 +33620,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -33498,7 +33864,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200: + case 202: case 152: case 151: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -33508,23 +33874,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182: + case 184: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234: + case 237: case 154: case 153: case 156: case 157: - case 192: - case 193: + case 194: + case 195: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 177: + case 179: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -33540,24 +33906,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -33684,8 +34048,12 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, false) && !!getUnmatchedProperty(target, source, false); } function getTypeFromInference(inference) { @@ -33926,12 +34294,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -34034,14 +34423,12 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { inferredType = getCovariantInference(inference, context, signature); - if (inferredType.flags & 32768 && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - inferredType = getContravariantInference(inference); } else if (context.flags & 2) { inferredType = silentNeverType; @@ -34099,13 +34486,13 @@ var ts; if (node.kind === 99) { return "0"; } - if (node.kind === 185) { + if (node.kind === 187) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182) { + if (node.kind === 184) { var container = node.parent.parent; - var key = container.kind === 182 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -34114,7 +34501,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180) { + if (parent.kind === 182) { var name = element.propertyName || element.name; switch (name.kind) { case 71: @@ -34136,26 +34523,26 @@ var ts; switch (source.kind) { case 71: return target.kind === 71 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 || target.kind === 182) && + (target.kind === 235 || target.kind === 184) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99: return target.kind === 99; case 97: return target.kind === 97; - case 185: - return target.kind === 185 && + case 187: + return target.kind === 187 && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182: - if (target.kind !== 185) + case 184: + if (target.kind !== 187) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232) { + if (source.parent.parent.kind === 235) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -34163,7 +34550,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185) { + while (source.kind === 187) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -34172,7 +34559,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 185 && + return target.kind === 187 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -34180,7 +34567,7 @@ var ts; if (expr.kind === 71) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185) { + if (expr.kind === 187) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -34224,7 +34611,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 && + if (callExpression.expression.kind === 187 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -34345,7 +34732,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, undefined, false, false) || errorType; } @@ -34353,15 +34740,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 && parent.parent.left === parent || - parent.parent.kind === 222 && parent.parent.initializer === parent; + return parent.parent.kind === 202 && parent.parent.left === parent || + parent.parent.kind === 225 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -34378,21 +34765,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221: + case 224: return stringType; - case 222: + case 225: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200: + case 202: return getAssignedTypeOfBinaryExpression(parent); - case 194: + case 196: return undefinedType; - case 183: + case 185: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204: + case 206: return getAssignedTypeOfSpreadExpression(parent); - case 270: + case 273: return getAssignedTypeOfPropertyAssignment(parent); - case 271: + case 274: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -34400,7 +34787,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 ? + var type = pattern.kind === 182 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -34415,35 +34802,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221) { + if (node.parent.parent.kind === 224) { return stringType; } - if (node.parent.parent.kind === 222) { + if (node.parent.parent.kind === 225) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 ? + return node.kind === 235 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 || node.kind === 182 ? + return node.kind === 235 || node.kind === 184 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 && node.initializer && + return node.kind === 235 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 && node.parent.kind === 200 && + node.kind !== 184 && node.parent.kind === 202 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191: + case 193: return getReferenceCandidate(node.expression); - case 200: + case 202: switch (node.operatorToken.kind) { case 58: return getReferenceCandidate(node.left); @@ -34455,13 +34842,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 191 || - parent.kind === 200 && parent.operatorToken.kind === 58 && parent.left === node || - parent.kind === 200 && parent.operatorToken.kind === 26 && parent.right === node ? + return parent.kind === 193 || + parent.kind === 202 && parent.operatorToken.kind === 58 && parent.left === node || + parent.kind === 202 && parent.operatorToken.kind === 26 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266) { + if (clause.kind === 269) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -34608,11 +34995,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 185 && (parent.name.escapedText === "length" || - parent.parent.kind === 187 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 186 && + var isLengthPushOrUnshift = parent.kind === 187 && (parent.name.escapedText === "length" || + parent.parent.kind === 189 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 && parent.expression === root && - parent.parent.kind === 200 && + parent.parent.kind === 202 && parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -34656,7 +35043,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 209 && getTypeWithFacts(resultType, 524288).flags & 32768) { + if (reference.parent && reference.parent.kind === 211 && getTypeWithFacts(resultType, 524288).flags & 32768) { return declaredType; } return resultType; @@ -34718,7 +35105,7 @@ var ts; } else if (flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 185 && reference.kind !== 99) { + if (container && container !== flowContainer && reference.kind !== 187 && reference.kind !== 99) { flow = container.flowNode; continue; } @@ -34763,7 +35150,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 ? + var expr = node.kind === 189 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -34771,7 +35158,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 187) { + if (node.kind === 189) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -34895,7 +35282,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 && + return expr.kind === 187 && computedType.flags & 262144 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -34946,10 +35333,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 === 195 && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -35143,7 +35530,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 || invokedExpression.kind === 185) { + if (invokedExpression.kind === 188 || invokedExpression.kind === 187) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -35161,15 +35548,15 @@ var ts; case 71: case 99: case 97: - case 185: - return narrowTypeByTruthiness(type, expr, assumeTrue); case 187: + return narrowTypeByTruthiness(type, expr, assumeTrue); + case 189: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191: + case 193: return narrowType(type, expr.expression, assumeTrue); - case 200: + case 202: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198: + case 200: if (expr.operator === 51) { return narrowType(type, expr.operand, !assumeTrue); } @@ -35196,8 +35583,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 || - node.kind === 274 || + node.kind === 243 || + node.kind === 277 || node.kind === 152; }); } @@ -35241,10 +35628,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 185 || - parent.kind === 187 && parent.expression === node || - parent.kind === 186 && parent.expression === node || - parent.kind === 182 && parent.name === node && !!parent.initializer; + return parent.kind === 187 || + parent.kind === 189 && parent.expression === node || + parent.kind === 188 && parent.expression === node || + parent.kind === 184 && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576); @@ -35268,7 +35655,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 193) { + if (container.kind === 195) { 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)) { @@ -35284,7 +35671,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 235 + if (declaration.kind === 238 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -35296,9 +35683,9 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205) { + else if (declaration.kind === 207) { var container = ts.getThisContainer(node, false); - while (container.kind !== 274) { + while (container.kind !== 277) { if (container.parent === declaration) { if (container.kind === 152 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 8388608; @@ -35343,17 +35730,17 @@ var ts; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - var isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - while (flowContainer !== declarationContainer && (flowContainer.kind === 192 || - flowContainer.kind === 193 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 || + flowContainer.kind === 195 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } - var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3) !== 0 || - isInTypeQuery(node) || node.parent.kind === 252) || - node.parent.kind === 209 || - declaration.kind === 232 && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 255) || + node.parent.kind === 211 || + declaration.kind === 235 && declaration.exclamationToken || declaration.flags & 4194304; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -35380,7 +35767,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 269) { + symbol.valueDeclaration.parent.kind === 272) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -35398,8 +35785,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 220 && - ts.getAncestor(symbol.valueDeclaration, 233).parent === container && + if (container.kind === 223 && + ts.getAncestor(symbol.valueDeclaration, 236).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -35411,14 +35798,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 191) { + while (current.parent.kind === 193) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 || current.parent.kind === 199)) { + else if ((current.parent.kind === 200 || current.parent.kind === 201)) { var expr = current.parent; isAssigned = expr.operator === 43 || expr.operator === 44; } @@ -35462,7 +35849,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { var superCall = getSuperCallInConstructor(container); if (!superCall || superCall.end > node.pos) { @@ -35476,15 +35863,15 @@ var ts; if (container.kind === 155) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 193) { + if (container.kind === 195) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 239: + case 242: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 238: + case 241: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; case 155: @@ -35515,8 +35902,8 @@ var ts; if (container === void 0) { container = ts.getThisContainer(node, false); } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 192 && - container.parent.kind === 200 && + if (container.kind === 194 && + container.parent.kind === 202 && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -35546,7 +35933,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284) { + if (jsdocType && jsdocType.kind === 287) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -35563,11 +35950,11 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 193) { + while (container && container.kind === 195) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -35582,7 +35969,7 @@ var ts; 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 === 184)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -35611,7 +35998,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184) { + if (container.parent.kind === 186) { 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 errorType; @@ -35621,7 +36008,7 @@ var ts; } } var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -35645,7 +36032,7 @@ var ts; return container.kind === 155; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 184) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186) { if (ts.hasModifier(container, 32)) { return container.kind === 154 || container.kind === 153 || @@ -35669,8 +36056,8 @@ var ts; function getContainingObjectLiteral(func) { return (func.kind === 154 || func.kind === 156 || - func.kind === 157) && func.parent.kind === 184 ? func.parent : - func.kind === 192 && func.parent.kind === 270 ? func.parent.parent : + func.kind === 157) && func.parent.kind === 186 ? func.parent : + func.kind === 194 && func.parent.kind === 273 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -35682,7 +36069,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193) { + if (func.kind === 195) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -35706,7 +36093,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270) { + if (literal.parent.kind !== 273) { break; } literal = literal.parent.parent; @@ -35715,9 +36102,9 @@ var ts; return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } var parent = func.parent; - if (parent.kind === 200 && parent.operatorToken.kind === 58) { + if (parent.kind === 202 && parent.operatorToken.kind === 58) { var target = parent.left; - if (target.kind === 185 || target.kind === 186) { + if (target.kind === 187 || target.kind === 188) { var expression = target.expression; if (inJs && ts.isIdentifier(expression)) { var sourceFile = ts.getSourceFileOfNode(parent); @@ -35738,27 +36125,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); @@ -35767,10 +36151,8 @@ var ts; if (indexOfParameter < len) { return getTypeAtPosition(contextualSignature, indexOfParameter); } - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -35793,7 +36175,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182) { + if (parentDeclaration.kind !== 184) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -35868,7 +36250,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189) { + if (template.parent.kind === 191) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -35909,8 +36291,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, true); } function getIndexTypeOfContextualType(type, kind) { @@ -35931,8 +36324,8 @@ var ts; var type = getApparentTypeOfContextualType(objectLiteral); if (type) { if (!hasNonBindableDynamicName(element)) { - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -35986,8 +36379,8 @@ var ts; case 95: case 71: return true; - case 185: - case 191: + case 187: + case 193: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -36003,14 +36396,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270) + if (prop.kind !== 273) continue; if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; @@ -36033,51 +36426,51 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232: + case 235: case 149: case 152: case 151: - case 182: + case 184: return getContextualTypeForInitializerExpression(node); - case 193: - case 225: + case 195: + case 228: return getContextualTypeForReturnExpression(node); - case 203: + case 205: return getContextualTypeForYieldOperand(parent); - case 187: - case 188: - return getContextualTypeForArgument(parent, node); + case 189: case 190: - case 208: + return getContextualTypeForArgument(parent, node); + case 192: + case 210: return getTypeFromTypeNode(parent.type); - case 200: + case 202: return getContextualTypeForBinaryOperand(node); - case 270: - case 271: + case 273: + case 274: return getContextualTypeForObjectLiteralElement(parent); - case 272: + case 275: return getApparentTypeOfContextualType(parent.parent); - case 183: { + case 185: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201: + case 203: return getContextualTypeForConditionalOperand(node); - case 211: - ts.Debug.assert(parent.parent.kind === 202); + case 214: + ts.Debug.assert(parent.parent.kind === 204); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191: { + case 193: { var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 265: + case 268: return getContextualTypeForJsxExpression(parent); - case 262: - case 264: + case 265: + case 267: return getContextualTypeForJsxAttribute(parent); - case 257: - case 256: + case 260: + case 259: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -36142,6 +36535,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -36152,8 +36546,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) : forcedLookupLocation === "" @@ -36165,7 +36575,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { return attributesType; } else { @@ -36205,11 +36616,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 || node.kind === 193; + return node.kind === 194 || node.kind === 195; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -36271,18 +36681,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false, false); } function hasDefaultValue(node) { - return (node.kind === 182 && !!node.initializer) || - (node.kind === 200 && node.operatorToken.kind === 58); + return (node.kind === 184 && !!node.initializer) || + (node.kind === 202 && node.operatorToken.kind === 58); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204) { + if (inDestructuringPattern && e.kind === 206) { var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || getIteratedTypeOrElementType(restArrayType, undefined, false, false, false); @@ -36295,38 +36706,44 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204; + if (index < elementCount - 1 && e.kind === 206) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206; + var minLength = elementCount - (hasRestElement ? 1 : 0); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 181 || pattern.kind === 183)) { + if (!hasRestElement && pattern && (pattern.kind === 183 || pattern.kind === 185)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - if (patternElement.kind !== 206) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + else if (i < patternElements.length - 1 || !(e.kind === 184 && e.dotDotDotToken || e.kind === 206)) { + if (e.kind !== 208) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -36385,7 +36802,7 @@ var ts; var propagatedFlags = 33554432; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 || contextualType.pattern.kind === 184); + (contextualType.pattern.kind === 182 || contextualType.pattern.kind === 186); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -36399,11 +36816,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 || - memberDecl.kind === 271 || + if (memberDecl.kind === 273 || + memberDecl.kind === 274 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -36422,8 +36839,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 270 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -36446,7 +36863,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272) { + else if (memberDecl.kind === 275) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -36533,18 +36950,24 @@ var ts; type.flags & 131072 && !isGenericMappedType(type) || type.flags & 786432 && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + function checkJsxElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0); if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); } else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -36560,15 +36983,7 @@ var ts; return !ts.stringContains(name, "-"); } function isJsxIntrinsicIdentifier(tagName) { - switch (tagName.kind) { - case 185: - case 99: - return false; - case 71: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -36602,7 +37017,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264); + ts.Debug.assert(attributeDecl.kind === 267); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, 4096); attributesTable = ts.createSymbolTable(); @@ -36624,7 +37039,7 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, 4096); } } - var parent = openingLikeElement.parent.kind === 255 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -36758,12 +37173,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } return getGlobalSymbol(JsxNames.JSX, 1920, undefined); @@ -36785,6 +37212,9 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928); + } function getJsxElementPropertiesName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace); } @@ -37060,7 +37490,7 @@ var ts; var targetAttributesType = isJsxIntrinsicIdentifier(openingLikeElement.tagName) ? getIntrinsicAttributesTypeFromJsxOpeningLikeElement(openingLikeElement) : getCustomJsxElementAttributesType(openingLikeElement, false); - var sourceAttributesType = createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { for (var _i = 0, _a = openingLikeElement.attributes.properties; _i < _a.length; _i++) { @@ -37077,28 +37507,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -37131,9 +37540,9 @@ var ts; } function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 || node.kind === 232 ? + var errorNode = node.kind === 187 || node.kind === 235 ? node.name : - node.kind === 179 ? + node.kind === 181 ? node : node.right; if (ts.getCheckFlags(prop) & 256) { @@ -37275,7 +37684,7 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - if (node.kind !== 185 || + if (node.kind !== 187 || assignmentKind === 1 || prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 262144)) { return propType; @@ -37302,16 +37711,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 && + else if (valueDeclaration.kind === 238 && node.parent.kind !== 162 && !(valueDeclaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -37319,7 +37733,7 @@ var ts; switch (node.kind) { case 152: return true; - case 270: + case 273: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -37370,13 +37784,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -37416,16 +37836,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185: + case 187: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179: + case 181: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -37455,7 +37875,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233) { + if (initializer.kind === 236) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -37477,7 +37897,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 && + if (node.kind === 224 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -37495,7 +37915,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 && node.parent.expression === node) { + if (node.parent.kind === 190 && 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); @@ -37554,7 +37974,7 @@ var ts; if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189) { + if (node.kind === 191) { checkExpression(node.template); } else if (node.kind !== 150) { @@ -37605,14 +38025,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 || arg.kind === 213 && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -37623,10 +38040,10 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { return true; } - if (node.kind === 189) { + if (node.kind === 191) { argCount = args.length; typeArguments = node.typeArguments; - if (node.template.kind === 202) { + if (node.template.kind === 204) { var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } @@ -37642,8 +38059,8 @@ var ts; } else { if (!node.arguments) { - ts.Debug.assert(node.kind === 188); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; callIsIncomplete = node.arguments.end === node.end; @@ -37654,13 +38071,12 @@ var ts; return false; } if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -37681,8 +38097,9 @@ var ts; } function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8); @@ -37711,7 +38128,7 @@ var ts; var instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 8); @@ -37723,10 +38140,12 @@ var ts; var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; inferTypes(context.inferences, thisArgumentType, thisType); } - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 206) { + if (arg === undefined || arg.kind !== 208) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -37736,6 +38155,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } if (excludeArgument) { for (var i = 0; i < argCount; i++) { if (excludeArgument[i] === false) { @@ -37747,6 +38170,33 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + return arg.kind === 213 ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 | 1048576); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -37791,7 +38241,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188) { + if (thisType && thisType !== voidType && node.kind !== 190) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -37802,34 +38252,42 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 206) { - var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208) { + if (i === restIndex && (restType.flags & 65536 || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + var paramType = getTypeAtPosition(signature, i); + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } return true; } function getThisArgumentOfCall(node) { - if (node.kind === 187) { + if (node.kind === 189) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 || callee.kind === 186) { + if (callee.kind === 187 || callee.kind === 188) { return callee.expression; } } } function getEffectiveCallArguments(node) { - if (node.kind === 189) { + if (node.kind === 191) { var template = node.template; var args_4 = [undefined]; - if (template.kind === 202) { + if (template.kind === 204) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -37843,14 +38301,32 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150) { switch (node.parent.kind) { - case 235: - case 205: + case 238: + case 207: return 1; case 152: return 2; @@ -37872,7 +38348,7 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 235) { + if (node.kind === 238) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } @@ -37893,7 +38369,7 @@ var ts; return errorType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 235) { + if (node.kind === 238) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -37932,7 +38408,7 @@ var ts; return errorType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 235) { + if (node.kind === 238) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -37969,14 +38445,14 @@ var ts; if (node.kind === 150) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189) { + else if (argIndex === 0 && node.kind === 191) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { if (node.kind === 150 || - (argIndex === 0 && node.kind === 189)) { + (argIndex === 0 && node.kind === 191)) { return undefined; } return args[argIndex]; @@ -37985,7 +38461,7 @@ var ts; if (node.kind === 150) { return node.expression; } - else if (argIndex === 0 && node.kind === 189) { + else if (argIndex === 0 && node.kind === 191) { return node.template; } else { @@ -38004,7 +38480,7 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 189; + var isTaggedTemplate = node.kind === 191; var isDecorator = node.kind === 150; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -38038,7 +38514,7 @@ var ts; var candidateForArgumentError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 187 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -38065,10 +38541,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -38175,11 +38651,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -38193,7 +38670,7 @@ var ts; return anySignature; } if (superType !== errorType) { - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -38328,8 +38805,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -38351,8 +38827,8 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235: - case 205: + case 238: + case 207: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -38410,16 +38886,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187: + case 189: return resolveCallExpression(node, candidatesOutArray); - case 188: + case 190: return resolveNewExpression(node, candidatesOutArray); - case 189: + case 191: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150: return resolveDecorator(node, candidatesOutArray); - case 257: - case 256: + case 260: + case 259: var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray); @@ -38474,7 +38950,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -38488,7 +38965,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185) { + while (parent && parent.kind === 187) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58) { @@ -38515,7 +38992,7 @@ var ts; if (node.expression.kind === 97) { return voidType; } - if (node.kind === 188) { + if (node.kind === 190) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 && @@ -38632,9 +39109,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 234 + ? 237 : resolvedRequire.flags & 3 - ? 232 + ? 235 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -38711,10 +39188,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -38753,10 +39327,10 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -38816,7 +39390,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213) { + if (func.body.kind !== 216) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2) { type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -38895,7 +39469,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member @@ -38919,7 +39493,7 @@ var ts; if (!(func.flags & 128)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -38956,11 +39530,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192: - case 193: + case 194: + case 195: return true; case 154: - return func.parent.kind === 184; + return func.parent.kind === 186; default: return false; } @@ -38972,7 +39546,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 3 | 4096)) { return; } - if (func.kind === 153 || ts.nodeIsMissing(func.body) || func.body.kind !== 213 || !functionHasImplicitReturn(func)) { + if (func.kind === 153 || ts.nodeIsMissing(func.body) || func.body.kind !== 216 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -39004,7 +39578,7 @@ var ts; return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192) { + if (!hasGrammarError && node.kind === 194) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -39055,7 +39629,7 @@ var ts; if (!returnTypeNode) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213) { + if (node.body.kind === 216) { checkSourceElement(node.body); } else { @@ -39063,10 +39637,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3) === 2) { var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -39089,7 +39663,7 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 185 || expr.kind === 186) && + (expr.kind === 187 || expr.kind === 188) && expr.expression.kind === 99) { var func = ts.getContainingFunction(expr); if (!(func && func.kind === 155)) { @@ -39102,13 +39676,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 || expr.kind === 186) { + if (expr.kind === 187 || expr.kind === 188) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 246; + return !!declaration && declaration.kind === 249; } } } @@ -39116,7 +39690,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipOuterExpressions(expr, 2 | 1); - if (node.kind !== 71 && node.kind !== 185 && node.kind !== 186) { + if (node.kind !== 71 && node.kind !== 187 && node.kind !== 188) { error(expr, invalidReferenceMessage); return false; } @@ -39125,7 +39699,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 && expr.kind !== 186) { + if (expr.kind !== 187 && expr.kind !== 188) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -39286,7 +39860,7 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 270 || property.kind === 271) { + if (property.kind === 273 || property.kind === 274) { var name = property.name; if (name.kind === 147) { checkComputedPropertyName(name); @@ -39301,7 +39875,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 271) { + if (property.kind === 274) { return checkDestructuringAssignment(property, type); } else { @@ -39312,7 +39886,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 272) { + else if (property.kind === 275) { if (languageVersion < 6) { checkExternalEmitHelpers(property, 4); } @@ -39344,25 +39918,21 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206) { - if (element.kind !== 204) { + if (element.kind !== 208) { + if (element.kind !== 206) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -39371,12 +39941,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 && restExpression.operatorToken.kind === 58) { + if (restExpression.kind === 202 && restExpression.operatorToken.kind === 58) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -39385,7 +39958,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271) { + if (exprOrAssignment.kind === 274) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -39399,25 +39972,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 && target.operatorToken.kind === 58) { + if (target.kind === 202 && target.operatorToken.kind === 58) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184) { + if (target.kind === 186) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183) { + if (target.kind === 185) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 272 ? + var error = target.parent.kind === 275 ? 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)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -39427,35 +40000,35 @@ var ts; case 71: case 9: case 12: - case 189: - case 202: + case 191: + case 204: case 13: case 8: case 101: case 86: case 95: case 140: - case 192: - case 205: - case 193: - case 183: - case 184: + case 194: + case 207: case 195: - case 209: - case 256: - case 255: + case 185: + case 186: + case 197: + case 211: + case 259: + case 258: return true; - case 201: + case 203: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200: + case 202: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198: - case 199: + case 200: + case 201: switch (node.operator) { case 51: case 37: @@ -39464,9 +40037,9 @@ var ts; return true; } return false; - case 196: - case 190: - case 208: + case 198: + case 192: + case 210: default: return false; } @@ -39482,7 +40055,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 && (left.kind === 184 || left.kind === 183)) { + if (operator === 58 && (left.kind === 186 || left.kind === 185)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -39664,7 +40237,7 @@ var ts; if (produceDiagnostics && ts.isAssignmentOperator(operator)) { if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { - checkTypeAssignableTo(valueType, leftType, left, undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -39685,7 +40258,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34: + case 32: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35: + case 33: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -39734,7 +40323,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } return anyType; } @@ -39753,7 +40342,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263) { + if (node.kind === 266) { return node.parent.parent; } return node; @@ -39786,7 +40375,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 || node.kind === 208; + return node.kind === 192 || node.kind === 210; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -39868,7 +40457,7 @@ var ts; return type; } function getTypeOfExpression(node, cache) { - if (node.kind === 187 && node.expression.kind !== 97 && !ts.isRequireCall(node, true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 && node.expression.kind !== 97 && !ts.isRequireCall(node, true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -39897,8 +40486,8 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 185 && node.parent.expression === node) || - (node.parent.kind === 186 && node.parent.expression === node) || + var ok = (node.parent.kind === 187 && node.parent.expression === node) || + (node.parent.kind === 188 && node.parent.expression === node) || ((node.kind === 71 || node.kind === 146) && isInRightSideOfImportOrExportAssignment(node) || (node.parent.kind === 165 && node.parent.exprName === node)); if (!ok) { @@ -39934,73 +40523,75 @@ var ts; return trueType; case 86: return falseType; - case 202: + case 204: return checkTemplateExpression(node); case 12: return globalRegExpType; - case 183: + case 185: return checkArrayLiteral(node, checkMode); - case 184: + case 186: return checkObjectLiteral(node, checkMode); - case 185: + case 187: return checkPropertyAccessExpression(node); - case 186: + case 188: return checkIndexedAccess(node); - case 187: + case 189: if (node.expression.kind === 91) { return checkImportCallExpression(node); } - case 188: + case 190: return checkCallExpression(node); - case 189: - return checkTaggedTemplateExpression(node); case 191: + return checkTaggedTemplateExpression(node); + case 193: return checkParenthesizedExpression(node, checkMode); - case 205: + case 207: return checkClassExpression(node); - case 192: - case 193: - return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 194: case 195: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 197: return checkTypeOfExpression(node); - case 190: - case 208: + case 192: + case 210: return checkAssertion(node); - case 209: + case 211: return checkNonNullAssertion(node); - case 210: + case 212: return checkMetaProperty(node); - case 194: - return checkDeleteExpression(node); case 196: + return checkDeleteExpression(node); + case 198: return checkVoidExpression(node); - case 197: + case 199: return checkAwaitExpression(node); - case 198: + case 200: return checkPrefixUnaryExpression(node); - case 199: + case 201: return checkPostfixUnaryExpression(node); - case 200: + case 202: return checkBinaryExpression(node, checkMode); - case 201: + case 203: return checkConditionalExpression(node, checkMode); - case 204: - return checkSpreadExpression(node, checkMode); case 206: + return checkSpreadExpression(node, checkMode); + case 208: return undefinedWideningType; - case 203: + case 205: return checkYieldExpression(node); - case 265: + case 213: + return node.type; + case 268: return checkJsxExpression(node, checkMode); - case 255: + case 258: return checkJsxElement(node, checkMode); - case 256: - return checkJsxSelfClosingElement(node, checkMode); case 259: + return checkJsxSelfClosingElement(node, checkMode); + case 262: return checkJsxFragment(node, checkMode); - case 263: + case 266: return checkJsxAttributes(node, checkMode); - case 257: + case 260: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -40027,6 +40618,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); @@ -40047,7 +40641,7 @@ var ts; error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -40105,10 +40699,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193: + case 195: case 158: - case 234: - case 192: + case 237: + case 194: case 163: case 154: case 153: @@ -40129,7 +40723,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 181 || name.kind === 180) { + else if (name.kind === 183 || name.kind === 182) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -40140,7 +40734,7 @@ var ts; if (node.kind === 160) { checkGrammarIndexSignature(node); } - else if (node.kind === 163 || node.kind === 234 || node.kind === 164 || + else if (node.kind === 163 || node.kind === 237 || node.kind === 164 || node.kind === 158 || node.kind === 155 || node.kind === 159) { checkGrammarFunctionLikeDeclaration(node); @@ -40194,7 +40788,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 && node.kind !== 284) { + if (node.kind !== 160 && node.kind !== 287) { registerForUnusedIdentifiersCheck(node); } } @@ -40305,7 +40899,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236) { + if (node.kind === 239) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -40376,7 +40970,7 @@ var ts; !!n.initializer; } var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -40391,7 +40985,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 216 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -40533,10 +41127,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -40549,7 +41161,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 186 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -40584,7 +41196,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -40598,9 +41210,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 236 && - n.parent.kind !== 235 && - n.parent.kind !== 205 && + if (n.parent.kind !== 239 && + n.parent.kind !== 238 && + n.parent.kind !== 207 && n.flags & 4194304) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; @@ -40713,11 +41325,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304; - var inAmbientContextOrInterface = node.parent.kind === 236 || node.parent.kind === 166 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 || node.parent.kind === 166 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 234 || node.kind === 154 || node.kind === 153 || node.kind === 155) { + if (node.kind === 237 || node.kind === 154 || node.kind === 153 || node.kind === 155) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -40830,36 +41442,36 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236: - case 237: - case 298: - case 292: - return 2; case 239: + case 240: + case 301: + case 295: + return 2; + case 242: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 235: case 238: + case 241: return 2 | 1; - case 274: + case 277: return 2 | 1 | 4; - case 249: + case 252: if (!ts.isEntityNameExpression(d.expression)) { return 1; } d = d.expression; - case 243: case 246: - case 245: + case 249: + case 248: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 232: - case 182: - case 234: - case 248: + case 235: + case 184: + case 237: + case 251: return 1; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -41015,7 +41627,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235: + case 238: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -41065,12 +41677,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170: - case 169: + case 172: + case 171: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173) { + while (typeNode.kind === 175) { typeNode = typeNode.type; } if (typeNode.kind === 131) { @@ -41095,7 +41707,7 @@ var ts; } } return commonEntityName; - case 173: + case 175: return getEntityNameForDecoratorMetadata(node.type); case 162: return node.typeName; @@ -41124,7 +41736,7 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 235: + case 238: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -41209,7 +41821,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -41221,7 +41833,7 @@ var ts; switch (node.kind) { case 71: return node; - case 185: + case 187: return node.name; default: return undefined; @@ -41280,27 +41892,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235: - case 205: + case 238: + case 207: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236: + case 239: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274: - case 239: - case 213: - case 241: - case 220: - case 221: - case 222: + case 277: + case 242: + case 216: + case 244: + case 223: + case 224: + case 225: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155: - case 192: - case 234: - case 193: + case 194: + case 237: + case 195: case 154: case 156: case 157: @@ -41314,7 +41926,7 @@ var ts; case 159: case 163: case 164: - case 237: + case 240: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -41327,10 +41939,7 @@ var ts; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; addDiagnostic(0, ts.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -41359,7 +41968,7 @@ var ts; } break; case 160: - case 212: + case 215: break; default: ts.Debug.fail(); @@ -41372,7 +41981,7 @@ var ts; if (!(node.flags & 4194304) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -41404,7 +42013,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -41421,9 +42030,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -41438,7 +42047,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0, unuseds.length === 1 @@ -41456,7 +42065,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 && bindingPattern.parent.parent.kind === 233) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 && bindingPattern.parent.parent.kind === 236) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -41477,7 +42086,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(0, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 214 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -41491,21 +42100,21 @@ var ts; switch (name.kind) { case 71: return ts.idText(name); - case 181: - case 180: + case 183: + case 182: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 || node.kind === 248 || node.kind === 246; + return node.kind === 248 || node.kind === 251 || node.kind === 249; } function importClauseFromImported(decl) { - return decl.kind === 245 ? decl : decl.kind === 246 ? decl.parent : decl.parent.parent; + return decl.kind === 248 ? decl : decl.kind === 249 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 213) { + if (node.kind === 216) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -41592,7 +42201,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 274 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 && 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)); } } @@ -41604,7 +42213,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 274 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 277 && 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)); } } @@ -41612,7 +42221,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 232 && !node.initializer) { + if (node.kind === 235 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -41624,15 +42233,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233); - var container = varDeclList.parent.kind === 214 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236); + var container = varDeclList.parent.kind === 217 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 213 && ts.isFunctionLike(container.parent) || - container.kind === 240 || - container.kind === 239 || - container.kind === 274); + (container.kind === 216 && ts.isFunctionLike(container.parent) || + container.kind === 243 || + container.kind === 242 || + container.kind === 277); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -41651,7 +42260,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 185) { + if (n.kind === 187) { return visit(n.expression); } else if (n.kind === 71) { @@ -41666,7 +42275,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 || - symbol.valueDeclaration.kind === 182) { + symbol.valueDeclaration.kind === 184) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -41707,8 +42316,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182) { - if (node.parent.kind === 180 && languageVersion < 6) { + if (node.kind === 184) { + if (node.parent.kind === 182 && languageVersion < 6) { checkExternalEmitHelpers(node, 4); } if (node.propertyName && node.propertyName.kind === 147) { @@ -41726,7 +42335,7 @@ var ts; } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); @@ -41736,13 +42345,13 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 221) { + if (node.initializer && node.parent.parent.kind !== 224) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -41757,8 +42366,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined); checkParameterInitializer(node); } } @@ -41771,7 +42380,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -41780,7 +42389,7 @@ var ts; } if (node.kind !== 152 && node.kind !== 151) { checkExportsOnMergedDeclarations(node); - if (node.kind === 232 || node.kind === 182) { + if (node.kind === 235 || node.kind === 184) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -41795,8 +42404,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 && right.kind === 232) || - (left.kind === 232 && right.kind === 149)) { + if ((left.kind === 149 && right.kind === 235) || + (left.kind === 235 && right.kind === 149)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -41831,7 +42440,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215) { + if (node.thenStatement.kind === 218) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -41848,12 +42457,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233) { + if (node.initializer && node.initializer.kind === 236) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233) { + if (node.initializer.kind === 236) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -41880,20 +42489,20 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 233) { + if (node.initializer.kind === 236) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); - if (varExpr.kind === 183 || varExpr.kind === 184) { + if (varExpr.kind === 185 || varExpr.kind === 186) { checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -41905,7 +42514,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 233) { + if (node.initializer.kind === 236) { 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); @@ -41915,7 +42524,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 183 || varExpr.kind === 184) { + if (varExpr.kind === 185 || varExpr.kind === 186) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -42167,7 +42776,7 @@ var ts; } } else if (func.kind === 155) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -42180,7 +42789,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -42209,7 +42818,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 267 && !hasDuplicateDefaultClause) { + if (clause.kind === 270 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -42221,7 +42830,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266) { + if (produceDiagnostics && clause.kind === 269) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -42245,7 +42854,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -42334,13 +42943,14 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; - if (indexKind === 1 && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); + if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 || - ts.getNameOfDeclaration(propDeclaration).kind === 147 || + if (propDeclaration && name && + (propDeclaration.kind === 202 || + name.kind === 147 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -42492,7 +43102,7 @@ var ts; if (!(node.flags & 4194304)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2) { checkExternalEmitHelpers(baseTypeNode.parent, 1); @@ -42504,6 +43114,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -42565,7 +43179,7 @@ var ts; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -42583,7 +43197,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag); @@ -42606,7 +43220,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 || d.kind === 236; + return d.kind === 238 || d.kind === 239; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -42624,7 +43238,7 @@ var ts; if (derived === base) { var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { - if (derivedClassDecl.kind === 205) { + if (derivedClassDecl.kind === 207) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -42733,7 +43347,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -42792,7 +43406,7 @@ var ts; if (member.initializer) { return computeConstantValue(member); } - if (member.parent.flags & 4194304 && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 && !ts.isEnumConst(member.parent)) { return undefined; } if (autoValue !== undefined) { @@ -42803,7 +43417,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -42829,7 +43443,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198: + case 200: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -42839,7 +43453,7 @@ var ts; } } break; - case 200: + case 202: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -42867,7 +43481,7 @@ var ts; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 191: + case 193: return evaluate(expr.expression); case 71: var identifier = expr; @@ -42875,14 +43489,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186: - case 185: + case 188: + case 187: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384) { var name = void 0; - if (ex.kind === 185) { + if (ex.kind === 187) { name = ex.name.escapedText; } else { @@ -42914,8 +43528,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 || - node.kind === 185 && isConstantMemberAccess(node.expression) || - node.kind === 186 && isConstantMemberAccess(node.expression) && + node.kind === 187 && isConstantMemberAccess(node.expression) || + node.kind === 188 && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9; } function checkEnumDeclaration(node) { @@ -42928,7 +43542,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -42937,14 +43551,14 @@ var ts; if (node === firstDeclaration) { if (enumSymbol.declarations.length > 1) { ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 238) { + if (declaration.kind !== 241) { return false; } var enumDeclaration = declaration; @@ -42967,8 +43581,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 235 || - (declaration.kind === 234 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 238 || + (declaration.kind === 237 && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304)) { return declaration; } @@ -43026,7 +43640,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, 235); + var mergedClass = ts.getDeclarationOfKind(symbol, 238); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -43069,22 +43683,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214: + case 217: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 249: - case 250: + case 252: + case 253: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243: - case 244: + case 246: + case 247: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182: - case 232: + case 184: + case 235: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -43093,12 +43707,12 @@ var ts; } break; } - case 235: case 238: - case 234: - case 236: - case 239: + case 241: case 237: + case 239: + case 242: + case 240: if (isGlobalAugmentation) { return; } @@ -43121,7 +43735,7 @@ var ts; node = node.left; } while (node.kind !== 71); return node; - case 185: + case 187: do { node = node.expression; } while (node.kind !== 71); @@ -43137,9 +43751,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 240 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 274 && !inAmbientExternalModule) { - error(moduleName, node.kind === 250 ? + var inAmbientExternalModule = node.parent.kind === 243 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -43160,13 +43774,13 @@ var ts; (symbol.flags & 67901928 ? 67901928 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 252 ? + var message = node.kind === 255 ? 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)); } if (compilerOptions.isolatedModules - && node.kind === 252 + && node.kind === 255 && !(target.flags & 67216319) && !(node.flags & 4194304)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -43192,7 +43806,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246) { + if (importClause.namedBindings.kind === 249) { checkImportBinding(importClause.namedBindings); } else { @@ -43215,7 +43829,7 @@ var ts; if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254) { + if (node.moduleReference.kind !== 257) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319) { @@ -43246,10 +43860,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 && + var inAmbientExternalModule = node.parent.kind === 243 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 && !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 274 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -43265,7 +43879,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 || node.parent.kind === 240 || node.parent.kind === 239; + var isInAppropriateContext = node.parent.kind === 277 || node.parent.kind === 243 || node.parent.kind === 242; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -43291,8 +43905,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 274 ? node.parent : node.parent.parent; - if (container.kind === 239 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 ? node.parent : node.parent.parent; + if (container.kind === 242 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -43371,7 +43985,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 && declaration.kind !== 154) || + return (declaration.kind !== 237 && declaration.kind !== 154) || !!declaration.body; } function checkSourceElement(node) { @@ -43387,10 +44001,10 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 242: + case 238: case 239: - case 235: - case 236: - case 234: + case 237: cancellationToken.throwIfCancellationRequested(); } } @@ -43428,110 +44042,112 @@ var ts; return checkArrayType(node); case 168: return checkTupleType(node); + case 171: + case 172: + return checkUnionOrIntersectionType(node); + case 175: case 169: case 170: - return checkUnionOrIntersectionType(node); - case 173: return checkSourceElement(node.type); - case 175: + case 177: return checkTypeOperator(node); - case 171: + case 173: return checkConditionalType(node); - case 172: + case 174: return checkInferType(node); - case 179: + case 181: return checkImportType(node); - case 290: + case 293: return checkJSDocAugmentsTag(node); - case 298: - case 292: + case 301: + case 295: return checkJSDocTypeAliasTag(node); - case 296: + case 299: return checkJSDocTypeTag(node); - case 293: + case 296: return checkJSDocParameterTag(node); - case 284: + case 287: checkSignatureDeclaration(node); + case 285: + case 284: case 282: - case 281: - case 279: - case 280: - case 287: + case 283: + case 290: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285: + case 288: checkJSDocVariadicType(node); return; - case 278: + case 281: return checkSourceElement(node.type); - case 176: + case 178: return checkIndexedAccessType(node); - case 177: + case 179: return checkMappedType(node); - case 234: + case 237: return checkFunctionDeclaration(node); - case 213: - case 240: + case 216: + case 243: return checkBlock(node); - case 214: + case 217: return checkVariableStatement(node); - case 216: + case 219: return checkExpressionStatement(node); - case 217: + case 220: return checkIfStatement(node); - case 218: + case 221: return checkDoStatement(node); - case 219: + case 222: return checkWhileStatement(node); - case 220: + case 223: return checkForStatement(node); - case 221: + case 224: return checkForInStatement(node); - case 222: + case 225: return checkForOfStatement(node); - case 223: - case 224: + case 226: + case 227: return checkBreakOrContinueStatement(node); - case 225: + case 228: return checkReturnStatement(node); - case 226: + case 229: return checkWithStatement(node); - case 227: + case 230: return checkSwitchStatement(node); - case 228: + case 231: return checkLabeledStatement(node); - case 229: + case 232: return checkThrowStatement(node); - case 230: + case 233: return checkTryStatement(node); - case 232: + case 235: return checkVariableDeclaration(node); - case 182: + case 184: return checkBindingElement(node); - case 235: + case 238: return checkClassDeclaration(node); - case 236: + case 239: return checkInterfaceDeclaration(node); - case 237: + case 240: return checkTypeAliasDeclaration(node); - case 238: + case 241: return checkEnumDeclaration(node); - case 239: + case 242: return checkModuleDeclaration(node); - case 244: + case 247: return checkImportDeclaration(node); - case 243: + case 246: return checkImportEqualsDeclaration(node); - case 250: + case 253: return checkExportDeclaration(node); - case 249: + case 252: return checkExportAssignment(node); - case 215: - case 231: + case 218: + case 234: checkGrammarStatementInAmbientContext(node); return; - case 253: + case 256: return checkMissingDeclaration(node); } } @@ -43589,15 +44205,15 @@ var ts; } function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192: - case 193: + case 194: + case 195: case 154: case 153: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -43606,11 +44222,17 @@ var ts; case 157: checkAccessorDeclaration(node); break; - case 205: + case 207: checkClassExpressionDeferred(node); break; + case 259: + checkJsxSelfClosingElementDeferred(node); + break; + case 258: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -43640,7 +44262,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -43720,24 +44342,24 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239: + case 242: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 238: + case 241: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 205: + case 207: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 235: - case 236: + case 238: + case 239: if (!isStatic) { copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928); } break; - case 192: + case 194: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -43776,10 +44398,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148: - case 235: - case 236: - case 237: case 238: + case 239: + case 240: + case 241: return true; default: return false; @@ -43792,10 +44414,10 @@ var ts; return node.parent.kind === 162; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185) { + while (node.parent.kind === 187) { node = node.parent; } - return node.parent.kind === 207; + return node.parent.kind === 209; } function forEachEnclosingClass(node, callback) { var result; @@ -43826,10 +44448,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243) { + if (nodeOnRightSide.parent.kind === 246) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249) { + if (nodeOnRightSide.parent.kind === 252) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -43855,7 +44477,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 && parent.qualifier === node) { + if (parent && parent.kind === 181 && parent.qualifier === node) { return parent; } return undefined; @@ -43865,21 +44487,21 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 && + entityName.parent.kind === 187 && entityName.parent === entityName.parent.parent.left) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 && ts.isEntityNameExpression(entityName)) { var success = resolveEntityName(entityName, 67216319 | 67901928 | 1920 | 2097152, true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 243); + var importEqualsDeclaration = ts.getAncestor(entityName, 246); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -43896,7 +44518,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 207) { + if (entityName.parent.kind === 209) { meaning = 67901928; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 67216319; @@ -43911,10 +44533,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293) { + if (entityName.parent.kind === 296) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 && entityName.parent.parent.kind === 297) { + if (entityName.parent.kind === 148 && entityName.parent.parent.kind === 300) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -43930,12 +44552,12 @@ var ts; } return resolveEntityName(entityName, 67216319, false, true); } - else if (entityName.kind === 185 || entityName.kind === 146) { + else if (entityName.kind === 187 || entityName.kind === 146) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185) { + if (entityName.kind === 187) { checkPropertyAccessExpression(entityName); } else { @@ -43948,7 +44570,7 @@ var ts; var meaning = entityName.parent.kind === 162 ? 67901928 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 262) { + else if (entityName.parent.kind === 265) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161) { @@ -43957,7 +44579,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274) { + if (node.kind === 277) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -43975,8 +44597,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 && - grandParent.kind === 180 && + else if (parent.kind === 184 && + grandParent.kind === 182 && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -43987,7 +44609,7 @@ var ts; } switch (node.kind) { case 71: - case 185: + case 187: case 146: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99: @@ -44001,7 +44623,7 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 174: + case 176: return getTypeFromThisTypeNode(node).symbol; case 97: return checkExpression(node).symbol; @@ -44014,7 +44636,7 @@ var ts; case 9: case 13: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 244 || node.parent.kind === 250) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 || node.parent.kind === 253) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -44030,14 +44652,14 @@ var ts; case 89: case 36: return getSymbolOfNode(node.parent); - case 179: + case 181: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271) { + if (location && location.kind === 274) { return resolveEntityName(location.name, 67216319 | 2097152); } return undefined; @@ -44098,20 +44720,20 @@ var ts; return errorType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 || expr.kind === 183); - if (expr.parent.kind === 222) { + ts.Debug.assert(expr.kind === 186 || expr.kind === 185); + if (expr.parent.kind === 225) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 200) { + if (expr.parent.kind === 202) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 270) { + if (expr.parent.kind === 273) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 183); + ts.Debug.assert(expr.parent.kind === 185); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, false, false) || errorType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); @@ -44175,7 +44797,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -44217,7 +44839,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 274) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 277) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -44251,7 +44873,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 === 213 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 216 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -44287,16 +44909,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243: - case 245: case 246: case 248: - case 252: + case 249: + case 251: + case 255: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250: + case 253: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249: + case 252: return node.expression && node.expression.kind === 71 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -44306,7 +44928,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -44372,21 +44994,22 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273: - case 185: - case 186: + case 276: + case 187: + case 188: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273) { + if (node.kind === 276) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8)) { - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -44517,7 +45140,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 && type.flags & 33554432); } @@ -44609,14 +45232,14 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 && node.parent.parent && node.parent.parent.kind === 268; + return node.parent && node.parent.kind === 209 && node.parent.parent && node.parent.parent.kind === 271; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } var meaning = 67901928 | 1920; - if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 185 && !isInHeritageClause(node))) { + if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 187 && !isInHeritageClause(node))) { meaning = 67216319 | 1048576; } var symbol = resolveEntityName(node, meaning, true); @@ -44659,7 +45282,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -44673,21 +45296,25 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 274); + return ts.getDeclarationOfKind(moduleSymbol, 277); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -44747,6 +45374,30 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -44839,7 +45490,7 @@ var ts; } switch (modifier.kind) { case 76: - if (node.kind !== 238 && node.parent.kind === 235) { + if (node.kind !== 241) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76)); } break; @@ -44859,7 +45510,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 === 240 || node.parent.kind === 274) { + else if (node.parent.kind === 243 || node.parent.kind === 277) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -44882,7 +45533,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 240 || node.parent.kind === 274) { + else if (node.parent.kind === 243 || node.parent.kind === 277) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149) { @@ -44917,7 +45568,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 235) { + else if (node.parent.kind === 238) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149) { @@ -44926,8 +45577,8 @@ var ts; flags |= 1; break; case 79: - var container = node.parent.kind === 274 ? node.parent : node.parent.parent; - if (container.kind === 239 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 ? node.parent : node.parent.parent; + if (container.kind === 242 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; @@ -44939,13 +45590,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 === 235) { + else if (node.parent.kind === 238) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304) && node.parent.kind === 240) { + else if ((node.parent.flags & 4194304) && node.parent.kind === 243) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -44955,14 +45606,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235) { + if (node.kind !== 238) { if (node.kind !== 154 && node.kind !== 152 && node.kind !== 156 && node.kind !== 157) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 235 && ts.hasModifier(node.parent, 128))) { + if (!(node.parent.kind === 238 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -45004,7 +45655,7 @@ var ts; } return false; } - else if ((node.kind === 244 || node.kind === 243) && flags & 2) { + else if ((node.kind === 247 || node.kind === 246) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 && (flags & 92) && ts.isBindingPattern(node.name)) { @@ -45035,29 +45686,29 @@ var ts; case 154: case 153: case 160: - case 239: - case 244: - case 243: - case 250: - case 249: - case 192: - case 193: + case 242: + case 247: + case 246: + case 253: + case 252: + case 194: + case 195: case 149: return false; default: - if (node.parent.kind === 240 || node.parent.kind === 274) { + if (node.parent.kind === 243 || node.parent.kind === 277) { return false; } switch (node.kind) { - case 234: + case 237: return nodeHasAnyModifiersExcept(node, 120); - case 235: + case 238: return nodeHasAnyModifiersExcept(node, 117); - case 236: - case 214: - case 237: + case 239: + case 217: + case 240: return true; - case 238: + case 241: return nodeHasAnyModifiersExcept(node, 76); default: ts.Debug.fail(); @@ -45071,9 +45722,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154: - case 234: - case 192: - case 193: + case 237: + case 194: + case 195: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -45204,7 +45855,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206) { + if (arg.kind === 208) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -45282,15 +45933,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 && computedPropertyName.expression.operatorToken.kind === 26) { + if (computedPropertyName.expression.kind === 202 && computedPropertyName.expression.operatorToken.kind === 26) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 234 || - node.kind === 192 || + ts.Debug.assert(node.kind === 237 || + node.kind === 194 || node.kind === 154); if (node.flags & 4194304) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -45307,14 +45958,14 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272) { + if (prop.kind === 275) { continue; } var name = prop.name; if (name.kind === 147) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 && !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) { @@ -45327,8 +45978,8 @@ var ts; } var currentKind = void 0; switch (prop.kind) { - case 270: - case 271: + case 273: + case 274: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); @@ -45376,7 +46027,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 264) { + if (attr.kind === 267) { continue; } var name = attr.name, initializer = attr.initializer; @@ -45386,7 +46037,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 && !initializer.expression) { + if (initializer && initializer.kind === 268 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -45395,12 +46046,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384) === 0) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 233) { + if (forInOrOfStatement.initializer.kind === 236) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -45408,20 +46059,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 + var diagnostic = forInOrOfStatement.kind === 224 ? 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 === 221 + var diagnostic = forInOrOfStatement.kind === 224 ? 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 === 221 + var diagnostic = forInOrOfStatement.kind === 224 ? 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); @@ -45486,7 +46137,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232: + case 235: var decl = parent; if (decl.name.kind !== 71) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -45524,7 +46175,7 @@ var ts; return true; } if (node.kind === 154) { - if (node.parent.kind === 184) { + if (node.parent.kind === 186) { if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -45547,7 +46198,7 @@ var ts; return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 236) { + else if (node.parent.kind === 239) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (node.parent.kind === 166) { @@ -45561,9 +46212,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228: + case 231: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 223 + var isMisplacedContinueLabel = node.kind === 226 && !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); @@ -45571,8 +46222,8 @@ var ts; return false; } break; - case 227: - if (node.kind === 224 && !node.label) { + case 230: + if (node.kind === 227 && !node.label) { return false; } break; @@ -45585,13 +46236,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 + var message = node.kind === 227 ? 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 === 224 + var message = node.kind === 227 ? 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); @@ -45604,7 +46255,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 181 || node.name.kind === 180) { + if (node.name.kind === 183 || node.name.kind === 182) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -45617,14 +46268,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 198 && expr.operator === 38 && + expr.kind === 200 && expr.operator === 38 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 && node.parent.parent.kind !== 222) { + if (node.parent.parent.kind !== 224 && node.parent.parent.kind !== 225) { if (node.flags & 4194304) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -45634,7 +46285,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } @@ -45643,19 +46294,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 || !node.type || node.initializer || node.flags & 4194304)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 || !node.type || node.initializer || node.flags & 4194304)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !(node.parent.parent.flags & 4194304) && ts.hasModifier(node.parent.parent, 1)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { @@ -45704,15 +46355,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217: - case 218: - case 219: - case 226: case 220: case 221: case 222: + case 229: + case 223: + case 224: + case 225: return false; - case 228: + case 231: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -45722,7 +46373,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -45789,7 +46440,7 @@ var ts; return true; } } - else if (node.parent.kind === 236) { + else if (node.parent.kind === 239) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -45814,13 +46465,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 236 || - node.kind === 237 || - node.kind === 244 || - node.kind === 243 || - node.kind === 250 || - node.kind === 249 || - node.kind === 242 || + if (node.kind === 239 || + node.kind === 240 || + node.kind === 247 || + node.kind === 246 || + node.kind === 253 || + node.kind === 252 || + node.kind === 245 || ts.hasModifier(node, 2 | 1 | 512)) { return false; } @@ -45829,7 +46480,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 === 214) { + if (ts.isDeclaration(decl) || decl.kind === 217) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -45849,7 +46500,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 === 213 || node.parent.kind === 240 || node.parent.kind === 274) { + if (node.parent.kind === 216 || node.parent.kind === 243 || node.parent.kind === 277) { 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); @@ -45866,10 +46517,10 @@ var ts; 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, 178)) { + else if (ts.isChildOfNodeWithKind(node, 180)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273)) { + else if (ts.isChildOfNodeWithKind(node, 276)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -45920,8 +46571,8 @@ var ts; ts.createTypeChecker = createTypeChecker; function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 248: - case 252: + case 251: + case 255: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -45929,13 +46580,13 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245: - case 243: - case 246: case 248: + case 246: + case 249: + case 251: return true; case 71: - return decl.parent.kind === 248; + return decl.parent.kind === 251; default: return false; } @@ -45950,7 +46601,11 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -46102,7 +46757,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -46191,10 +46846,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26) || - expression.kind === 303 ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147); @@ -46553,14 +47207,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169, types); + return createUnionOrIntersectionTypeNode(171, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -46568,7 +47246,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170, types); + return createUnionOrIntersectionTypeNode(172, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -46587,7 +47265,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171); + var node = createSynthesizedNode(173); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -46605,7 +47283,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172); + var node = createSynthesizedNode(174); node.typeParameter = typeParameter; return node; } @@ -46617,7 +47295,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179); + var node = createSynthesizedNode(181); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -46635,7 +47313,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(175); node.type = type; return node; } @@ -46647,11 +47325,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174); + return createSynthesizedNode(176); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175); + var node = createSynthesizedNode(177); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -46662,7 +47340,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(178); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -46676,7 +47354,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(179); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -46694,7 +47372,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(180); node.literal = literal; return node; } @@ -46706,7 +47384,7 @@ var ts; } ts.updateLiteralTypeNode = updateLiteralTypeNode; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(182); node.elements = createNodeArray(elements); return node; } @@ -46718,7 +47396,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(183); node.elements = createNodeArray(elements); return node; } @@ -46730,7 +47408,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(184); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -46748,7 +47426,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(185); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -46762,7 +47440,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(186); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -46776,7 +47454,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(187); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072); @@ -46791,7 +47469,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(188); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -46805,7 +47483,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(189); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -46821,7 +47499,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(190); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -46837,7 +47515,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(191); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -46860,7 +47538,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(192); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -46874,7 +47552,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(193); node.expression = expression; return node; } @@ -46886,7 +47564,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(194); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -46910,7 +47588,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(195); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -46944,7 +47622,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(196); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -46956,7 +47634,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(197); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -46968,7 +47646,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196); + var node = createSynthesizedNode(198); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -46980,7 +47658,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(199); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -46992,7 +47670,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(200); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -47005,7 +47683,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199); + var node = createSynthesizedNode(201); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -47018,7 +47696,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(202); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -47035,7 +47713,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(203); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -47065,7 +47743,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(204); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -47103,7 +47781,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203); + var node = createSynthesizedNode(205); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 ? asteriskTokenOrExpression : expression; return node; @@ -47117,7 +47795,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(206); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -47129,7 +47807,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205); + var node = createSynthesizedNode(207); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47150,11 +47828,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206); + return createSynthesizedNode(208); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(209); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -47168,7 +47846,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208); + var node = createSynthesizedNode(210); node.expression = expression; node.type = type; return node; @@ -47182,7 +47860,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(211); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -47194,7 +47872,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(212); node.keywordToken = keywordToken; node.name = name; return node; @@ -47207,7 +47885,7 @@ var ts; } ts.updateMetaProperty = updateMetaProperty; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211); + var node = createSynthesizedNode(214); node.expression = expression; node.literal = literal; return node; @@ -47221,23 +47899,17 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212); + return createSynthesizedNode(215); } ts.createSemicolonClassElement = createSemicolonClassElement; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213); + var block = createSynthesizedNode(216); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -47245,7 +47917,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(217); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -47260,21 +47932,25 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215); + return createSynthesizedNode(218); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + ts.createStatement = createExpressionStatement; + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(220); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -47290,7 +47966,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218); + var node = createSynthesizedNode(221); node.statement = statement; node.expression = expression; return node; @@ -47304,7 +47980,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219); + var node = createSynthesizedNode(222); node.expression = expression; node.statement = statement; return node; @@ -47318,7 +47994,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(223); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -47336,7 +48012,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221); + var node = createSynthesizedNode(224); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -47352,7 +48028,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(225); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -47370,7 +48046,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(226); node.label = asName(label); return node; } @@ -47382,7 +48058,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224); + var node = createSynthesizedNode(227); node.label = asName(label); return node; } @@ -47394,7 +48070,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(228); node.expression = expression; return node; } @@ -47406,7 +48082,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(229); node.expression = expression; node.statement = statement; return node; @@ -47420,7 +48096,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(230); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -47434,7 +48110,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(231); node.label = asName(label); node.statement = statement; return node; @@ -47448,7 +48124,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229); + var node = createSynthesizedNode(232); node.expression = expression; return node; } @@ -47460,7 +48136,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230); + var node = createSynthesizedNode(233); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -47476,11 +48152,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231); + return createSynthesizedNode(234); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(235); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -47497,7 +48173,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(233); + var node = createSynthesizedNode(236); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); return node; @@ -47510,7 +48186,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(237); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -47536,7 +48212,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235); + var node = createSynthesizedNode(238); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47558,7 +48234,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(239); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47580,7 +48256,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237); + var node = createSynthesizedNode(240); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47600,7 +48276,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(241); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47619,7 +48295,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(242); node.flags |= flags & (16 | 4 | 512); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -47638,7 +48314,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(243); node.statements = createNodeArray(statements); return node; } @@ -47650,7 +48326,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(244); node.clauses = createNodeArray(clauses); return node; } @@ -47662,7 +48338,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(245); node.name = asName(name); return node; } @@ -47674,7 +48350,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(246); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -47692,7 +48368,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(247); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -47710,7 +48386,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245); + var node = createSynthesizedNode(248); node.name = name; node.namedBindings = namedBindings; return node; @@ -47724,7 +48400,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246); + var node = createSynthesizedNode(249); node.name = name; return node; } @@ -47736,7 +48412,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(250); node.elements = createNodeArray(elements); return node; } @@ -47748,7 +48424,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(251); node.propertyName = propertyName; node.name = name; return node; @@ -47762,7 +48438,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(252); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -47779,7 +48455,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(253); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -47797,7 +48473,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(254); node.elements = createNodeArray(elements); return node; } @@ -47809,7 +48485,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(255); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -47823,7 +48499,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(257); node.expression = expression; return node; } @@ -47835,7 +48511,7 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255); + var node = createSynthesizedNode(258); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -47851,7 +48527,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(259); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -47867,7 +48543,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(260); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -47883,7 +48559,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(261); node.tagName = tagName; return node; } @@ -47895,7 +48571,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259); + var node = createSynthesizedNode(262); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -47911,7 +48587,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262); + var node = createSynthesizedNode(265); node.name = name; node.initializer = initializer; return node; @@ -47925,7 +48601,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(266); node.properties = createNodeArray(properties); return node; } @@ -47937,7 +48613,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264); + var node = createSynthesizedNode(267); node.expression = expression; return node; } @@ -47949,7 +48625,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265); + var node = createSynthesizedNode(268); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -47962,7 +48638,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266); + var node = createSynthesizedNode(269); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -47976,7 +48652,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267); + var node = createSynthesizedNode(270); node.statements = createNodeArray(statements); return node; } @@ -47988,7 +48664,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268); + var node = createSynthesizedNode(271); node.token = token; node.types = createNodeArray(types); return node; @@ -48001,7 +48677,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269); + var node = createSynthesizedNode(272); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -48015,7 +48691,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270); + var node = createSynthesizedNode(273); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -48030,7 +48706,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271); + var node = createSynthesizedNode(274); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -48044,7 +48720,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272); + var node = createSynthesizedNode(275); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } @@ -48056,7 +48732,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273); + var node = createSynthesizedNode(276); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -48076,7 +48752,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274); + var updated = createSynthesizedNode(277); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -48150,28 +48826,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301); + var node = createSynthesizedNode(304); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305); + var node = createSynthesizedNode(308); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304); + var node = createSynthesizedNode(307); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(302); + var node = createSynthesizedNode(305); node.expression = expression; node.original = original; setTextRange(node, original); @@ -48187,7 +48863,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 303) { + if (node.kind === 306) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { @@ -48197,7 +48873,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303); + var node = createSynthesizedNode(306); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -48210,14 +48886,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275); + var node = ts.createNode(278); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276); + var node = ts.createNode(279); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -48225,7 +48901,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277); + var node = ts.createNode(280); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -48334,7 +49010,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 274) { + if (node.kind === 277) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -48765,7 +49441,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -48783,13 +49459,13 @@ var ts; case 8: case 9: return false; - case 183: + case 185: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184: + case 186: return target.properties.length > 0; default: return true; @@ -48816,7 +49492,7 @@ var ts; } else { switch (callee.kind) { - case 185: { + case 187: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -48828,7 +49504,7 @@ var ts; } break; } - case 186: { + case 188: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -48884,9 +49560,9 @@ var ts; case 156: case 157: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270: + case 273: return createExpressionForPropertyAssignment(property, receiver); - case 271: + case 274: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154: return createExpressionForMethodDeclaration(property, receiver); @@ -49090,7 +49766,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 191) { + if (skipped.kind === 193) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -49099,15 +49775,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(200, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 203) { + && operand.kind === 205) { return false; } return true; @@ -49146,7 +49822,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 && node.operatorToken.kind === 37) { + if (node.kind === 202 && node.operatorToken.kind === 37) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -49161,7 +49837,7 @@ var ts; return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201, 55); + var conditionalPrecedence = ts.getOperatorPrecedence(203, 55); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -49172,18 +49848,16 @@ var ts; ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; function parenthesizeSubexpressionOfConditionalExpression(e) { var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 200 && emittedExpression.operatorToken.kind === 26 || - emittedExpression.kind === 303 + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 || - check.kind === 192 || - check.kind === 303 || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26) + return check.kind === 207 || + check.kind === 194 || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -49191,9 +49865,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 187: + case 189: return ts.createParen(expression); - case 188: + case 190: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -49204,7 +49878,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -49242,7 +49916,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200, 26); + var commaPrecedence = ts.getOperatorPrecedence(202, 26); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -49253,27 +49927,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 || kind === 193) { + if (kind === 194 || kind === 195) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind; - if (leftmostExpressionKind === 184 || leftmostExpressionKind === 192) { + if (leftmostExpressionKind === 186 || leftmostExpressionKind === 194) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 ? ts.createParenthesizedType(member) : member; + return member.kind === 173 ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169: - case 170: + case 171: + case 172: case 163: case 164: return ts.createParenthesizedType(member); @@ -49284,8 +49958,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165: - case 175: - case 172: + case 177: + case 174: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -49311,24 +49985,24 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199: + case 201: node = node.operand; continue; - case 200: + case 202: node = node.left; continue; - case 201: + case 203: node = node.condition; continue; - case 187: + case 189: if (stopAtCallExpressions) { return node; } - case 186: - case 185: - node = node.expression; - continue; - case 302: + case 210: + case 188: + case 187: + case 211: + case 305: node = node.expression; continue; } @@ -49336,22 +50010,27 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, false).kind === 184) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 186)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 && node.operatorToken.kind === 26 || + node.kind === 306; + } + ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { - case 191: + case 193: return (kinds & 1) !== 0; - case 190: - case 208: - case 209: + case 192: + case 210: + case 211: return (kinds & 2) !== 0; - case 302: + case 305: return (kinds & 4) !== 0; } return false; @@ -49376,7 +50055,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209) { + while (ts.isAssertionExpression(node) || node.kind === 211) { node = node.expression; } return node; @@ -49384,15 +50063,15 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 191: return ts.updateParen(outerExpression, expression); - case 190: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 208: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 209: return ts.updateNonNullExpression(outerExpression, expression); - case 302: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193: return ts.updateParen(outerExpression, expression); + case 192: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211: return ts.updateNonNullExpression(outerExpression, expression); + case 305: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { - return node.kind === 191 + return node.kind === 193 && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -49454,10 +50133,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 && node.importClause) { + if (node.kind === 247 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 && node.moduleSpecifier) { + if (node.kind === 253 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -49520,11 +50199,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270: + case 273: return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271: + case 274: return bindingElement.name; - case 272: + case 275: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -49541,10 +50220,10 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149: - case 182: + case 184: return bindingElement.dotDotDotToken; - case 204: - case 272: + case 206: + case 275: return bindingElement; } return undefined; @@ -49552,7 +50231,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182: + case 184: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -49560,7 +50239,7 @@ var ts; : propertyName; } break; - case 270: + case 273: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -49568,7 +50247,7 @@ var ts; : propertyName; } break; - case 272: + case 275: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -49582,11 +50261,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180: - case 181: + case 182: case 183: + case 185: return name.elements; - case 184: + case 186: return name.properties; } } @@ -49625,11 +50304,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181: case 183: + case 185: return convertToArrayAssignmentPattern(node); - case 180: - case 184: + case 182: + case 186: return convertToObjectAssignmentPattern(node); } } @@ -49734,7 +50413,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -49766,7 +50445,7 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 145) || kind === 174) { + if ((kind > 0 && kind <= 145) || kind === 176) { return node; } switch (kind) { @@ -49817,206 +50496,210 @@ var ts; case 167: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); case 169: - return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 170: - return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); case 171: - return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); + return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 172: + return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + case 173: + return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); + case 174: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179: + case 181: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 173: - return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); case 175: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 177: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176: + case 178: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177: + case 179: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 178: - return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); case 180: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); + case 182: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181: + case 183: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182: + case 184: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); - case 183: + case 185: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184: + case 186: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185: + case 187: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186: + case 188: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187: + case 189: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188: + case 190: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189: + case 191: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190: + case 192: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191: + case 193: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: + case 194: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 193: + case 195: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 194: + case 196: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195: + case 197: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196: + case 198: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197: + case 199: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198: + case 200: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199: + case 201: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200: + case 202: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201: + case 203: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 202: + case 204: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203: + case 205: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204: + case 206: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205: - return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); case 207: + return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 209: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208: + case 210: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209: + case 211: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210: + case 212: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 211: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 213: - return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 214: - return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 216: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 217: + return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 219: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 218: + case 221: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219: + case 222: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220: + case 223: 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, ts.liftToBlock)); - case 221: + case 224: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 222: + case 225: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223: + case 226: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224: + case 227: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225: + case 228: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226: + case 229: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227: + case 230: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228: + case 231: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229: + case 232: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230: + case 233: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232: + case 235: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233: + case 236: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234: + case 237: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 235: + case 238: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 236: + case 239: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 237: + case 240: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 238: + case 241: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 239: + case 242: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 240: + case 243: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241: + case 244: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242: + case 245: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243: + case 246: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 244: + case 247: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 245: + case 248: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246: + case 249: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247: + case 250: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248: + case 251: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249: + case 252: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250: + case 253: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251: + case 254: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252: + case 255: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 254: + case 257: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); - case 255: + case 258: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256: + case 259: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257: + case 260: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258: + case 261: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259: - return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); case 262: + return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); + case 265: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263: + case 266: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264: + case 267: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265: + case 268: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 266: + case 269: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267: + case 270: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268: + case 271: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269: + case 272: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); - case 270: + case 273: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271: + case 274: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272: + case 275: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 273: + case 276: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 274: + case 277: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 302: + case 305: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303: + case 306: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -50045,16 +50728,16 @@ var ts; if ((kind > 0 && kind <= 145)) { return initial; } - if ((kind >= 161 && kind <= 178)) { + if ((kind >= 161 && kind <= 180)) { return initial; } var result = initial; switch (node.kind) { - case 212: case 215: - case 206: - case 231: - case 301: + case 218: + case 208: + case 234: + case 304: break; case 146: result = reduceNode(node.left, cbNode, result); @@ -50116,48 +50799,48 @@ var ts; result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 180: - case 181: + case 182: + case 183: result = reduceNodes(node.elements, cbNodes, result); break; - case 182: + case 184: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 183: + case 185: result = reduceNodes(node.elements, cbNodes, result); break; - case 184: + case 186: result = reduceNodes(node.properties, cbNodes, result); break; - case 185: + case 187: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186: + case 188: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187: + case 189: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188: + case 190: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189: + case 191: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190: + case 192: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192: + case 194: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -50165,121 +50848,121 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193: + case 195: 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 191: - case 194: - case 195: + case 193: case 196: case 197: - case 203: - case 204: - case 209: - result = reduceNode(node.expression, cbNode, result); - break; case 198: case 199: - result = reduceNode(node.operand, cbNode, result); + case 205: + case 206: + case 211: + result = reduceNode(node.expression, cbNode, result); break; case 200: + case 201: + result = reduceNode(node.operand, cbNode, result); + break; + case 202: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201: + case 203: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202: + case 204: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205: + case 207: 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 207: + case 209: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208: + case 210: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; - case 211: + case 214: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 213: + case 216: result = reduceNodes(node.statements, cbNodes, result); break; - case 214: + case 217: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216: + case 219: result = reduceNode(node.expression, cbNode, result); break; - case 217: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218: + case 221: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219: - case 226: + case 222: + case 229: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220: + case 223: 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 221: - case 222: + case 224: + case 225: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225: - case 229: + case 228: + case 232: result = reduceNode(node.expression, cbNode, result); break; - case 227: + case 230: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228: + case 231: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230: + case 233: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232: + case 235: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233: + case 236: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234: + case 237: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -50288,7 +50971,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235: + case 238: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -50296,131 +50979,131 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238: + case 241: 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 239: + case 242: 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 240: + case 243: result = reduceNodes(node.statements, cbNodes, result); break; - case 241: + case 244: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243: + case 246: 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 244: + case 247: 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 245: + case 248: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246: + case 249: result = reduceNode(node.name, cbNode, result); break; - case 247: - case 251: + case 250: + case 254: result = reduceNodes(node.elements, cbNodes, result); break; - case 248: - case 252: + case 251: + case 255: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249: + case 252: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250: + case 253: 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 254: + case 257: result = reduceNode(node.expression, cbNode, result); break; - case 255: + case 258: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259: + case 262: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256: - case 257: + case 259: + case 260: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263: + case 266: result = reduceNodes(node.properties, cbNodes, result); break; - case 258: + case 261: result = reduceNode(node.tagName, cbNode, result); break; - case 262: + case 265: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264: + case 267: result = reduceNode(node.expression, cbNode, result); break; - case 265: + case 268: result = reduceNode(node.expression, cbNode, result); break; - case 266: + case 269: result = reduceNode(node.expression, cbNode, result); - case 267: + case 270: result = reduceNodes(node.statements, cbNodes, result); break; - case 268: + case 271: result = reduceNodes(node.types, cbNodes, result); break; - case 269: + case 272: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 270: + case 273: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271: + case 274: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272: + case 275: result = reduceNode(node.expression, cbNode, result); break; - case 273: + case 276: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 274: + case 277: result = reduceNodes(node.statements, cbNodes, result); break; - case 302: + case 305: result = reduceNode(node.expression, cbNode, result); break; - case 303: + case 306: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -50473,7 +51156,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 207)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 209)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -50700,7 +51383,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -50817,7 +51499,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -50861,16 +51543,16 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244: + case 247: externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243: - if (node.moduleReference.kind === 254) { + case 246: + if (node.moduleReference.kind === 257) { externalImports.push(node); } break; - case 250: + case 253: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -50897,12 +51579,12 @@ var ts; } } break; - case 249: + case 252: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 214: + case 217: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -50910,7 +51592,7 @@ var ts; } } break; - case 234: + case 237: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -50928,7 +51610,7 @@ var ts; } } break; - case 235: + case 238: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -51373,12 +52055,13 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185); - context.enableSubstitution(186); + context.enableSubstitution(187); + context.enableSubstitution(188); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; var enabledSubstitutions; var classAliases; @@ -51386,14 +52069,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275) { + if (node.kind === 278) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277) { + if (prepend.kind === 280) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -51410,27 +52093,30 @@ var ts; return visited; } function saveStateAndInvoke(node, f) { - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; onBeforeVisitNode(node); var visited = f(node); - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } function onBeforeVisitNode(node) { switch (node.kind) { - case 274: - case 241: - case 240: - case 213: - currentScope = node; + case 277: + case 244: + case 243: + case 216: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235: - case 234: + case 238: + case 237: if (ts.hasModifier(node, 2)) { break; } @@ -51438,7 +52124,10 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 235 || ts.hasModifier(node, 512)); + ts.Debug.assert(node.kind === 238 || ts.hasModifier(node, 512)); + } + if (ts.isClassDeclaration(node)) { + currentNameScope = node; } break; } @@ -51460,10 +52149,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244: - case 243: - case 249: - case 250: + case 247: + case 246: + case 252: + case 253: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -51478,13 +52167,13 @@ var ts; return node; } switch (node.kind) { - case 244: + case 247: return visitImportDeclaration(node); - case 243: + case 246: return visitImportEqualsDeclaration(node); - case 249: + case 252: return visitExportAssignment(node); - case 250: + case 253: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -51494,11 +52183,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 250 || - node.kind === 244 || - node.kind === 245 || - (node.kind === 243 && - node.moduleReference.kind === 254)) { + if (node.kind === 253 || + node.kind === 247 || + node.kind === 248 || + (node.kind === 246 && + node.moduleReference.kind === 257)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -51522,7 +52211,7 @@ var ts; case 157: case 154: return visitorWorker(node); - case 212: + case 215: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -51554,6 +52243,8 @@ var ts; case 132: case 167: case 168: + case 169: + case 170: case 166: case 161: case 148: @@ -51569,34 +52260,34 @@ var ts; case 163: case 165: case 162: - case 169: - case 170: case 171: + case 172: case 173: - case 174: case 175: case 176: case 177: case 178: + case 179: + case 180: case 160: case 150: - case 237: + case 240: return undefined; case 152: return visitPropertyDeclaration(node); - case 242: + case 245: return undefined; case 155: return visitConstructor(node); - case 236: + case 239: return ts.createNotEmittedStatement(node); - case 235: + case 238: return visitClassDeclaration(node); - case 205: + case 207: return visitClassExpression(node); - case 268: + case 271: return visitHeritageClause(node); - case 207: + case 209: return visitExpressionWithTypeArguments(node); case 154: return visitMethodDeclaration(node); @@ -51604,36 +52295,36 @@ var ts; return visitGetAccessor(node); case 157: return visitSetAccessor(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); - case 193: + case 195: return visitArrowFunction(node); case 149: return visitParameter(node); - case 191: + case 193: return visitParenthesizedExpression(node); - case 190: - case 208: + case 192: + case 210: return visitAssertionExpression(node); - case 187: + case 189: return visitCallExpression(node); - case 188: + case 190: return visitNewExpression(node); - case 189: + case 191: return visitTaggedTemplateExpression(node); - case 209: + case 211: return visitNonNullExpression(node); - case 238: + case 241: return visitEnumDeclaration(node); - case 214: + case 217: return visitVariableStatement(node); - case 232: + case 235: return visitVariableDeclaration(node); - case 239: + case 242: return visitModuleDeclaration(node); - case 243: + case 246: return visitImportEqualsDeclaration(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -51662,7 +52353,7 @@ var ts; var facts = 0; if (ts.some(staticProperties)) facts |= 1; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95) facts |= 64; if (shouldEmitDecorateCallForClass(node)) @@ -51693,7 +52384,7 @@ var ts; : createClassDeclarationHeadWithoutDecorators(node, name, facts); var statements = [classStatement]; if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; if (facts & 1) { @@ -51836,7 +52527,7 @@ var ts; ts.addRange(statements, ts.map(propertyAssignments, transformParameterWithPropertyAssignment)); } else if (isDerivedClass) { - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } var properties = getInitializedProperties(node, false); addInitializedPropertyStatements(statements, properties, ts.createThis()); @@ -51854,7 +52545,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -51876,7 +52567,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536)); } function getInitializedProperties(node, isStatic) { return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); @@ -51895,7 +52586,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -52058,7 +52749,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } function generateConstructorDecorationExpression(node) { @@ -52141,8 +52832,8 @@ var ts; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235: - case 205: + case 238: + case 207: return ts.getFirstConstructorWithBody(node) !== undefined; case 154: case 156: @@ -52159,8 +52850,8 @@ var ts; return serializeTypeNode(node.type); case 157: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235: - case 205: + case 238: + case 207: case 154: return ts.createIdentifier("Function"); default: @@ -52220,7 +52911,7 @@ var ts; case 95: case 131: return ts.createVoidZero(); - case 173: + case 175: return serializeTypeNode(node.type); case 163: case 164: @@ -52235,7 +52926,7 @@ var ts; return ts.createIdentifier("String"); case 135: return ts.createIdentifier("Object"); - case 178: + case 180: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -52255,18 +52946,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162: return serializeTypeReferenceNode(node); - case 170: - case 169: + case 172: + case 171: return serializeUnionOrIntersectionType(node); case 165: - case 175: - case 176: case 177: + case 178: + case 179: case 166: case 119: case 142: - case 174: - case 179: + case 176: + case 181: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -52277,7 +52968,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173) { + while (typeNode.kind === 175) { typeNode = typeNode.type; } if (typeNode.kind === 131) { @@ -52304,7 +52995,7 @@ var ts; return serializedUnion || ts.createVoidZero(); } function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, true); @@ -52342,7 +53033,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); + name.parent = ts.getParseTreeNode(currentLexicalScope); if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -52516,7 +53207,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -52563,7 +53254,7 @@ var ts; return ts.updateTaggedTemplate(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression)); } function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -52574,7 +53265,7 @@ var ts; var statements = []; var emitFlags = 2; if (addVarForEnumOrModuleDeclaration(statements, node)) { - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512; } } @@ -52588,7 +53279,7 @@ 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])); + var enumStatement = ts.createExpressionStatement(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); @@ -52614,7 +53305,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } function transformEnumMemberDeclarationValue(member) { var value = resolver.getConstantValue(member); @@ -52664,11 +53355,11 @@ var ts; function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, false, true)) - ], currentScope.kind === 274 ? 0 : 1)); + ], currentLexicalScope.kind === 277 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 238) { + if (node.kind === 241) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -52695,7 +53386,7 @@ var ts; var statements = []; var emitFlags = 2; if (addVarForEnumOrModuleDeclaration(statements, node)) { - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512; } } @@ -52709,7 +53400,7 @@ 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])); + var moduleStatement = ts.createExpressionStatement(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); @@ -52729,7 +53420,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240) { + if (body.kind === 243) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -52753,13 +53444,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 240) { + if (body.kind !== 243) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239) { + if (moduleDeclaration.body.kind === 242) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -52779,7 +53470,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 246) { + if (node.kind === 249) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -52854,17 +53545,17 @@ var ts; && ts.hasModifier(node, 512); } function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -52914,15 +53605,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(71); - context.enableSubstitution(271); - context.enableEmitNotification(239); + context.enableSubstitution(274); + context.enableEmitNotification(242); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239; + return ts.getOriginalNode(node).kind === 242; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238; + return ts.getOriginalNode(node).kind === 241; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -52968,9 +53659,9 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 185: + case 187: return substitutePropertyAccessExpression(node); - case 186: + case 188: return substituteElementAccessExpression(node); } return node; @@ -53000,9 +53691,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 274) { - var substitute = (applicableSubstitutions & 2 && container.kind === 239) || - (applicableSubstitutions & 8 && container.kind === 238); + if (container && container.kind !== 277) { + var substitute = (applicableSubstitutions & 2 && container.kind === 242) || + (applicableSubstitutions & 8 && container.kind === 241); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -53115,15 +53806,15 @@ var ts; switch (node.kind) { case 120: return undefined; - case 197: + case 199: return visitAwaitExpression(node); case 154: return visitMethodDeclaration(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); - case 193: + case 195: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -53132,27 +53823,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214: + case 217: return visitVariableStatementInAsyncBody(node); - case 220: + case 223: return visitForStatementInAsyncBody(node); - case 221: + case 224: return visitForInStatementInAsyncBody(node); - case 222: + case 225: return visitForOfStatementInAsyncBody(node); - case 269: + case 272: return visitCatchClauseInAsyncBody(node); - case 213: - case 227: - case 241: - case 266: - case 267: + case 216: case 230: - case 218: - case 219: - case 217: - case 226: - case 228: + case 244: + case 269: + case 270: + case 233: + case 221: + case 222: + case 220: + case 229: + case 231: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -53186,7 +53877,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -53301,7 +53992,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 193; + var isArrowFunction = node.kind === 195; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap(); @@ -53365,10 +54056,10 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; + context.enableSubstitution(189); context.enableSubstitution(187); - context.enableSubstitution(185); - context.enableSubstitution(186); - context.enableEmitNotification(235); + context.enableSubstitution(188); + context.enableEmitNotification(238); context.enableEmitNotification(154); context.enableEmitNotification(156); context.enableEmitNotification(157); @@ -53397,11 +54088,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185: + case 187: return substitutePropertyAccessExpression(node); - case 186: + case 188: return substituteElementAccessExpression(node); - case 187: + case 189: return substituteCallExpression(node); } return node; @@ -53432,7 +54123,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 + return kind === 238 || kind === 155 || kind === 154 || kind === 156 @@ -53516,25 +54207,25 @@ var ts; return node; } switch (node.kind) { - case 197: + case 199: return visitAwaitExpression(node); - case 203: + case 205: return visitYieldExpression(node); - case 225: - return visitReturnStatement(node); case 228: + return visitReturnStatement(node); + case 231: return visitLabeledStatement(node); - case 184: + case 186: return visitObjectLiteralExpression(node); - case 200: + case 202: return visitBinaryExpression(node, noDestructuringValue); - case 232: + case 235: return visitVariableDeclaration(node); - case 222: + case 225: return visitForOfStatement(node, undefined); - case 220: + case 223: return visitForStatement(node); - case 196: + case 198: return visitVoidExpression(node); case 155: return visitConstructorDeclaration(node); @@ -53544,19 +54235,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157: return visitSetAccessorDeclaration(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); - case 193: + case 195: return visitArrowFunction(node); case 149: return visitParameter(node); - case 216: + case 219: return visitExpressionStatement(node); - case 191: + case 193: return visitParenthesizedExpression(node, noDestructuringValue); - case 269: + case 272: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -53589,7 +54280,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 && statement.awaitModifier) { + if (statement.kind === 225 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -53601,7 +54292,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 272) { + if (e.kind === 275) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -53610,7 +54301,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 + chunkObject = ts.append(chunkObject, e.kind === 273 ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -53623,7 +54314,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 184) { + if (objects.length && objects[0].kind !== 186) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -53739,12 +54430,12 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1)), ts.createBlock([ ts.createTry(ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1) ]), undefined, ts.setEmitFlags(ts.createBlock([ ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) ]), 1)) @@ -53879,10 +54570,10 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; + context.enableSubstitution(189); context.enableSubstitution(187); - context.enableSubstitution(185); - context.enableSubstitution(186); - context.enableEmitNotification(235); + context.enableSubstitution(188); + context.enableEmitNotification(238); context.enableEmitNotification(154); context.enableEmitNotification(156); context.enableEmitNotification(157); @@ -53911,11 +54602,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185: + case 187: return substitutePropertyAccessExpression(node); - case 186: + case 188: return substituteElementAccessExpression(node); - case 187: + case 189: return substituteCallExpression(node); } return node; @@ -53946,7 +54637,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 + return kind === 238 || kind === 155 || kind === 154 || kind === 156 @@ -54045,13 +54736,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255: + case 258: return visitJsxElement(node, false); - case 256: - return visitJsxSelfClosingElement(node, false); case 259: + return visitJsxSelfClosingElement(node, false); + case 262: return visitJsxFragment(node, false); - case 265: + case 268: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -54061,13 +54752,13 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 265: + case 268: return visitJsxExpression(node); - case 255: + case 258: return visitJsxElement(node, true); - case 256: - return visitJsxSelfClosingElement(node, true); case 259: + return visitJsxSelfClosingElement(node, true); + case 262: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -54131,7 +54822,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265) { + else if (node.kind === 268) { if (node.expression === undefined) { return ts.createTrue(); } @@ -54191,7 +54882,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255) { + if (node.kind === 258) { return getTagName(node.openingElement); } else { @@ -54491,7 +55182,7 @@ var ts; return node; } switch (node.kind) { - case 200: + case 202: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -54581,13 +55272,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096) !== 0 - && node.kind === 225 + && node.kind === 228 && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 213))) + || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 216))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432) !== 0; } @@ -54615,63 +55306,63 @@ var ts; switch (node.kind) { case 115: return undefined; - case 235: + case 238: return visitClassDeclaration(node); - case 205: + case 207: return visitClassExpression(node); case 149: return visitParameter(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 193: + case 195: return visitArrowFunction(node); - case 192: + case 194: return visitFunctionExpression(node); - case 232: + case 235: return visitVariableDeclaration(node); case 71: return visitIdentifier(node); - case 233: + case 236: return visitVariableDeclarationList(node); - case 227: + case 230: return visitSwitchStatement(node); - case 241: + case 244: return visitCaseBlock(node); - case 213: + case 216: return visitBlock(node, false); - case 224: - case 223: + case 227: + case 226: return visitBreakOrContinueStatement(node); - case 228: + case 231: return visitLabeledStatement(node); - case 218: - case 219: + case 221: + case 222: return visitDoOrWhileStatement(node, undefined); - case 220: + case 223: return visitForStatement(node, undefined); - case 221: + case 224: return visitForInStatement(node, undefined); - case 222: + case 225: return visitForOfStatement(node, undefined); - case 216: + case 219: return visitExpressionStatement(node); - case 184: + case 186: return visitObjectLiteralExpression(node); - case 269: + case 272: return visitCatchClause(node); - case 271: + case 274: return visitShorthandPropertyAssignment(node); case 147: return visitComputedPropertyName(node); - case 183: + case 185: return visitArrayLiteralExpression(node); - case 187: + case 189: return visitCallExpression(node); - case 188: + case 190: return visitNewExpression(node); - case 191: + case 193: return visitParenthesizedExpression(node, true); - case 200: + case 202: return visitBinaryExpression(node, true); case 13: case 14: @@ -54682,28 +55373,28 @@ var ts; return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 189: + case 191: return visitTaggedTemplateExpression(node); - case 202: + case 204: return visitTemplateExpression(node); - case 203: + case 205: return visitYieldExpression(node); - case 204: + case 206: return visitSpreadElement(node); case 97: return visitSuperKeyword(false); case 99: return visitThisKeyword(node); - case 210: + case 212: return visitMetaProperty(node); case 154: return visitMethodDeclaration(node); case 156: case 157: return visitAccessorDeclaration(node); - case 214: + case 217: return visitVariableStatement(node); - case 225: + case 228: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -54784,14 +55475,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 224 ? 2 : 4; + var jump = node.kind === 227 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224) { + if (node.kind === 227) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -54801,7 +55492,7 @@ var ts; } } else { - if (node.kind === 224) { + if (node.kind === 227) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } @@ -54860,7 +55551,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, ts.createFileLevelUniqueName("_super"))] : [], undefined, transformClassBody(node, extendsClauseElement)); ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288); var inner = ts.createPartiallyEmittedExpression(classFunction); @@ -54897,7 +55588,7 @@ var ts; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), extendsClauseElement)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { @@ -54965,17 +55656,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 225) { + if (statement.kind === 228) { return true; } - else if (statement.kind === 217) { + else if (statement.kind === 220) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 213) { + else if (statement.kind === 216) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -55004,7 +55695,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -55012,8 +55703,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 - || superCallExpression.left.kind !== 187) { + if (superCallExpression.kind !== 202 + || superCallExpression.left.kind !== 189) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -55073,13 +55764,13 @@ var ts; statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 1048576)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576)); } } 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.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536)) ]), parameter), 1 | 32 | 384 | 1536)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -55105,7 +55796,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) ]), 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 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); @@ -55114,7 +55805,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 193) { + if (node.transformFlags & 32768 && node.kind !== 195) { captureThisForNode(statements, node, ts.createThis()); } } @@ -55132,7 +55823,7 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 193: + case 195: return statements; case 154: case 156: @@ -55142,8 +55833,8 @@ var ts; case 155: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 234: - case 192: + case 237: + case 194: newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 93, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: @@ -55163,7 +55854,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212: + case 215: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154: @@ -55195,7 +55886,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), member); + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); @@ -55203,7 +55894,7 @@ var ts; return statement; } function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, false)); + var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false)); ts.setEmitFlags(statement, 1536); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; @@ -55301,7 +55992,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 234 || node.kind === 192)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 237 || node.kind === 194)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -55333,7 +56024,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193); + ts.Debug.assert(node.kind === 195); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -55386,19 +56077,19 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 191: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 200: - return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); + case 193: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false)); + case 202: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); } function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 191: + case 193: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 200: + case 202: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -55431,7 +56122,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { updated = undefined; @@ -55523,14 +56214,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218: - case 219: + case 221: + case 222: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220: + case 223: return visitForStatement(node, outermostLabeledStatement); - case 221: + case 224: return visitForInStatement(node, outermostLabeledStatement); - case 222: + case 225: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -55577,11 +56268,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -55632,12 +56323,12 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1)), ts.createBlock([ ts.createTry(ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1), ]), undefined, ts.setEmitFlags(ts.createBlock([ ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) ]), 1)) @@ -55716,11 +56407,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220: - case 221: - case 222: + case 223: + case 224: + case 225: var initializer = node.initializer; - if (initializer && initializer.kind === 233) { + if (initializer && initializer.kind === 236) { loopInitializer = initializer; } break; @@ -55846,7 +56537,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -55860,7 +56551,7 @@ var ts; ? ts.createYield(ts.createToken(39), ts.setEmitFlags(call, 8388608)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); } else { @@ -55956,10 +56647,10 @@ var ts; case 154: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270: + case 273: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271: + case 274: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -56095,7 +56786,7 @@ var ts; } statements.push(funcStatements[classBodyStart]); classBodyStart++; - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { classBodyEnd--; @@ -56165,7 +56856,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -56315,9 +57006,9 @@ var ts; context.enableEmitNotification(154); context.enableEmitNotification(156); context.enableEmitNotification(157); - context.enableEmitNotification(193); - context.enableEmitNotification(192); - context.enableEmitNotification(234); + context.enableEmitNotification(195); + context.enableEmitNotification(194); + context.enableEmitNotification(237); } } function onSubstituteNode(hint, node) { @@ -56341,10 +57032,10 @@ var ts; } function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182: - case 235: + case 184: case 238: - case 232: + case 241: + case 235: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -56405,11 +57096,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189) { return false; } var callTarget = statementExpression.expression; @@ -56417,7 +57108,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206) { return false; } var expression = callArgument.expression; @@ -56461,24 +57152,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257); - context.enableEmitNotification(258); - context.enableEmitNotification(256); + context.enableEmitNotification(260); + context.enableEmitNotification(261); + context.enableEmitNotification(259); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185); - context.enableSubstitution(270); + context.enableSubstitution(187); + context.enableSubstitution(273); return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257: - case 258: - case 256: + case 260: + case 261: + case 259: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -56595,13 +57286,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218: + case 221: return visitDoStatement(node); - case 219: + case 222: return visitWhileStatement(node); - case 227: + case 230: return visitSwitchStatement(node); - case 228: + case 231: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -56609,24 +57300,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); case 156: case 157: return visitAccessorDeclaration(node); - case 214: + case 217: return visitVariableStatement(node); - case 220: + case 223: return visitForStatement(node); - case 221: - return visitForInStatement(node); case 224: + return visitForInStatement(node); + case 227: return visitBreakStatement(node); - case 223: + case 226: return visitContinueStatement(node); - case 225: + case 228: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -56642,21 +57333,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200: + case 202: return visitBinaryExpression(node); - case 201: - return visitConditionalExpression(node); case 203: + return visitConditionalExpression(node); + case 205: return visitYieldExpression(node); - case 183: + case 185: return visitArrayLiteralExpression(node); - case 184: - return visitObjectLiteralExpression(node); case 186: + return visitObjectLiteralExpression(node); + case 188: return visitElementAccessExpression(node); - case 187: + case 189: return visitCallExpression(node); - case 188: + case 190: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -56664,9 +57355,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 234: + case 237: return visitFunctionDeclaration(node); - case 192: + case 194: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -56784,7 +57475,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } function visitBinaryExpression(node) { @@ -56823,10 +57514,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185: + case 187: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186: + case 188: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -56884,7 +57575,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -56965,7 +57656,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -57027,35 +57718,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213: - return transformAndEmitBlock(node); case 216: + return transformAndEmitBlock(node); + case 219: return transformAndEmitExpressionStatement(node); - case 217: + case 220: return transformAndEmitIfStatement(node); - case 218: + case 221: return transformAndEmitDoStatement(node); - case 219: + case 222: return transformAndEmitWhileStatement(node); - case 220: + case 223: return transformAndEmitForStatement(node); - case 221: + case 224: return transformAndEmitForInStatement(node); - case 223: + case 226: return transformAndEmitContinueStatement(node); - case 224: + case 227: return transformAndEmitBreakStatement(node); - case 225: + case 228: return transformAndEmitReturnStatement(node); - case 226: + case 229: return transformAndEmitWithStatement(node); - case 227: + case 230: return transformAndEmitSwitchStatement(node); - case 228: + case 231: return transformAndEmitLabeledStatement(node); - case 229: + case 232: return transformAndEmitThrowStatement(node); - case 230: + case 233: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -57092,7 +57783,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -57186,7 +57877,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -57196,7 +57887,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -57236,7 +57927,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), undefined, [key])))); + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); var incrementLabel = defineLabel(); @@ -57258,7 +57949,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -57349,7 +58040,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 && defaultClauseIndex === -1) { + if (clause.kind === 270 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -57359,7 +58050,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266) { + if (clause.kind === 269) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -57948,7 +58639,7 @@ var ts; } if (currentExceptionBlock) { var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), undefined, [ + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), undefined, [ ts.createArrayLiteral([ createLabel(startLabel), createLabel(catchLabel), @@ -57959,7 +58650,7 @@ var ts; currentExceptionBlock = undefined; } if (markLabelEnd) { - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -58089,7 +58780,7 @@ var ts; } } function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } function writeThrow(expression, operationLocation) { lastOperationWasAbrupt = true; @@ -58175,11 +58866,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71); + context.enableSubstitution(202); context.enableSubstitution(200); - context.enableSubstitution(198); - context.enableSubstitution(199); - context.enableSubstitution(271); - context.enableEmitNotification(274); + context.enableSubstitution(201); + context.enableSubstitution(274); + context.enableEmitNotification(277); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -58231,7 +58922,7 @@ var ts; var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ + ts.createExpressionStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") @@ -58256,9 +58947,9 @@ var ts; 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.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(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, (moduleName ? [moduleName] : []).concat([ + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") @@ -58268,7 +58959,7 @@ var ts; ]))) ], true), undefined)); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, undefined, [ + ts.createExpressionStatement(ts.createCall(umdHeader, undefined, [ ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(undefined, undefined, undefined, "require"), ts.createParameter(undefined, undefined, undefined, "exports") @@ -58318,7 +59009,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); @@ -58354,7 +59045,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536); statements.push(statement); @@ -58364,23 +59055,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 244: + case 247: return visitImportDeclaration(node); - case 243: + case 246: return visitImportEqualsDeclaration(node); - case 250: + case 253: return visitExportDeclaration(node); - case 249: + case 252: return visitExportAssignment(node); - case 214: + case 217: return visitVariableStatement(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 235: + case 238: return visitClassDeclaration(node); - case 304: + case 307: return visitMergeDeclarationMarker(node); - case 305: + case 308: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -58405,17 +59096,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270: + case 273: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271: + case 274: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272: + case 275: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -58484,7 +59175,7 @@ var ts; ts.createParameter(undefined, undefined, undefined, reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; if (languageVersion >= 2) { @@ -58541,7 +59232,7 @@ var ts; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -58584,7 +59275,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ @@ -58594,7 +59285,7 @@ var ts; } else { if (ts.hasModifier(node, 1)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -58621,12 +59312,12 @@ var ts; 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)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } function visitExportAssignment(node) { @@ -58700,7 +59391,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -58737,7 +59428,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -58769,10 +59460,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246: + case 249: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247: + case 250: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -58846,10 +59537,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), ts.createObjectLiteral([ @@ -58861,7 +59552,7 @@ var ts; return statement; } function createExportStatement(name, value, location, allowComments) { - var statement = ts.setTextRange(ts.createStatement(createExportExpression(name, value)), location); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536); @@ -58880,7 +59571,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274) { + if (node.kind === 277) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -58922,10 +59613,10 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 200: + case 202: return substituteBinaryExpression(node); - case 199: - case 198: + case 201: + case 200: return substituteUnaryExpression(node); } return node; @@ -58940,7 +59631,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274) { + if (exportContainer && exportContainer.kind === 277) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -58983,7 +59674,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 + var expression = node.kind === 201 ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 ? 59 : 60), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -59047,11 +59738,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71); - context.enableSubstitution(271); + context.enableSubstitution(274); + context.enableSubstitution(202); context.enableSubstitution(200); - context.enableSubstitution(198); - context.enableSubstitution(199); - context.enableEmitNotification(274); + context.enableSubstitution(201); + context.enableEmitNotification(277); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -59084,7 +59775,7 @@ var ts; 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.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) ]), node.statements)), 1024); @@ -59155,7 +59846,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 && externalImport.exportClause) { + if (externalImport.kind === 253 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -59178,7 +59869,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250) { + if (externalImport.kind !== 253) { continue; } if (!externalImport.exportClause) { @@ -59213,9 +59904,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), - ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) + ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [exports])) ], true)); } function createSettersArray(exportStarFunction, dependencyGroups) { @@ -59229,15 +59920,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 244: + case 247: if (!entry.importClause) { break; } - case 243: + case 246: ts.Debug.assert(importVariableName !== undefined); - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250: + case 253: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -59245,10 +59936,10 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)]))); } else { - statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); } break; } @@ -59259,13 +59950,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 244: + case 247: return visitImportDeclaration(node); - case 243: + case 246: return visitImportEqualsDeclaration(node); - case 250: + case 253: return undefined; - case 249: + case 252: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -59332,7 +60023,7 @@ var ts; var statements; var name = ts.getLocalName(node); hoistVariableDeclaration(name); - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); @@ -59360,7 +60051,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { var id = ts.getOriginalNodeId(node); @@ -59386,7 +60077,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 274 + && (enclosingBlockScopedContainer.kind === 277 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -59408,7 +60099,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -59447,10 +60138,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246: + case 249: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247: + case 250: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -59536,7 +60227,7 @@ var ts; return statements; } function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536); @@ -59550,43 +60241,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 214: + case 217: return visitVariableStatement(node); - case 234: + case 237: return visitFunctionDeclaration(node); - case 235: + case 238: return visitClassDeclaration(node); - case 220: + case 223: return visitForStatement(node); - case 221: + case 224: return visitForInStatement(node); - case 222: + case 225: return visitForOfStatement(node); - case 218: + case 221: return visitDoStatement(node); - case 219: + case 222: return visitWhileStatement(node); - case 228: + case 231: return visitLabeledStatement(node); - case 226: + case 229: return visitWithStatement(node); - case 227: + case 230: return visitSwitchStatement(node); - case 241: + case 244: return visitCaseBlock(node); - case 266: + case 269: return visitCaseClause(node); - case 267: + case 270: return visitDefaultClause(node); - case 230: + case 233: return visitTryStatement(node); - case 269: + case 272: return visitCatchClause(node); - case 213: + case 216: return visitBlock(node); - case 304: + case 307: return visitMergeDeclarationMarker(node); - case 305: + case 308: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -59680,7 +60371,7 @@ var ts; } function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 200) { + && node.kind === 202) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -59723,7 +60414,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274; + return container !== undefined && container.kind === 277; } else { return false; @@ -59738,7 +60429,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274) { + if (node.kind === 277) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -59772,7 +60463,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 271: + case 274: return substituteShorthandPropertyAssignment(node); } return node; @@ -59796,10 +60487,10 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 200: + case 202: return substituteBinaryExpression(node); - case 198: - case 199: + case 200: + case 201: return substituteUnaryExpression(node); } return node; @@ -59851,14 +60542,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 + var expression = node.kind === 201 ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 199) { + if (node.kind === 201) { expression = node.operator === 43 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -59875,7 +60566,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 274) { + if (exportContainer && exportContainer.kind === 277) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -59903,7 +60594,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274); + context.enableEmitNotification(277); context.enableSubstitution(71); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -59930,9 +60621,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243: + case 246: return undefined; - case 249: + case 252: return visitExportAssignment(node); } return node; @@ -60018,7 +60709,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 === 235) { + else if (node.parent.kind === 238) { 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 : @@ -60047,7 +60738,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 235) { + else if (node.parent.kind === 238) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -60094,7 +60785,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 232 || node.kind === 182) { + if (node.kind === 235 || node.kind === 184) { 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 : @@ -60110,7 +60801,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 === 235 || node.kind === 149) { + else if (node.parent.kind === 238 || node.kind === 149) { 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 : @@ -60195,7 +60886,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 === 235) { + else if (node.parent.kind === 238) { 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 : @@ -60208,7 +60899,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234: + case 237: 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 : @@ -60261,7 +60952,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 === 235) { + else if (node.parent.parent.kind === 238) { 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 : @@ -60273,7 +60964,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 234: + case 237: case 163: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -60287,10 +60978,10 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 235: + case 238: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236: + case 239: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159: @@ -60304,17 +60995,17 @@ var ts; 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 === 235) { + else if (node.parent.parent.kind === 238) { 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 234: + case 237: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237: + case 240: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -60328,7 +61019,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 235) { + if (node.parent.parent.kind === 238) { diagnosticMessage = node.parent.token === 108 ? 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; @@ -60416,7 +61107,11 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -60468,10 +61163,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275) { + if (node.kind === 278) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -60499,7 +61194,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277) { + if (prepend.kind === 280) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -60594,7 +61289,7 @@ var ts; return name; } else { - if (name.kind === 181) { + if (name.kind === 183) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -60602,7 +61297,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206) { + if (elem.kind === 208) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -60654,7 +61349,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 || node.kind === 182) { + if (node.kind === 235 || node.kind === 184) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 @@ -60676,19 +61371,19 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234: - case 239: - case 236: - case 235: case 237: + case 242: + case 239: case 238: + case 240: + case 241: return !resolver.isDeclarationVisible(node); - case 232: + case 235: return !getBindingNameVisible(node); - case 243: - case 244: - case 250: - case 249: + case 246: + case 247: + case 253: + case 252: return false; } return false; @@ -60741,7 +61436,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 && parent.kind !== 179); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 && parent.kind !== 181); if (input.kind === 9 && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -60753,7 +61448,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254) { + if (decl.moduleReference.kind === 257) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -60773,7 +61468,7 @@ var ts; if (!decl.importClause.namedBindings) { return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 246) { + if (decl.importClause.namedBindings.kind === 249) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; } @@ -60853,13 +61548,13 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 || input.kind === 177) && input.parent.kind !== 237); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 || input.kind === 179) && input.parent.kind !== 240); if (shouldEnterSuppressNewDiagnosticsContextContext) { suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 207: { + case 209: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -60907,7 +61602,7 @@ var ts; case 160: { return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119))); } - case 232: { + case 235: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -60921,7 +61616,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171: { + case 173: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -60937,7 +61632,7 @@ var ts; case 164: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179: { + case 181: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -60975,14 +61670,14 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250: { + case 253: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; } return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249: { + case 252: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -61010,10 +61705,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243: { + case 246: { return transformImportEqualsDeclaration(input); } - case 244: { + case 247: { return transformImportDeclaration(input); } } @@ -61033,18 +61728,18 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237: + case 240: return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 236: { + case 239: { return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 234: { + case 237: { return cleanup(ts.updateFunctionDeclaration(input, undefined, ensureModifiers(input, isPrivate), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); } - case 239: { + case 242: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240) { + if (inner && inner.kind === 243) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -61062,7 +61757,7 @@ var ts; return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 235: { + case 238: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -61097,7 +61792,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95) { var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); getSymbolAccessibilityDiagnostic = function () { return ({ @@ -61124,10 +61819,10 @@ var ts; return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214: { + case 217: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238: { + case 241: { return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -61144,7 +61839,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239) { + if (input.kind === 242) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -61165,7 +61860,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206) { + if (e.kind === 208) { return; } if (e.name) { @@ -61219,7 +61914,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 274; + var parentIsFile = node.parent.kind === 277; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1) | 512 | 2); additions = 0; @@ -61239,7 +61934,7 @@ var ts; var prop = ts.createProperty(undefined, maskModifiers(node, undefined, (!accessors.setAccessor) ? 64 : 0), node.name, node.questionToken, ensureType(node, accessorType), undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -61253,7 +61948,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -61266,7 +61961,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236) { + if (node.kind === 239) { return true; } return false; @@ -61294,7 +61989,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232: + case 235: case 152: case 151: case 149: @@ -61304,17 +61999,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 234: - case 239: - case 243: - case 236: - case 235: case 237: + case 242: + case 246: + case 239: case 238: - case 214: - case 244: - case 250: - case 249: + case 240: + case 241: + case 217: + case 247: + case 253: + case 252: return true; } return false; @@ -61331,14 +62026,14 @@ var ts; case 153: case 158: case 160: - case 232: + case 235: case 148: - case 207: + case 209: case 162: - case 171: + case 173: case 163: case 164: - case 179: + case 181: return true; } return false; @@ -61389,7 +62084,7 @@ var ts; } ts.getTransformers = getTransformers; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(306); + var enabledSyntaxKindFeatures = new Array(309); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -61647,7 +62342,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47) { @@ -61655,7 +62349,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274) { + if (sourceFileOrBundle.kind === 277) { sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { @@ -61727,7 +62421,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } function emitPos(pos) { if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { @@ -61768,6 +62461,7 @@ var ts; return typeof x === "object" && !!x.mappings && typeof x.mappings === "string" && !!x.sources; } function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -61778,43 +62472,48 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, true)); - } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); + } + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 + if (node.kind !== 304 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -61831,7 +62530,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 + if (node.kind !== 304 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -61873,9 +62572,11 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -61974,7 +62675,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301; + var isEmittedNode = node.kind !== 304; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 10; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 10; if (!skipLeadingComments) { @@ -61988,7 +62689,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 233) { + if (node.kind === 236) { declarationListContainerEnd = end; } } @@ -62297,7 +62998,7 @@ var ts; ts.forEachEmittedFile = forEachEmittedFile; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275) { + if (sourceFile.kind === 278) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; @@ -62414,6 +63115,9 @@ var ts; var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -62438,9 +63142,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71) { + resolver.collectLinkedAliases(node.expression, true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -62527,9 +63244,9 @@ var ts; break; } switch (node.kind) { - case 274: return printFile(node); - case 275: return printBundle(node); - case 276: return printUnparsedSource(node); + case 277: return printFile(node); + case 278: return printBundle(node); + case 279: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -62673,7 +63390,7 @@ var ts; } return pipelineEmitWithoutComments; case 2: - if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { + if (onEmitSourceMapOfNode && hint !== 0) { return pipelineEmitWithSourceMap; } case 3: @@ -62698,7 +63415,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 && hint !== 2); + ts.Debug.assert(hint !== 0); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -62716,7 +63433,7 @@ var ts; case 15: case 16: return emitLiteral(node); - case 276: + case 279: return emitUnparsedSource(node); case 71: return emitIdentifier(node); @@ -62755,7 +63472,7 @@ var ts; return emitTypeReference(node); case 163: return emitFunctionType(node); - case 284: + case 287: return emitJSDocFunctionType(node); case 164: return emitConstructorType(node); @@ -62768,168 +63485,171 @@ var ts; case 168: return emitTupleType(node); case 169: + return emitOptionalType(node); + case 171: return emitUnionType(node); - case 170: + case 172: return emitIntersectionType(node); - case 171: + case 173: return emitConditionalType(node); - case 172: + case 174: return emitInferType(node); - case 173: + case 175: return emitParenthesizedType(node); - case 207: + case 209: return emitExpressionWithTypeArguments(node); - case 174: + case 176: return emitThisType(); - case 175: + case 177: return emitTypeOperator(node); - case 176: + case 178: return emitIndexedAccessType(node); - case 177: + case 179: return emitMappedType(node); - case 178: + case 180: return emitLiteralType(node); - case 179: + case 181: return emitImportTypeNode(node); - case 279: + case 282: write("*"); return; - case 280: + case 283: write("?"); return; - case 281: + case 284: return emitJSDocNullableType(node); - case 282: + case 285: return emitJSDocNonNullableType(node); - case 283: + case 286: return emitJSDocOptionalType(node); - case 285: - return emitJSDocVariadicType(node); - case 180: + case 170: + case 288: + return emitRestOrJSDocVariadicType(node); + case 182: return emitObjectBindingPattern(node); - case 181: + case 183: return emitArrayBindingPattern(node); - case 182: + case 184: return emitBindingElement(node); - case 211: + case 214: return emitTemplateSpan(node); - case 212: + case 215: return emitSemicolonClassElement(); - case 213: + case 216: return emitBlock(node); - case 214: + case 217: return emitVariableStatement(node); - case 215: + case 218: return emitEmptyStatement(); - case 216: + case 219: return emitExpressionStatement(node); - case 217: + case 220: return emitIfStatement(node); - case 218: + case 221: return emitDoStatement(node); - case 219: + case 222: return emitWhileStatement(node); - case 220: + case 223: return emitForStatement(node); - case 221: + case 224: return emitForInStatement(node); - case 222: + case 225: return emitForOfStatement(node); - case 223: + case 226: return emitContinueStatement(node); - case 224: + case 227: return emitBreakStatement(node); - case 225: + case 228: return emitReturnStatement(node); - case 226: + case 229: return emitWithStatement(node); - case 227: + case 230: return emitSwitchStatement(node); - case 228: + case 231: return emitLabeledStatement(node); - case 229: + case 232: return emitThrowStatement(node); - case 230: + case 233: return emitTryStatement(node); - case 231: + case 234: return emitDebuggerStatement(node); - case 232: + case 235: return emitVariableDeclaration(node); - case 233: + case 236: return emitVariableDeclarationList(node); - case 234: + case 237: return emitFunctionDeclaration(node); - case 235: + case 238: return emitClassDeclaration(node); - case 236: + case 239: return emitInterfaceDeclaration(node); - case 237: + case 240: return emitTypeAliasDeclaration(node); - case 238: + case 241: return emitEnumDeclaration(node); - case 239: + case 242: return emitModuleDeclaration(node); - case 240: + case 243: return emitModuleBlock(node); - case 241: + case 244: return emitCaseBlock(node); - case 242: + case 245: return emitNamespaceExportDeclaration(node); - case 243: + case 246: return emitImportEqualsDeclaration(node); - case 244: + case 247: return emitImportDeclaration(node); - case 245: + case 248: return emitImportClause(node); - case 246: + case 249: return emitNamespaceImport(node); - case 247: + case 250: return emitNamedImports(node); - case 248: + case 251: return emitImportSpecifier(node); - case 249: + case 252: return emitExportAssignment(node); - case 250: + case 253: return emitExportDeclaration(node); - case 251: + case 254: return emitNamedExports(node); - case 252: + case 255: return emitExportSpecifier(node); - case 253: + case 256: return; - case 254: + case 257: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 257: case 260: + case 263: return emitJsxOpeningElementOrFragment(node); - case 258: case 261: + case 264: return emitJsxClosingElementOrFragment(node); - case 262: + case 265: return emitJsxAttribute(node); - case 263: + case 266: return emitJsxAttributes(node); - case 264: + case 267: return emitJsxSpreadAttribute(node); - case 265: + case 268: return emitJsxExpression(node); - case 266: + case 269: return emitCaseClause(node); - case 267: + case 270: return emitDefaultClause(node); - case 268: + case 271: return emitHeritageClause(node); - case 269: + case 272: return emitCatchClause(node); - case 270: + case 273: return emitPropertyAssignment(node); - case 271: + case 274: return emitShorthandPropertyAssignment(node); - case 272: + case 275: return emitSpreadAssignment(node); - case 273: + case 276: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -62958,69 +63678,69 @@ var ts; case 91: writeTokenNode(node, writeKeyword); return; - case 183: + case 185: return emitArrayLiteralExpression(node); - case 184: + case 186: return emitObjectLiteralExpression(node); - case 185: + case 187: return emitPropertyAccessExpression(node); - case 186: + case 188: return emitElementAccessExpression(node); - case 187: + case 189: return emitCallExpression(node); - case 188: + case 190: return emitNewExpression(node); - case 189: + case 191: return emitTaggedTemplateExpression(node); - case 190: + case 192: return emitTypeAssertionExpression(node); - case 191: + case 193: return emitParenthesizedExpression(node); - case 192: + case 194: return emitFunctionExpression(node); - case 193: + case 195: return emitArrowFunction(node); - case 194: + case 196: return emitDeleteExpression(node); - case 195: + case 197: return emitTypeOfExpression(node); - case 196: + case 198: return emitVoidExpression(node); - case 197: + case 199: return emitAwaitExpression(node); - case 198: + case 200: return emitPrefixUnaryExpression(node); - case 199: + case 201: return emitPostfixUnaryExpression(node); - case 200: + case 202: return emitBinaryExpression(node); - case 201: + case 203: return emitConditionalExpression(node); - case 202: + case 204: return emitTemplateExpression(node); - case 203: + case 205: return emitYieldExpression(node); - case 204: + case 206: return emitSpreadExpression(node); - case 205: + case 207: return emitClassExpression(node); - case 206: - return; case 208: + return; + case 210: return emitAsExpression(node); - case 209: + case 211: return emitNonNullExpression(node); - case 210: + case 212: return emitMetaProperty(node); - case 255: + case 258: return emitJsxElement(node); - case 256: - return emitJsxSelfClosingElement(node); case 259: + return emitJsxSelfClosingElement(node); + case 262: return emitJsxFragment(node); - case 302: + case 305: return emitPartiallyEmittedExpression(node); - case 303: + case 306: return emitCommaList(node); } } @@ -63037,7 +63757,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 ? node : undefined; + var bundle = node.kind === 278 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -63136,7 +63856,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 && !node.name) { + if (node.parent && node.parent.kind === 287 && !node.name) { emit(node.type); } else { @@ -63298,7 +64018,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -63307,6 +64027,10 @@ var ts; emitList(node, node.elementTypes, 272); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260); } @@ -63565,7 +64289,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 198 + return operand.kind === 200 && ((node.operator === 37 && (operand.operator === 37 || operand.operator === 43)) || (node.operator === 38 && (operand.operator === 38 || operand.operator === 44))); } @@ -63679,7 +64403,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217) { + if (node.elseStatement.kind === 220) { writeSpace(); emit(node.elseStatement); } @@ -63750,7 +64474,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233) { + if (node.kind === 236) { emit(node); } else { @@ -63849,7 +64573,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272); } @@ -64035,7 +64759,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239) { + while (body.kind === 242) { writePunctuation("."); emit(body.name); body = body.body; @@ -64890,7 +65614,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -64949,81 +65673,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213: + case 216: ts.forEach(node.statements, generateNames); break; - case 228: - case 226: - case 218: - case 219: + case 231: + case 229: + case 221: + case 222: generateNames(node.statement); break; - case 217: + case 220: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220: - case 222: - case 221: + case 223: + case 225: + case 224: generateNames(node.initializer); generateNames(node.statement); break; - case 227: + case 230: generateNames(node.caseBlock); break; - case 241: + case 244: ts.forEach(node.clauses, generateNames); break; - case 266: - case 267: + case 269: + case 270: ts.forEach(node.statements, generateNames); break; - case 230: + case 233: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269: + case 272: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214: + case 217: generateNames(node.declarationList); break; - case 233: + case 236: ts.forEach(node.declarations, generateNames); break; - case 232: - case 149: - case 182: case 235: + case 149: + case 184: + case 238: generateNameIfNeeded(node.name); break; - case 234: + case 237: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180: - case 181: + case 182: + case 183: ts.forEach(node.elements, generateNames); break; - case 244: + case 247: generateNames(node.importClause); break; - case 245: + case 248: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246: + case 249: generateNameIfNeeded(node.name); break; - case 247: + case 250: ts.forEach(node.elements, generateNames); break; - case 248: + case 251: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -65032,8 +65756,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270: - case 271: + case 273: + case 274: case 152: case 154: case 156: @@ -65171,17 +65895,17 @@ var ts; switch (node.kind) { case 71: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); - case 239: - case 238: + case 242: + case 241: return generateNameForModuleOrEnum(node); - case 244: - case 250: + case 247: + case 253: return generateNameForImportOrExportDeclaration(node); - case 234: - case 235: - case 249: + case 237: + case 238: + case 252: return generateNameForExportDefault(); - case 205: + case 207: return generateNameForClassExpression(); case 154: case 156: @@ -65773,17 +66497,19 @@ var ts; } return context; } - function formatLocation(file, start, host) { + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -65802,11 +66528,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -66398,7 +67124,14 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -66619,51 +67352,51 @@ var ts; case 155: case 156: case 157: - case 192: - case 234: - case 193: - case 232: + case 194: + case 237: + case 195: + case 235: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 243: + case 246: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249: + case 252: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268: + case 271: var heritageClause = node; if (heritageClause.token === 108) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 236: + case 239: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239: + case 242: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237: + case 240: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238: + case 241: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209: + case 211: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208: + case 210: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190: + case 192: ts.Debug.fail(); } var prevParent = parent; @@ -66676,22 +67409,22 @@ 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 235: + case 238: case 154: case 153: case 155: case 156: case 157: - case 192: - case 234: - case 193: + case 194: + case 237: + case 195: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 214: + case 217: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214); + return checkModifiers(nodes, parent.kind === 217); } break; case 152: @@ -66711,11 +67444,11 @@ var ts; return; } break; - case 187: - case 188: - case 207: - case 256: - case 257: + case 189: + case 190: + case 209: + case 259: + case 260: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -67310,14 +68043,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -68692,10 +69425,11 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -68707,7 +69441,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); @@ -68724,13 +69458,13 @@ var ts; function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -68773,11 +69507,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0) { resolvedParts.pop(); originalParts.pop(); } @@ -68810,14 +69545,13 @@ var ts; } return [target]; } - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -68887,7 +69621,7 @@ var ts; return undefined; } var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); - if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); function getDirectoryOrExtensionlessFileName(path) { @@ -69243,7 +69977,7 @@ var ts; } var trace = host.trace && (function (s) { host.trace(s + newLine); }); var watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? ts.WatchLogLevel.Verbose : - compilerOptions.diagnostis ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -69716,16 +70450,19 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1) ? ".jsx" : ".js"); + var newExtension = ts.fileExtensionIs(inputFileName, ".json") ? ".json" : + ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ? ".jsx" : ".js"; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts")) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json")) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -69894,9 +70631,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -69941,7 +70675,7 @@ var ts; if (!graph.buildQueue) { return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { system.watchFile(resolved, function () { @@ -69965,7 +70699,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -70157,13 +70891,17 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -70171,7 +70909,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -70436,10 +71178,10 @@ var ts; upstreamProjectName: ref.path }; } - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -70506,7 +71248,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } break; case UpToDateStatusType.UpToDateWithUpstreamTypes: @@ -70541,9 +71283,12 @@ var ts; reportDiagnostic = ts.createDiagnosticReporter(ts.sys, /*pretty*/ true); } } + function defaultIsPretty() { + return !!ts.sys.writeOutputIsTTY && ts.sys.writeOutputIsTTY(); + } function shouldBePretty(options) { if (typeof options.pretty === "undefined") { - return !!ts.sys.writeOutputIsTTY && ts.sys.writeOutputIsTTY(); + return defaultIsPretty(); } return options.pretty; } @@ -70567,7 +71312,7 @@ var ts; } function executeCommandLine(args) { if (args.length > 0 && ((args[0].toLowerCase() === "--build") || (args[0].toLowerCase() === "-b"))) { - var reportDiag_1 = ts.createDiagnosticReporter(ts.sys, /*pretty*/ true); + var reportDiag_1 = ts.createDiagnosticReporter(ts.sys, defaultIsPretty()); var report = function (message) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 0fe2f989a21ac..7dbe902b21ac4 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -16,31 +16,67 @@ and limitations under the License. "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]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -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 __assign = (this && this.__assign) || function () { + __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; + }; + return __assign.apply(this, arguments); }; "use strict"; -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]; +var __assign = (this && this.__assign) || function () { + __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; + }; + return __assign.apply(this, arguments); +}; +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 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, 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 }; } - return t; }; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } @@ -892,23 +928,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1869,8 +1888,9 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; - function tryRemovePrefix(str, prefix) { - return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2210,160 +2230,163 @@ var ts; SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType"; + SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 213] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 295] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 296] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 297] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 298] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 299] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 296] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 297] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 298] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 299] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 300] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 301] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 302] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 300] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 303] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 301] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 302] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 303] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 304] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 305] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 304] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 305] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 306] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 307] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 308] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 306] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 309] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -2376,7 +2399,7 @@ var ts; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; @@ -2390,10 +2413,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 299] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 299] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 302] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 302] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -2567,6 +2590,7 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; @@ -2786,6 +2810,8 @@ var ts; CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; CheckFlags[CheckFlags["Late"] = 1024] = "Late"; CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped"; + CheckFlags[CheckFlags["OptionalParameter"] = 4096] = "OptionalParameter"; + CheckFlags[CheckFlags["RestParameter"] = 8192] = "RestParameter"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var InternalSymbolName; @@ -4420,6 +4446,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -4578,7 +4607,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -4698,6 +4726,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -4728,7 +4758,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -4798,6 +4828,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -4847,6 +4878,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -4994,6 +5026,9 @@ var ts; Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -5080,6 +5115,8 @@ var ts; Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -5379,6 +5416,10 @@ var ts; Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true), All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5410,6 +5451,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -5441,6 +5484,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -5585,6 +5629,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -7733,7 +7781,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274 /* SourceFile */) { + while (node && node.kind !== 277 /* SourceFile */) { node = node.parent; } return node; @@ -7741,11 +7789,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return true; } return false; @@ -7883,7 +7931,7 @@ 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 === 300 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 303 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7976,14 +8024,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; // 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) { @@ -7997,7 +8037,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; + return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -8029,11 +8069,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 && node.kind === 239 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 /* SourceFile */ || - node.kind === 239 /* ModuleDeclaration */ || + return node.kind === 277 /* SourceFile */ || + node.kind === 242 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8050,9 +8090,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node.parent); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8064,22 +8104,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 269 /* CatchClause */: - case 239 /* ModuleDeclaration */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 272 /* CatchClause */: + case 242 /* ModuleDeclaration */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; - case 213 /* Block */: + case 216 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8095,22 +8135,22 @@ var ts; case 160 /* IndexSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: - case 288 /* JSDocSignature */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 291 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -8120,8 +8160,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8130,15 +8170,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 214 /* VariableStatement */: - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 217 /* VariableStatement */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -8159,7 +8199,7 @@ var ts; // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -8186,7 +8226,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8231,7 +8271,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213 /* Block */) { + if (node.body && node.body.kind === 216 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8245,7 +8285,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* 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 @@ -8254,25 +8294,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: errorNode = node.name; break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8304,35 +8344,34 @@ var ts; return file.scriptKind === 6 /* JSON */; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */ && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */) - || !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 /* ImportType */ && - n.argument.kind === 178 /* LiteralType */ && + return n.kind === 181 /* ImportType */ && + n.argument.kind === 180 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 /* ExpressionStatement */ + return node.kind === 219 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -8343,9 +8382,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 /* Parameter */ || node.kind === 148 /* TypeParameter */ || - node.kind === 192 /* FunctionExpression */ || - node.kind === 193 /* ArrowFunction */ || - node.kind === 191 /* ParenthesizedExpression */) ? + node.kind === 194 /* FunctionExpression */ || + node.kind === 195 /* ArrowFunction */ || + node.kind === 193 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -8361,7 +8400,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -8375,11 +8414,11 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 196 /* VoidExpression */; - case 207 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 198 /* VoidExpression */; + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148 /* TypeParameter */: - return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; + return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: @@ -8387,20 +8426,20 @@ var ts; if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 187 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 185 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through case 146 /* QualifiedName */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: { var parent = node.parent; if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 179 /* ImportType */) { + if (parent.kind === 181 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8409,22 +8448,22 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148 /* TypeParameter */: return node === parent.constraint; case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return node === parent.type; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -8435,12 +8474,12 @@ var ts; case 159 /* ConstructSignature */: case 160 /* IndexSignature */: return node === parent.type; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return node === parent.type; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8465,23 +8504,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitor(node); - case 241 /* CaseBlock */: - case 213 /* Block */: - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 226 /* WithStatement */: - case 227 /* SwitchStatement */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 228 /* LabeledStatement */: - case 230 /* TryStatement */: - case 269 /* CatchClause */: + case 244 /* CaseBlock */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8491,19 +8530,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -8546,12 +8585,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 166 /* TypeLiteral */: return node.members; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.properties; } } @@ -8559,14 +8598,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182 /* BindingElement */: - case 273 /* EnumMember */: + case 184 /* BindingElement */: + case 276 /* EnumMember */: case 149 /* Parameter */: - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 271 /* ShorthandPropertyAssignment */: - case 232 /* VariableDeclaration */: + case 274 /* ShorthandPropertyAssignment */: + case 235 /* VariableDeclaration */: return true; } } @@ -8578,12 +8617,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 /* VariableDeclarationList */ - && node.parent.parent.kind === 214 /* VariableStatement */; + return node.parent.kind === 236 /* VariableDeclarationList */ + && node.parent.parent.kind === 217 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -8595,8 +8634,8 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return true; } return false; @@ -8607,7 +8646,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228 /* LabeledStatement */) { + if (node.statement.kind !== 231 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -8615,17 +8654,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 184 /* ObjectLiteralExpression */ || - node.parent.kind === 205 /* ClassExpression */); + (node.parent.kind === 186 /* ObjectLiteralExpression */ || + node.parent.kind === 207 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8638,7 +8677,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270 /* PropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -8675,7 +8714,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274 /* SourceFile */); + ts.Debug.assert(node.kind !== 277 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -8710,14 +8749,14 @@ var ts; node = node.parent; } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 239 /* ModuleDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 242 /* ModuleDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 154 /* MethodDeclaration */: @@ -8728,8 +8767,8 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 238 /* EnumDeclaration */: - case 274 /* SourceFile */: + case 241 /* EnumDeclaration */: + case 277 /* SourceFile */: return node; } } @@ -8740,8 +8779,8 @@ var ts; if (container) { switch (container.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return container; } } @@ -8766,9 +8805,9 @@ var ts; case 147 /* ComputedPropertyName */: node = node.parent; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!stopOnFunctions) { continue; } @@ -8799,14 +8838,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { + if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 191 /* ParenthesizedExpression */) { + while (parent.kind === 193 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -8817,7 +8856,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -8826,7 +8865,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -8834,7 +8873,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -8847,10 +8886,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return node.tag; - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -8859,25 +8898,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // classes are valid targets return true; case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 235 /* ClassDeclaration */; + return parent.kind === 238 /* ClassDeclaration */; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 154 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 235 /* ClassDeclaration */; + && parent.kind === 238 /* ClassDeclaration */; case 149 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined && (parent.kind === 155 /* Constructor */ || parent.kind === 154 /* MethodDeclaration */ || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 235 /* ClassDeclaration */; + && grandparent.kind === 238 /* ClassDeclaration */; } return false; } @@ -8893,7 +8932,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 case 154 /* MethodDeclaration */: case 157 /* SetAccessor */: @@ -8905,9 +8944,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 /* JsxOpeningElement */ || - parent.kind === 256 /* JsxSelfClosingElement */ || - parent.kind === 258 /* JsxClosingElement */) { + if (parent.kind === 260 /* JsxOpeningElement */ || + parent.kind === 259 /* JsxSelfClosingElement */ || + parent.kind === 261 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -8920,37 +8959,37 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: - case 208 /* AsExpression */: - case 190 /* TypeAssertionExpression */: - case 209 /* NonNullExpression */: - case 191 /* ParenthesizedExpression */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: - case 193 /* ArrowFunction */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 204 /* SpreadElement */: - case 202 /* TemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: + case 210 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 211 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 206 /* SpreadElement */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 206 /* OmittedExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 203 /* YieldExpression */: - case 197 /* AwaitExpression */: - case 210 /* MetaProperty */: + case 208 /* OmittedExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 205 /* YieldExpression */: + case 199 /* AwaitExpression */: + case 212 /* MetaProperty */: return true; case 146 /* QualifiedName */: while (node.parent.kind === 146 /* QualifiedName */) { @@ -8974,47 +9013,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 182 /* BindingElement */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 184 /* BindingElement */: return parent.initializer === node; - case 216 /* ExpressionStatement */: - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 225 /* ReturnStatement */: - case 226 /* WithStatement */: - case 227 /* SwitchStatement */: - case 266 /* CaseClause */: - case 229 /* ThrowStatement */: + case 219 /* ExpressionStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 228 /* ReturnStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 232 /* ThrowStatement */: return parent.expression === node; - case 220 /* ForStatement */: + case 223 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forInStatement.expression === node; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return node === parent.expression; - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return node === parent.expression; case 147 /* ComputedPropertyName */: return node === parent.expression; case 150 /* Decorator */: - case 265 /* JsxExpression */: - case 264 /* JsxSpreadAttribute */: - case 272 /* SpreadAssignment */: + case 268 /* JsxExpression */: + case 267 /* JsxSpreadAttribute */: + case 275 /* SpreadAssignment */: return true; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -9022,7 +9061,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9031,7 +9070,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -9063,7 +9102,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187 /* CallExpression */) { + if (callExpression.kind !== 189 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -9159,11 +9198,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 192 /* FunctionExpression */ || - initializer.kind === 205 /* ClassExpression */ || - initializer.kind === 193 /* ArrowFunction */) { + if (initializer.kind === 194 /* FunctionExpression */ || + initializer.kind === 207 /* ClassExpression */ || + initializer.kind === 195 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9232,7 +9271,7 @@ var ts; return false; } function getRightMostAssignedExpression(node) { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -9255,6 +9294,14 @@ var ts; return 0 /* None */; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + // F.prototype = { ... } + return 6 /* Prototype */; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } @@ -9263,11 +9310,7 @@ var ts; return 2 /* ModuleExports */; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - // F.prototype = { ... } - return 6 /* Prototype */; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } @@ -9287,7 +9330,7 @@ var ts; } return 0 /* None */; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -9301,7 +9344,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9311,14 +9354,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.parent; - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return node.parent.parent; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return node.parent; - case 178 /* LiteralType */: + case 180 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9328,12 +9371,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.moduleSpecifier; - case 243 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 179 /* ImportType */: + case 246 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 181 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9342,11 +9385,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9354,7 +9397,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -9363,8 +9406,8 @@ var ts; case 149 /* Parameter */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 271 /* ShorthandPropertyAssignment */: - case 270 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return node.questionToken !== undefined; @@ -9374,14 +9417,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 /* JSDocFunctionType */ && + return node.kind === 287 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 301 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9406,12 +9449,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152 /* PropertyDeclaration */: return node.initializer; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return node.initializer; } } @@ -9421,59 +9464,57 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 /* ModuleDeclaration */ + node.body.kind === 242 /* ModuleDeclaration */ ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - if (parent.kind === 270 /* PropertyAssignment */ || parent.kind === 152 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { - getJSDocCommentsAndTagsWorker(parent); - } - // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } + // Pull parameter comments from declaring function as well + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); } - // Pull parameter comments from declaring function as well if (node.kind === 149 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; } - if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { - result = ts.addRange(result, node.initializer.jsDoc); - } - if (ts.hasJSDocNodes(node)) { - result = ts.addRange(result, node.jsDoc); - } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 /* PropertyAssignment */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + return parent; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -9522,7 +9563,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9535,31 +9576,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 191 /* ParenthesizedExpression */: - case 183 /* ArrayLiteralExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 185 /* ArrayLiteralExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: node = parent; break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -9586,22 +9627,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 213 /* Block */: - case 214 /* VariableStatement */: - case 226 /* WithStatement */: - case 217 /* IfStatement */: - case 227 /* SwitchStatement */: - case 241 /* CaseBlock */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 228 /* LabeledStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 230 /* TryStatement */: - case 269 /* CatchClause */: + case 216 /* Block */: + case 217 /* VariableStatement */: + case 229 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return true; } return false; @@ -9618,15 +9659,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173 /* ParenthesizedType */); + return walkUp(node, 175 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191 /* ParenthesizedExpression */); + return walkUp(node, 193 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */) { + while (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -9634,11 +9675,11 @@ var ts; ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194 /* DeleteExpression */; + return node && node.kind === 196 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9695,9 +9736,9 @@ var ts; case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 185 /* PropertyAccessExpression */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 187 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; case 146 /* QualifiedName */: @@ -9709,12 +9750,12 @@ var ts; return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 182 /* BindingElement */: - case 248 /* ImportSpecifier */: + case 184 /* BindingElement */: + case 251 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 252 /* ExportSpecifier */: - case 262 /* JsxAttribute */: + case 255 /* ExportSpecifier */: + case 265 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -9730,13 +9771,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ || - node.kind === 242 /* NamespaceExportDeclaration */ || - node.kind === 245 /* ImportClause */ && !!node.name || - node.kind === 246 /* NamespaceImport */ || - node.kind === 248 /* ImportSpecifier */ || - node.kind === 252 /* ExportSpecifier */ || - node.kind === 249 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 245 /* NamespaceExportDeclaration */ || + node.kind === 248 /* ImportClause */ && !!node.name || + node.kind === 249 /* NamespaceImport */ || + node.kind === 251 /* ImportSpecifier */ || + node.kind === 255 /* ExportSpecifier */ || + node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9745,11 +9786,22 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + // Prefer an @augments tag because it may have type parameters. + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; @@ -9758,7 +9810,7 @@ var ts; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -9831,14 +9883,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -9852,9 +9904,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined @@ -9960,7 +10012,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182 /* BindingElement */) { + while (node.kind === 184 /* BindingElement */) { node = node.parent.parent; } return node; @@ -9969,14 +10021,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 /* Constructor */ - || kind === 192 /* FunctionExpression */ - || kind === 234 /* FunctionDeclaration */ - || kind === 193 /* ArrowFunction */ + || kind === 194 /* FunctionExpression */ + || kind === 237 /* FunctionDeclaration */ + || kind === 195 /* ArrowFunction */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ - || kind === 239 /* ModuleDeclaration */ - || kind === 274 /* SourceFile */; + || kind === 242 /* ModuleDeclaration */ + || kind === 277 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9995,23 +10047,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: return 1 /* Right */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -10035,15 +10087,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200 /* BinaryExpression */) { + if (expression.kind === 202 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { + else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10053,15 +10105,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return 0; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return 1; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return 2; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return 4; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -10082,21 +10134,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: return 16; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return 17; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return 18; - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 19 : 18; - case 189 /* TaggedTemplateExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 191 /* TaggedTemplateExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -10106,19 +10158,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 191 /* ParenthesizedExpression */: - case 206 /* OmittedExpression */: + case 204 /* TemplateExpression */: + case 193 /* ParenthesizedExpression */: + case 208 /* OmittedExpression */: return 20; default: return -1; @@ -10177,6 +10229,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -10184,6 +10237,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -10606,7 +10676,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); @@ -10618,7 +10688,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -10911,8 +10981,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 184 /* ObjectLiteralExpression */ - || kind === 183 /* ArrayLiteralExpression */; + return kind === 186 /* ObjectLiteralExpression */ + || kind === 185 /* ArrayLiteralExpression */; } return false; } @@ -10922,7 +10992,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */ + return node.kind === 209 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -10944,16 +11014,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); + (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 /* ObjectLiteralExpression */ && + return expression.kind === 186 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 /* ArrayLiteralExpression */ && + return expression.kind === 185 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11294,8 +11364,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11372,21 +11442,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && parent.parent.kind === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -11489,7 +11559,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -11559,6 +11629,11 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + /* @internal */ + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; // Returns true if 'span' contains 'other'. function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -11752,7 +11827,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { return current; } } @@ -11777,27 +11852,34 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232 /* VariableDeclaration */) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236 /* VariableDeclarationList */) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217 /* VariableStatement */) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags @@ -11807,19 +11889,7 @@ var ts; // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** @@ -11927,16 +11997,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -11953,17 +12013,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return expr.name; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11972,10 +12032,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 228 /* LabeledStatement */: { + case 231 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11987,7 +12047,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -11998,29 +12058,20 @@ var ts; return !!node.name; // A 'name' property should always be a DeclarationName. } ts.isNamedDeclaration = isNamedDeclaration; - // TODO: GH#18217 This is often used as if it returns a defined result - function getNameOfDeclaration(declaration) { - if (!declaration) { - return undefined; - } + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71 /* Identifier */: return declaration; - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: { + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -12032,17 +12083,22 @@ var ts; return undefined; } } - case 292 /* JSDocCallbackTag */: - return declaration.name; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -12331,545 +12387,545 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169 /* UnionType */; + return node.kind === 171 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170 /* IntersectionType */; + return node.kind === 172 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171 /* ConditionalType */; + return node.kind === 173 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172 /* InferType */; + return node.kind === 174 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173 /* ParenthesizedType */; + return node.kind === 175 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174 /* ThisType */; + return node.kind === 176 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175 /* TypeOperator */; + return node.kind === 177 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176 /* IndexedAccessType */; + return node.kind === 178 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177 /* MappedType */; + return node.kind === 179 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178 /* LiteralType */; + return node.kind === 180 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179 /* ImportType */; + return node.kind === 181 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 180 /* ObjectBindingPattern */; + return node.kind === 182 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181 /* ArrayBindingPattern */; + return node.kind === 183 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182 /* BindingElement */; + return node.kind === 184 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 183 /* ArrayLiteralExpression */; + return node.kind === 185 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184 /* ObjectLiteralExpression */; + return node.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185 /* PropertyAccessExpression */; + return node.kind === 187 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186 /* ElementAccessExpression */; + return node.kind === 188 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187 /* CallExpression */; + return node.kind === 189 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188 /* NewExpression */; + return node.kind === 190 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189 /* TaggedTemplateExpression */; + return node.kind === 191 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190 /* TypeAssertionExpression */; + return node.kind === 192 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191 /* ParenthesizedExpression */; + return node.kind === 193 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302 /* PartiallyEmittedExpression */) { + while (node.kind === 305 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192 /* FunctionExpression */; + return node.kind === 194 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193 /* ArrowFunction */; + return node.kind === 195 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194 /* DeleteExpression */; + return node.kind === 196 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195 /* TypeOfExpression */; + return node.kind === 197 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196 /* VoidExpression */; + return node.kind === 198 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197 /* AwaitExpression */; + return node.kind === 199 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198 /* PrefixUnaryExpression */; + return node.kind === 200 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199 /* PostfixUnaryExpression */; + return node.kind === 201 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200 /* BinaryExpression */; + return node.kind === 202 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201 /* ConditionalExpression */; + return node.kind === 203 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202 /* TemplateExpression */; + return node.kind === 204 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203 /* YieldExpression */; + return node.kind === 205 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204 /* SpreadElement */; + return node.kind === 206 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205 /* ClassExpression */; + return node.kind === 207 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206 /* OmittedExpression */; + return node.kind === 208 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208 /* AsExpression */; + return node.kind === 210 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209 /* NonNullExpression */; + return node.kind === 211 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210 /* MetaProperty */; + return node.kind === 212 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 211 /* TemplateSpan */; + return node.kind === 214 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212 /* SemicolonClassElement */; + return node.kind === 215 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 213 /* Block */; + return node.kind === 216 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214 /* VariableStatement */; + return node.kind === 217 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215 /* EmptyStatement */; + return node.kind === 218 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216 /* ExpressionStatement */; + return node.kind === 219 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217 /* IfStatement */; + return node.kind === 220 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218 /* DoStatement */; + return node.kind === 221 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219 /* WhileStatement */; + return node.kind === 222 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220 /* ForStatement */; + return node.kind === 223 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221 /* ForInStatement */; + return node.kind === 224 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222 /* ForOfStatement */; + return node.kind === 225 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223 /* ContinueStatement */; + return node.kind === 226 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224 /* BreakStatement */; + return node.kind === 227 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; + return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225 /* ReturnStatement */; + return node.kind === 228 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226 /* WithStatement */; + return node.kind === 229 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227 /* SwitchStatement */; + return node.kind === 230 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228 /* LabeledStatement */; + return node.kind === 231 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229 /* ThrowStatement */; + return node.kind === 232 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230 /* TryStatement */; + return node.kind === 233 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231 /* DebuggerStatement */; + return node.kind === 234 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232 /* VariableDeclaration */; + return node.kind === 235 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233 /* VariableDeclarationList */; + return node.kind === 236 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234 /* FunctionDeclaration */; + return node.kind === 237 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235 /* ClassDeclaration */; + return node.kind === 238 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236 /* InterfaceDeclaration */; + return node.kind === 239 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237 /* TypeAliasDeclaration */; + return node.kind === 240 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */; + return node.kind === 241 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */; + return node.kind === 242 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240 /* ModuleBlock */; + return node.kind === 243 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241 /* CaseBlock */; + return node.kind === 244 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242 /* NamespaceExportDeclaration */; + return node.kind === 245 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */; + return node.kind === 246 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244 /* ImportDeclaration */; + return node.kind === 247 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245 /* ImportClause */; + return node.kind === 248 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246 /* NamespaceImport */; + return node.kind === 249 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247 /* NamedImports */; + return node.kind === 250 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248 /* ImportSpecifier */; + return node.kind === 251 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249 /* ExportAssignment */; + return node.kind === 252 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250 /* ExportDeclaration */; + return node.kind === 253 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251 /* NamedExports */; + return node.kind === 254 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252 /* ExportSpecifier */; + return node.kind === 255 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253 /* MissingDeclaration */; + return node.kind === 256 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 254 /* ExternalModuleReference */; + return node.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 255 /* JsxElement */; + return node.kind === 258 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256 /* JsxSelfClosingElement */; + return node.kind === 259 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257 /* JsxOpeningElement */; + return node.kind === 260 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258 /* JsxClosingElement */; + return node.kind === 261 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259 /* JsxFragment */; + return node.kind === 262 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260 /* JsxOpeningFragment */; + return node.kind === 263 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261 /* JsxClosingFragment */; + return node.kind === 264 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262 /* JsxAttribute */; + return node.kind === 265 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263 /* JsxAttributes */; + return node.kind === 266 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264 /* JsxSpreadAttribute */; + return node.kind === 267 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265 /* JsxExpression */; + return node.kind === 268 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 266 /* CaseClause */; + return node.kind === 269 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267 /* DefaultClause */; + return node.kind === 270 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268 /* HeritageClause */; + return node.kind === 271 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269 /* CatchClause */; + return node.kind === 272 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 270 /* PropertyAssignment */; + return node.kind === 273 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271 /* ShorthandPropertyAssignment */; + return node.kind === 274 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272 /* SpreadAssignment */; + return node.kind === 275 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 274 /* SourceFile */; + return node.kind === 277 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275 /* Bundle */; + return node.kind === 278 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276 /* UnparsedSource */; + return node.kind === 279 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 278 /* JSDocTypeExpression */; + return node.kind === 281 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279 /* JSDocAllType */; + return node.kind === 282 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280 /* JSDocUnknownType */; + return node.kind === 283 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281 /* JSDocNullableType */; + return node.kind === 284 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282 /* JSDocNonNullableType */; + return node.kind === 285 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283 /* JSDocOptionalType */; + return node.kind === 286 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284 /* JSDocFunctionType */; + return node.kind === 287 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285 /* JSDocVariadicType */; + return node.kind === 288 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286 /* JSDocComment */; + return node.kind === 289 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290 /* JSDocAugmentsTag */; + return node.kind === 293 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291 /* JSDocClassTag */; + return node.kind === 294 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295 /* JSDocThisTag */; + return node.kind === 298 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293 /* JSDocParameterTag */; + return node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294 /* JSDocReturnTag */; + return node.kind === 297 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296 /* JSDocTypeTag */; + return node.kind === 299 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297 /* JSDocTemplateTag */; + return node.kind === 300 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298 /* JSDocTypedefTag */; + return node.kind === 301 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299 /* JSDocPropertyTag */; + return node.kind === 302 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; + return node.kind === 302 /* JSDocPropertyTag */ || node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287 /* JSDocTypeLiteral */; + return node.kind === 290 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288 /* JSDocSignature */; + return node.kind === 291 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -12880,7 +12936,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 300 /* SyntaxList */; + return n.kind === 303 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -12995,8 +13051,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 180 /* ObjectBindingPattern */ - || kind === 181 /* ArrayBindingPattern */; + || kind === 182 /* ObjectBindingPattern */ + || kind === 183 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13011,13 +13067,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; default: return false; @@ -13028,11 +13084,11 @@ var ts; switch (kind) { case 153 /* MethodSignature */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: case 164 /* ConstructorType */: return true; default: @@ -13054,11 +13110,11 @@ var ts; || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ || kind === 160 /* IndexSignature */ - || kind === 212 /* SemicolonClassElement */; + || kind === 215 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); + return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -13093,9 +13149,9 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 /* PropertyAssignment */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 272 /* SpreadAssignment */ + return kind === 273 /* PropertyAssignment */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 275 /* SpreadAssignment */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */; @@ -13103,7 +13159,7 @@ var ts; ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ @@ -13116,14 +13172,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 207 /* ExpressionWithTypeArguments */ - || kind === 279 /* JSDocAllType */ - || kind === 280 /* JSDocUnknownType */ - || kind === 281 /* JSDocNullableType */ - || kind === 282 /* JSDocNonNullableType */ - || kind === 283 /* JSDocOptionalType */ - || kind === 284 /* JSDocFunctionType */ - || kind === 285 /* JSDocVariadicType */; + || kind === 209 /* ExpressionWithTypeArguments */ + || kind === 282 /* JSDocAllType */ + || kind === 283 /* JSDocUnknownType */ + || kind === 284 /* JSDocNullableType */ + || kind === 285 /* JSDocNonNullableType */ + || kind === 286 /* JSDocOptionalType */ + || kind === 287 /* JSDocFunctionType */ + || kind === 288 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13148,8 +13204,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 /* ArrayBindingPattern */ - || kind === 180 /* ObjectBindingPattern */; + return kind === 183 /* ArrayBindingPattern */ + || kind === 182 /* ObjectBindingPattern */; } return false; } @@ -13157,15 +13213,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 /* ArrayLiteralExpression */ - || kind === 184 /* ObjectLiteralExpression */; + return kind === 185 /* ArrayLiteralExpression */ + || kind === 186 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 /* BindingElement */ - || kind === 206 /* OmittedExpression */; + return kind === 184 /* BindingElement */ + || kind === 208 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13174,9 +13230,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return true; } return false; @@ -13197,8 +13253,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return true; } return false; @@ -13210,8 +13266,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return true; } return false; @@ -13220,25 +13276,25 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */ - || kind === 179 /* ImportType */; + || kind === 181 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: case 150 /* Decorator */: return true; default: @@ -13247,12 +13303,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; + return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 /* TemplateExpression */ + return kind === 204 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13263,32 +13319,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: - case 188 /* NewExpression */: - case 187 /* CallExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 189 /* TaggedTemplateExpression */: - case 183 /* ArrayLiteralExpression */: - case 191 /* ParenthesizedExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 190 /* NewExpression */: + case 189 /* CallExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 191 /* TaggedTemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 193 /* ParenthesizedExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 209 /* NonNullExpression */: - case 210 /* MetaProperty */: + case 211 /* NonNullExpression */: + case 212 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13302,13 +13358,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 190 /* TypeAssertionExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 192 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13317,9 +13373,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -13338,15 +13394,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: - case 193 /* ArrowFunction */: - case 200 /* BinaryExpression */: - case 204 /* SpreadElement */: - case 208 /* AsExpression */: - case 206 /* OmittedExpression */: - case 303 /* CommaListExpression */: - case 302 /* PartiallyEmittedExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: + case 195 /* ArrowFunction */: + case 202 /* BinaryExpression */: + case 206 /* SpreadElement */: + case 210 /* AsExpression */: + case 208 /* OmittedExpression */: + case 306 /* CommaListExpression */: + case 305 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13354,18 +13410,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 /* TypeAssertionExpression */ - || kind === 208 /* AsExpression */; + return kind === 192 /* TypeAssertionExpression */ + || kind === 210 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 302 /* PartiallyEmittedExpression */; + return node.kind === 305 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 301 /* NotEmittedStatement */; + return node.kind === 304 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -13376,13 +13432,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return true; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13390,7 +13446,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; + return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13414,113 +13470,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */ + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */; + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 239 /* ModuleDeclaration */; + || kind === 242 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 /* NamedImports */ - || kind === 246 /* NamespaceImport */; + return kind === 250 /* NamedImports */ + || kind === 249 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; + return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 /* ArrowFunction */ - || kind === 182 /* BindingElement */ - || kind === 235 /* ClassDeclaration */ - || kind === 205 /* ClassExpression */ + return kind === 195 /* ArrowFunction */ + || kind === 184 /* BindingElement */ + || kind === 238 /* ClassDeclaration */ + || kind === 207 /* ClassExpression */ || kind === 155 /* Constructor */ - || kind === 238 /* EnumDeclaration */ - || kind === 273 /* EnumMember */ - || kind === 252 /* ExportSpecifier */ - || kind === 234 /* FunctionDeclaration */ - || kind === 192 /* FunctionExpression */ + || kind === 241 /* EnumDeclaration */ + || kind === 276 /* EnumMember */ + || kind === 255 /* ExportSpecifier */ + || kind === 237 /* FunctionDeclaration */ + || kind === 194 /* FunctionExpression */ || kind === 156 /* GetAccessor */ - || kind === 245 /* ImportClause */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 248 /* ImportSpecifier */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 262 /* JsxAttribute */ + || kind === 248 /* ImportClause */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 251 /* ImportSpecifier */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 265 /* JsxAttribute */ || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ - || kind === 239 /* ModuleDeclaration */ - || kind === 242 /* NamespaceExportDeclaration */ - || kind === 246 /* NamespaceImport */ + || kind === 242 /* ModuleDeclaration */ + || kind === 245 /* NamespaceExportDeclaration */ + || kind === 249 /* NamespaceImport */ || kind === 149 /* Parameter */ - || kind === 270 /* PropertyAssignment */ + || kind === 273 /* PropertyAssignment */ || kind === 152 /* PropertyDeclaration */ || kind === 151 /* PropertySignature */ || kind === 157 /* SetAccessor */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 237 /* TypeAliasDeclaration */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 240 /* TypeAliasDeclaration */ || kind === 148 /* TypeParameter */ - || kind === 232 /* VariableDeclaration */ - || kind === 298 /* JSDocTypedefTag */ - || kind === 292 /* JSDocCallbackTag */ - || kind === 299 /* JSDocPropertyTag */; + || kind === 235 /* VariableDeclaration */ + || kind === 301 /* JSDocTypedefTag */ + || kind === 295 /* JSDocCallbackTag */ + || kind === 302 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 234 /* FunctionDeclaration */ - || kind === 253 /* MissingDeclaration */ - || kind === 235 /* ClassDeclaration */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 237 /* TypeAliasDeclaration */ - || kind === 238 /* EnumDeclaration */ - || kind === 239 /* ModuleDeclaration */ - || kind === 244 /* ImportDeclaration */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 250 /* ExportDeclaration */ - || kind === 249 /* ExportAssignment */ - || kind === 242 /* NamespaceExportDeclaration */; + return kind === 237 /* FunctionDeclaration */ + || kind === 256 /* MissingDeclaration */ + || kind === 238 /* ClassDeclaration */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 240 /* TypeAliasDeclaration */ + || kind === 241 /* EnumDeclaration */ + || kind === 242 /* ModuleDeclaration */ + || kind === 247 /* ImportDeclaration */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 253 /* ExportDeclaration */ + || kind === 252 /* ExportAssignment */ + || kind === 245 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 224 /* BreakStatement */ - || kind === 223 /* ContinueStatement */ - || kind === 231 /* DebuggerStatement */ - || kind === 218 /* DoStatement */ - || kind === 216 /* ExpressionStatement */ - || kind === 215 /* EmptyStatement */ - || kind === 221 /* ForInStatement */ - || kind === 222 /* ForOfStatement */ - || kind === 220 /* ForStatement */ - || kind === 217 /* IfStatement */ - || kind === 228 /* LabeledStatement */ - || kind === 225 /* ReturnStatement */ - || kind === 227 /* SwitchStatement */ - || kind === 229 /* ThrowStatement */ - || kind === 230 /* TryStatement */ - || kind === 214 /* VariableStatement */ - || kind === 219 /* WhileStatement */ - || kind === 226 /* WithStatement */ - || kind === 301 /* NotEmittedStatement */ - || kind === 305 /* EndOfDeclarationMarker */ - || kind === 304 /* MergeDeclarationMarker */; + return kind === 227 /* BreakStatement */ + || kind === 226 /* ContinueStatement */ + || kind === 234 /* DebuggerStatement */ + || kind === 221 /* DoStatement */ + || kind === 219 /* ExpressionStatement */ + || kind === 218 /* EmptyStatement */ + || kind === 224 /* ForInStatement */ + || kind === 225 /* ForOfStatement */ + || kind === 223 /* ForStatement */ + || kind === 220 /* IfStatement */ + || kind === 231 /* LabeledStatement */ + || kind === 228 /* ReturnStatement */ + || kind === 230 /* SwitchStatement */ + || kind === 232 /* ThrowStatement */ + || kind === 233 /* TryStatement */ + || kind === 217 /* VariableStatement */ + || kind === 222 /* WhileStatement */ + || kind === 229 /* WithStatement */ + || kind === 304 /* NotEmittedStatement */ + || kind === 308 /* EndOfDeclarationMarker */ + || kind === 307 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 297 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -13547,10 +13603,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213 /* Block */) + if (node.kind !== 216 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { + if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { return false; } } @@ -13560,7 +13616,7 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 254 /* ExternalModuleReference */ + return kind === 257 /* ExternalModuleReference */ || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } @@ -13571,62 +13627,62 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 185 /* PropertyAccessExpression */; + || kind === 187 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 255 /* JsxElement */ - || kind === 265 /* JsxExpression */ - || kind === 256 /* JsxSelfClosingElement */ + return kind === 258 /* JsxElement */ + || kind === 268 /* JsxExpression */ + || kind === 259 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 259 /* JsxFragment */; + || kind === 262 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 /* JsxAttribute */ - || kind === 264 /* JsxSpreadAttribute */; + return kind === 265 /* JsxAttribute */ + || kind === 267 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 265 /* JsxExpression */; + || kind === 268 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 /* JsxOpeningElement */ - || kind === 256 /* JsxSelfClosingElement */; + return kind === 260 /* JsxOpeningElement */ + || kind === 259 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 /* CaseClause */ - || kind === 267 /* DefaultClause */; + return kind === 269 /* CaseClause */ + || kind === 270 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 299 /* LastJSDocNode */; + return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 302 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 289 /* FirstJSDocTagNode */ && node.kind <= 299 /* LastJSDocTagNode */; + return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 302 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -13669,22 +13725,22 @@ var ts; case 161 /* TypePredicate */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: - case 177 /* MappedType */: - case 190 /* TypeAssertionExpression */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 208 /* AsExpression */: - case 232 /* VariableDeclaration */: - case 234 /* FunctionDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 278 /* JSDocTypeExpression */: - case 281 /* JSDocNullableType */: - case 282 /* JSDocNonNullableType */: - case 283 /* JSDocOptionalType */: - case 284 /* JSDocFunctionType */: - case 285 /* JSDocVariadicType */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: + case 179 /* MappedType */: + case 192 /* TypeAssertionExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 210 /* AsExpression */: + case 235 /* VariableDeclaration */: + case 237 /* FunctionDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 281 /* JSDocTypeExpression */: + case 284 /* JSDocNullableType */: + case 285 /* JSDocNonNullableType */: + case 286 /* JSDocOptionalType */: + case 287 /* JSDocFunctionType */: + case 288 /* JSDocVariadicType */: return true; } return false; @@ -13704,10 +13760,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -13719,7 +13775,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13756,7 +13812,7 @@ var ts; (function (ts) { /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; + return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -13897,6 +13953,13 @@ var ts; } /* @internal */ function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + /* @internal */ + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -13904,7 +13967,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; + } + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -14447,17 +14522,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.tryRemovePrefix(path, dirPath); - if (a === undefined) - return undefined; - switch (a.charCodeAt(0)) { - case 47 /* slash */: - case 92 /* backslash */: - return a.slice(1); - default: - return undefined; - } + function isDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; // Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. @@ -15010,7 +15083,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 274 /* SourceFile */) { + if (kind === 277 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -15074,14 +15147,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -15106,20 +15179,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15141,9 +15214,9 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15168,290 +15241,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172 /* InferType */: + case 174 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 179 /* ImportType */: + case 181 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: return visitNode(cbNode, node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177 /* MappedType */: + case 179 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return visitNode(cbNode, node.literal); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitNode(cbNode, node.name); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return visitNode(cbNode, node.label); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 278 /* JSDocTypeExpression */: - return visitNode(cbNode, node.type); - case 282 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 281 /* JSDocNullableType */: - return visitNode(cbNode, node.type); - case 283 /* JSDocOptionalType */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 281 /* JSDocTypeExpression */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 286 /* JSDocOptionalType */: + case 288 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 286 /* JSDocComment */: + case 289 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15460,17 +15531,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 278 /* JSDocTypeExpression */) { + node.typeExpression.kind === 281 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15478,18 +15549,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292 /* JSDocCallbackTag */: + case 295 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295 /* JSDocThisTag */: + case 298 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 287 /* JSDocTypeLiteral */: + case 290 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15497,7 +15568,7 @@ var ts; } } return; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15711,7 +15782,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216 /* ExpressionStatement */); + var statement = createNode(219 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15828,13 +15899,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); // Should only be called once per node + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -15870,7 +15938,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // 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(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16677,7 +16745,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 152 /* PropertyDeclaration */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return true; case 154 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -16694,8 +16762,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: return true; } } @@ -16704,42 +16772,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 214 /* VariableStatement */: - case 213 /* Block */: - case 217 /* IfStatement */: - case 216 /* ExpressionStatement */: - case 229 /* ThrowStatement */: - case 225 /* ReturnStatement */: - case 227 /* SwitchStatement */: - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 215 /* EmptyStatement */: - case 230 /* TryStatement */: - case 228 /* LabeledStatement */: - case 218 /* DoStatement */: - case 231 /* DebuggerStatement */: - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 217 /* VariableStatement */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 219 /* ExpressionStatement */: + case 232 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 230 /* SwitchStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 218 /* EmptyStatement */: + case 233 /* TryStatement */: + case 231 /* LabeledStatement */: + case 221 /* DoStatement */: + case 234 /* DebuggerStatement */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -16755,7 +16823,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232 /* VariableDeclaration */) { + if (node.kind !== 235 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16881,7 +16949,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -16943,7 +17016,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202 /* TemplateExpression */); + var template = createNode(204 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -16955,7 +17028,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211 /* TemplateSpan */); + var span = createNode(214 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -17021,10 +17094,9 @@ var ts; case 163 /* FunctionType */: case 164 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17038,14 +17110,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174 /* ThisType */); + var node = createNode(176 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279 /* JSDocAllType */); + var result = createNode(282 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, result); + return createPostfixType(286 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17053,7 +17125,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282 /* JSDocNonNullableType */); + var result = createNode(285 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17077,18 +17149,18 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(280 /* JSDocUnknownType */, pos); + var result = createNode(283 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(281 /* JSDocNullableType */, pos); + var result = createNode(284 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -17110,12 +17182,12 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, type); + return createPostfixType(286 /* JSDocOptionalType */, type); } return type; } @@ -17455,7 +17527,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177 /* MappedType */); + var node = createNode(179 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17477,13 +17549,26 @@ var ts; parseExpected(18 /* CloseBraceToken */); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24 /* DotDotDotToken */)) { + var node = createNode(170 /* RestType */, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 169 /* OptionalType */; + } + return type; + } function parseTupleType() { var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173 /* ParenthesizedType */); + var node = createNode(175 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); parseExpected(20 /* CloseParenToken */); @@ -17501,10 +17586,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178 /* LiteralType */); + var node = createNode(180 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17525,7 +17610,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(179 /* ImportType */); + var node = createNode(181 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17651,19 +17736,19 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); + type = createPostfixType(285 /* JSDocNonNullableType */, type); break; case 55 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(281 /* JSDocNullableType */, type); + type = createPostfixType(284 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(176 /* IndexedAccessType */, type.pos); + var node = createNode(178 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); @@ -17682,21 +17767,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175 /* TypeOperator */); + var node = createNode(177 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172 /* InferType */); + var node = createNode(174 /* InferType */); parseExpected(126 /* InferKeyword */); var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); @@ -17729,10 +17814,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17816,7 +17901,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(171 /* ConditionalType */, type.pos); + var node = createNode(173 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -18009,7 +18094,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203 /* YieldExpression */); + var node = createNode(205 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -18031,11 +18116,11 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193 /* ArrowFunction */, asyncModifier.pos); + node = createNode(195 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193 /* ArrowFunction */, identifier.pos); + node = createNode(195 /* ArrowFunction */, identifier.pos); } var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; @@ -18233,7 +18318,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193 /* ArrowFunction */); + var node = createNodeWithJSDoc(195 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18297,7 +18382,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(201 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18377,39 +18462,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200 /* BinaryExpression */, left.pos); + var node = createNode(202 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208 /* AsExpression */, left.pos); + var node = createNode(210 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194 /* DeleteExpression */); + var node = createNode(196 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195 /* TypeOfExpression */); + var node = createNode(197 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196 /* VoidExpression */); + var node = createNode(198 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18425,7 +18510,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197 /* AwaitExpression */); + var node = createNode(199 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18469,7 +18554,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { parseErrorAt(pos, end, 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 { @@ -18566,7 +18651,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18579,7 +18664,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18635,7 +18720,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(210 /* MetaProperty */, fullStart); + var node = createNode(212 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18710,7 +18795,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(185 /* PropertyAccessExpression */, expression.pos); + var node = createNode(187 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -18719,8 +18804,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257 /* JsxOpeningElement */) { - var node = createNode(255 /* JsxElement */, opening.pos); + if (opening.kind === 260 /* JsxOpeningElement */) { + var node = createNode(258 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18729,15 +18814,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260 /* JsxOpeningFragment */) { - var node = createNode(259 /* JsxFragment */, opening.pos); + else if (opening.kind === 263 /* JsxOpeningFragment */) { + var node = createNode(262 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18752,7 +18837,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(200 /* BinaryExpression */, result.pos); + var badNode = createNode(202 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -18810,7 +18895,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263 /* JsxAttributes */); + var jsxAttributes = createNode(266 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18819,7 +18904,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18831,7 +18916,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(257 /* JsxOpeningElement */, fullStart); + node = createNode(260 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18843,7 +18928,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(256 /* JsxSelfClosingElement */, fullStart); + node = createNode(259 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18860,7 +18945,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18868,7 +18953,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265 /* JsxExpression */); + var node = createNode(268 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18890,7 +18975,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262 /* JsxAttribute */); + var node = createNode(265 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18905,7 +18990,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264 /* JsxSpreadAttribute */); + var node = createNode(267 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18913,7 +18998,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258 /* JsxClosingElement */); + var node = createNode(261 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18926,7 +19011,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261 /* JsxClosingFragment */); + var node = createNode(264 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18941,7 +19026,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190 /* TypeAssertionExpression */); + var node = createNode(192 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18952,7 +19037,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18960,14 +19045,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(211 /* 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(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(186 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -18994,7 +19079,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -19018,7 +19103,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -19026,7 +19111,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19138,28 +19223,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204 /* SpreadElement */); + var node = createNode(206 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183 /* ArrayLiteralExpression */); + var node = createNode(185 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19171,7 +19256,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 272 /* SpreadAssignment */; + node.kind = 275 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19198,7 +19283,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - node.kind = 271 /* ShorthandPropertyAssignment */; + node.kind = 274 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -19206,14 +19291,14 @@ var ts; } } else { - node.kind = 270 /* PropertyAssignment */; + node.kind = 273 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184 /* ObjectLiteralExpression */); + var node = createNode(186 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19232,7 +19317,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(192 /* FunctionExpression */); + var node = createNodeWithJSDoc(194 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19257,7 +19342,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(210 /* MetaProperty */, fullStart); + var node_2 = createNode(212 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19274,7 +19359,7 @@ var ts; } break; } - var node = createNode(188 /* NewExpression */, fullStart); + var node = createNode(190 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19284,7 +19369,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213 /* Block */); + var node = createNode(216 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19317,12 +19402,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215 /* EmptyStatement */); + var node = createNode(218 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(217 /* IfStatement */); + var node = createNode(220 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19332,7 +19417,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218 /* DoStatement */); + var node = createNode(221 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19347,7 +19432,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219 /* WhileStatement */); + var node = createNode(222 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19371,7 +19456,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(222 /* ForOfStatement */, pos); + var forOfStatement = createNode(225 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19379,14 +19464,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(221 /* ForInStatement */, pos); + var forInStatement = createNode(224 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220 /* ForStatement */, pos); + var forStatement = createNode(223 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19404,7 +19489,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19412,7 +19497,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225 /* ReturnStatement */); + var node = createNode(228 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19421,7 +19506,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226 /* WithStatement */); + var node = createNode(229 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19430,7 +19515,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266 /* CaseClause */); + var node = createNode(269 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19438,7 +19523,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267 /* DefaultClause */); + var node = createNode(270 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19448,12 +19533,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227 /* SwitchStatement */); + var node = createNode(230 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(241 /* CaseBlock */); + var caseBlock = createNode(244 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19468,7 +19553,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(229 /* ThrowStatement */); + var node = createNode(232 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19476,7 +19561,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(230 /* TryStatement */); + var node = createNode(233 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19489,7 +19574,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269 /* CatchClause */); + var result = createNode(272 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19503,7 +19588,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231 /* DebuggerStatement */); + var node = createNode(234 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19515,12 +19600,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 228 /* LabeledStatement */; + node.kind = 231 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216 /* ExpressionStatement */; + node.kind = 219 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19687,16 +19772,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19706,9 +19791,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(223 /* ContinueStatement */); + return parseBreakOrContinueStatement(226 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(224 /* BreakStatement */); + return parseBreakOrContinueStatement(227 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19805,7 +19890,7 @@ var ts; if (node.decorators || node.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 missing = createMissingNode(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -19828,16 +19913,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(206 /* OmittedExpression */); + return createNode(208 /* OmittedExpression */); } - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19853,14 +19938,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180 /* ObjectBindingPattern */); + var node = createNode(182 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181 /* ArrayBindingPattern */); + var node = createNode(183 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19882,7 +19967,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232 /* VariableDeclaration */); + var node = createNode(235 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19895,7 +19980,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233 /* VariableDeclarationList */); + var node = createNode(236 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19933,13 +20018,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 214 /* VariableStatement */; + node.kind = 217 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234 /* FunctionDeclaration */; + node.kind = 237 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -20121,7 +20206,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(212 /* SemicolonClassElement */); + var result = createNode(215 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -20158,10 +20243,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -20204,14 +20289,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(268 /* HeritageClause */); + var node = createNode(271 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -20228,7 +20313,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236 /* InterfaceDeclaration */; + node.kind = 239 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20237,7 +20322,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237 /* TypeAliasDeclaration */; + node.kind = 240 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20251,13 +20336,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 = createNodeWithJSDoc(273 /* EnumMember */); + var node = createNodeWithJSDoc(276 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238 /* EnumDeclaration */; + node.kind = 241 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20270,7 +20355,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240 /* ModuleBlock */); + var node = createNode(243 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20281,7 +20366,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; // 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 */; @@ -20293,7 +20378,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -20339,7 +20424,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 242 /* NamespaceExportDeclaration */; + node.kind = 245 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20357,7 +20442,7 @@ var ts; } } // Import statement - node.kind = 244 /* ImportDeclaration */; + node.kind = 247 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20372,7 +20457,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243 /* ImportEqualsDeclaration */; + node.kind = 246 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20386,7 +20471,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(245 /* ImportClause */, fullStart); + var importClause = createNode(248 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20396,7 +20481,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); } return finishNode(importClause); } @@ -20406,7 +20491,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(254 /* ExternalModuleReference */); + var node = createNode(257 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20429,7 +20514,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(246 /* NamespaceImport */); + var namespaceImport = createNode(249 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20444,14 +20529,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252 /* ExportSpecifier */); + return parseImportOrExportSpecifier(255 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248 /* ImportSpecifier */); + return parseImportOrExportSpecifier(251 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20476,19 +20561,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250 /* ExportDeclaration */; + node.kind = 253 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(254 /* 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. @@ -20501,7 +20586,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249 /* ExportAssignment */; + node.kind = 252 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20521,10 +20606,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ - || node.kind === 244 /* ImportDeclaration */ - || node.kind === 249 /* ExportAssignment */ - || node.kind === 250 /* ExportDeclaration */ + || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ + || node.kind === 247 /* ImportDeclaration */ + || node.kind === 252 /* ExportAssignment */ + || node.kind === 253 /* ExportDeclaration */ ? node : undefined; } @@ -20587,7 +20672,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20647,17 +20732,16 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var state = 1 /* SawAsterisk */; @@ -20743,9 +20827,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -20757,7 +20840,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286 /* JSDocComment */, start); + var result = createNode(289 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20874,6 +20957,16 @@ var ts; indent += whitespace.length; } break; + case 17 /* OpenBraceToken */: + state = 2 /* SavingComments */; + if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token @@ -20895,7 +20988,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289 /* JSDocTag */, atToken.pos); + var result = createNode(292 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20955,8 +21048,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(299 /* JSDocPropertyTag */, atToken.pos) : - createNode(293 /* JSDocParameterTag */, atToken.pos); + createNode(302 /* JSDocPropertyTag */, atToken.pos) : + createNode(296 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -20976,18 +21069,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 293 /* JSDocParameterTag */ || child.kind === 299 /* JSDocPropertyTag */) { + if (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -20998,27 +21091,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocReturnTag */, atToken.pos); + var result = createNode(297 /* 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 === 296 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296 /* JSDocTypeTag */, atToken.pos); + var result = createNode(299 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -21026,7 +21119,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -21038,7 +21131,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(185 /* PropertyAccessExpression */, node.pos); + var prop = createNode(187 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -21046,13 +21139,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291 /* JSDocClassTag */, atToken.pos); + var tag = createNode(294 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295 /* JSDocThisTag */, atToken.pos); + var tag = createNode(298 /* JSDocThisTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); @@ -21062,7 +21155,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(301 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21078,9 +21171,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 296 /* JSDocTypeTag */) { + if (child.kind === 299 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21112,7 +21205,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21126,7 +21219,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21135,7 +21228,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288 /* JSDocSignature */, start); + var jsdocSignature = createNode(291 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -21143,7 +21236,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 294 /* JSDocReturnTag */) { + if (tag && tag.kind === 297 /* JSDocReturnTag */) { return tag; } } @@ -21188,9 +21281,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 /* JSDocParameterTag */ && + if (child && (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -21264,7 +21357,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(300 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22068,6 +22161,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -23237,7 +23331,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 270 /* PropertyAssignment */) { + if (element.kind !== 273 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -23314,13 +23408,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -23337,7 +23431,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25425,24 +25519,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 238 /* EnumDeclaration */: - if (ts.isConst(node)) { + case 241 /* EnumDeclaration */: + if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 240 /* ModuleBlock */: { + case 243 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -25464,7 +25558,7 @@ var ts; }); return state_1; } - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -25623,7 +25717,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -25648,32 +25742,32 @@ var ts; return "__constructor" /* Constructor */; case 163 /* FunctionType */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return "__call" /* Call */; case 164 /* ConstructorType */: case 159 /* ConstructSignature */: return "__new" /* New */; case 160 /* IndexSignature */: return "__index" /* Index */; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 149 /* 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 === 284 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -25767,7 +25861,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 && - (node.kind === 249 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 252 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -25792,7 +25886,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -25859,7 +25953,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -25904,7 +25998,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -25953,8 +26047,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -25986,77 +26080,78 @@ var ts; return; } switch (node.kind) { - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: bindWhileStatement(node); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: bindDoStatement(node); break; - case 220 /* ForStatement */: + case 223 /* ForStatement */: bindForStatement(node); break; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: bindIfStatement(node); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: bindTryStatement(node); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: bindSwitchStatement(node); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: bindCaseBlock(node); break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: bindCaseClause(node); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: bindLabeledStatement(node); break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: bindCallExpressionFlow(node); break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 274 /* SourceFile */: + case 277 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213 /* Block */: - case 240 /* ModuleBlock */: + } + case 216 /* Block */: + case 243 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -26069,15 +26164,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return hasNarrowableArgument(expr); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -26086,7 +26181,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -26097,7 +26192,7 @@ var ts; } } } - if (expr.expression.kind === 185 /* PropertyAccessExpression */ && + if (expr.expression.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -26130,9 +26225,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -26210,33 +26305,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return parent.expression === node; - case 220 /* ForStatement */: - case 201 /* ConditionalExpression */: + case 223 /* ForStatement */: + case 203 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191 /* ParenthesizedExpression */) { + if (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 /* ParenthesizedExpression */ || - node.parent.kind === 198 /* PrefixUnaryExpression */ && + while (node.parent.kind === 193 /* ParenthesizedExpression */ || + node.parent.kind === 200 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -26278,7 +26373,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -26312,13 +26407,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222 /* ForOfStatement */) { + if (node.kind === 225 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233 /* VariableDeclarationList */) { + if (node.initializer.kind !== 236 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -26340,7 +26435,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225 /* ReturnStatement */) { + if (node.kind === 228 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -26360,7 +26455,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -26456,7 +26551,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* 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; @@ -26524,14 +26619,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -26542,10 +26637,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183 /* ArrayLiteralExpression */) { + else if (node.kind === 185 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204 /* SpreadElement */) { + if (e.kind === 206 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -26553,16 +26648,16 @@ var ts; } } } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270 /* PropertyAssignment */) { + if (p.kind === 273 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271 /* ShorthandPropertyAssignment */) { + else if (p.kind === 274 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272 /* SpreadAssignment */) { + else if (p.kind === 275 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -26618,7 +26713,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26629,7 +26724,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -26676,10 +26771,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 === 191 /* ParenthesizedExpression */) { + while (expr.kind === 193 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { + if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -26687,7 +26782,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26696,21 +26791,21 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 266 /* JsxAttributes */: return 1 /* IsContainer */; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 179 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -26718,32 +26813,32 @@ var ts; } // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: - case 284 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: case 163 /* FunctionType */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 269 /* CatchClause */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 241 /* CaseBlock */: + case 272 /* CatchClause */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 244 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 213 /* Block */: + case 216 /* 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 @@ -26776,20 +26871,20 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 184 /* ObjectLiteralExpression */: - case 236 /* InterfaceDeclaration */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 186 /* ObjectLiteralExpression */: + case 239 /* InterfaceDeclaration */: + case 266 /* 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 @@ -26800,21 +26895,21 @@ var ts; case 164 /* ConstructorType */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 160 /* IndexSignature */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 284 /* JSDocFunctionType */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 287 /* JSDocFunctionType */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 240 /* TypeAliasDeclaration */: + case 179 /* 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 @@ -26835,11 +26930,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { + var body = node.kind === 277 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { + if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { return true; } } @@ -26923,7 +27018,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -26935,7 +27030,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -26967,10 +27062,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -27111,8 +27206,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 274 /* SourceFile */ && - blockScopeContainer.kind !== 239 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 277 /* SourceFile */ && + blockScopeContainer.kind !== 242 /* 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. @@ -27208,7 +27303,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1 /* EndOfFileToken */) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -27266,11 +27365,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -27278,7 +27377,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -27306,19 +27405,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return checkStrictModeCatchClause(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkStrictModeWithStatement(node); - case 174 /* ThisType */: + case 176 /* ThisType */: seenThisKeyword = true; return; case 161 /* TypePredicate */: @@ -27327,18 +27426,18 @@ var ts; return bindTypeParameter(node); case 149 /* Parameter */: return bindParameter(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); case 158 /* CallSignature */: case 159 /* ConstructSignature */: @@ -27351,7 +27450,7 @@ var ts; // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 67208127 /* MethodExcludes */); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -27360,83 +27459,83 @@ var ts; case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 177 /* MappedType */: + case 290 /* JSDocTypeLiteral */: + case 179 /* MappedType */: return bindAnonymousTypeWorker(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return bindFunctionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return bindJsxAttributes(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return bindImportClause(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return bindExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return bindExportAssignment(node); - case 274 /* SourceFile */: + case 277 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213 /* Block */: + case 216 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 293 /* JSDocParameterTag */: - if (node.parent.kind === 288 /* JSDocSignature */) { + case 296 /* JSDocParameterTag */: + if (node.parent.kind === 291 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { break; } // falls through - case 299 /* JSDocPropertyTag */: + case 302 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -27468,7 +27567,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; ? 2097152 /* Alias */ // An export default clause with any other expression exports a value @@ -27482,7 +27581,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274 /* SourceFile */) { + if (node.parent.kind !== 277 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -27567,8 +27666,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -27595,7 +27694,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -27607,7 +27706,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -27664,9 +27763,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + : propertyAccess.parent.parent.kind === 277 /* SourceFile */; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; @@ -27760,7 +27859,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -27793,7 +27892,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); } @@ -27823,7 +27922,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { + if (node.kind === 296 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -27900,7 +27999,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 172 /* InferType */) { + else if (node.parent.kind === 174 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -27928,13 +28027,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || // report error on class declarations - node.kind === 235 /* ClassDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -27991,43 +28090,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); @@ -28038,11 +28137,11 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -28094,12 +28193,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* 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 === 58 /* EqualsToken */ && leftKind === 183 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -28148,8 +28247,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 === 208 /* AsExpression */ - || expressionKind === 190 /* TypeAssertionExpression */) { + if (expressionKind === 210 /* AsExpression */ + || expressionKind === 192 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -28526,13 +28625,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -28543,25 +28642,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 209 /* NonNullExpression */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 211 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: case 10 /* JsxText */: - case 258 /* JsxClosingElement */: - case 259 /* JsxFragment */: - case 260 /* JsxOpeningFragment */: - case 261 /* JsxClosingFragment */: - case 262 /* JsxAttribute */: - case 263 /* JsxAttributes */: - case 264 /* JsxSpreadAttribute */: - case 265 /* JsxExpression */: + case 261 /* JsxClosingElement */: + case 262 /* JsxFragment */: + case 263 /* JsxOpeningFragment */: + case 264 /* JsxClosingFragment */: + case 265 /* JsxAttribute */: + case 266 /* JsxAttributes */: + case 267 /* JsxSpreadAttribute */: + case 268 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -28569,11 +28668,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: - case 271 /* ShorthandPropertyAssignment */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 274 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -28587,14 +28686,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -28621,19 +28720,21 @@ var ts; case 166 /* TypeLiteral */: case 167 /* ArrayType */: case 168 /* TupleType */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 171 /* ConditionalType */: - case 172 /* InferType */: - case 173 /* ParenthesizedType */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 174 /* ThisType */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: - case 178 /* LiteralType */: - case 242 /* NamespaceExportDeclaration */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 174 /* InferType */: + case 175 /* ParenthesizedType */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: + case 245 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; @@ -28655,10 +28756,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -28670,18 +28771,18 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; @@ -28691,7 +28792,7 @@ var ts; // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -28709,8 +28810,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 183 /* ArrayLiteralExpression */: - case 188 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: + case 190 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -28718,26 +28819,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -28753,27 +28854,27 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 183 /* ArrayLiteralExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return 942011713 /* ClassExcludes */; case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; @@ -28795,24 +28896,24 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 269 /* CatchClause */: + case 272 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: - case 191 /* ParenthesizedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: + case 193 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -29101,6 +29202,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -29174,7 +29276,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -29272,6 +29373,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -29330,7 +29432,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -29387,6 +29489,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; /** @@ -29600,143 +29703,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); - }, - buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } - symbolToString(symbol, enclosingDeclaration, meaning, flags | 4 /* AllowAnyNodeKind */, emitTextWriterWrapper(writer)); - }, - buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildParameterDisplay: function (symbol, writer, enclosing, flags) { - var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { - var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 8192 /* OmitParameterModifiers */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896 /* TypeParameters */, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { - var printer = ts.createPrinter({ removeComments: true }); - var flags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */ | toNodeBuilderFlags(originalFlags); - var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; // TODO: GH#18217 - var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); // TODO: GH#18217 - printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForTypeParametersAndDelimiters: function (typeParameters, writer, enclosing, flags) { - var printer = ts.createPrinter({ removeComments: true }); - var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); // TODO: GH#18217 - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -29774,6 +29740,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -29899,22 +29890,57 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), 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 & 384 /* Enum */ || source.flags & 384 /* Enum */ + var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); + var isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 /* LessThan */ ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -29989,7 +30015,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -30047,17 +30073,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 182 /* BindingElement */) { + if (declaration.kind === 184 /* 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, 182 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 184 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || 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, 232 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235 /* VariableDeclaration */), usage); } - else if (declaration.kind === 232 /* VariableDeclaration */) { + else if (declaration.kind === 235 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -30075,12 +30101,12 @@ var ts; // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 249 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 252 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -30088,9 +30114,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214 /* VariableStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 217 /* VariableStatement */: + case 223 /* ForStatement */: + case 225 /* 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)) { @@ -30162,7 +30188,7 @@ 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 & 67901928 /* Type */ && lastLocation.kind !== 286 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -30182,7 +30208,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171 /* ConditionalType */) { + else if (location.kind === 173 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -30196,14 +30222,14 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 277 /* 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.get("default" /* Default */)) { @@ -30227,7 +30253,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { break; } } @@ -30241,7 +30267,7 @@ var ts; } } break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -30264,9 +30290,9 @@ var ts; } } break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -30282,7 +30308,7 @@ var ts; } break loop; } - if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -30290,7 +30316,7 @@ var ts; } } break; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -30312,7 +30338,7 @@ var ts; // case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -30325,14 +30351,14 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -30367,8 +30393,8 @@ var ts; location = location.parent; } break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -30387,7 +30413,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -30461,7 +30487,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67216319 /* Value */) === 67216319 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 242 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -30470,12 +30496,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 239 /* ModuleDeclaration */: // For `namespace N { N; }` + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -30543,9 +30569,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -30609,18 +30635,26 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238 /* EnumDeclaration */) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32 /* Class */) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256 /* RegularEnum */) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -30633,13 +30667,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 245 /* ImportClause */: + case 248 /* ImportClause */: return node.parent; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return node.parent.parent; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -30649,7 +30683,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -30837,20 +30871,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 249 /* ExportAssignment */: - case 200 /* BinaryExpression */: + case 252 /* ExportAssignment */: + case 202 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -30911,11 +30945,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 252 /* ExportSpecifier */) { + else if (node.kind === 255 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -30943,7 +30977,7 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -30967,7 +31001,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -31132,10 +31166,19 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages( + /*details*/ undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)) + : undefined; errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -31161,7 +31204,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -31394,6 +31437,12 @@ var ts; var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -31412,25 +31461,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -31446,12 +31489,12 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -31548,7 +31591,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -31660,10 +31703,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -31716,8 +31759,8 @@ var ts; // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || - entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || + entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -31799,64 +31842,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; // TODO: GH#18217 + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -31864,6 +31876,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -31981,7 +31995,7 @@ var ts; var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -32050,7 +32064,7 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -32088,7 +32102,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; + return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -32136,8 +32150,15 @@ var ts; } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -32351,7 +32372,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -32405,7 +32426,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -32413,7 +32434,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; - var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -32422,7 +32443,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; + var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -32432,7 +32454,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 182 /* BindingElement */) { + if (clone.kind === 184 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -32516,17 +32538,49 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + if (context.tracker.trackReferencedAmbientModule) { + var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); + if (ts.length(ambientDecls)) { + for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { + var decl = ambientDecls_1[_i]; + context.tracker.trackReferencedAmbientModule(decl, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= 16777216 /* InInitialEntityName */; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216 /* InInitialEntityName */; var isTypeOf = meaning === 67216319 /* Value */; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -32700,8 +32754,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173 /* ParenthesizedType */; }); - if (node.kind === 237 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); + if (node.kind === 240 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -32709,11 +32763,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 /* ModuleBlock */ && + node.parent.kind === 243 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -32733,42 +32787,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 - var file = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); - if (!file || !context.tracker.moduleResolverHost) { - if (context.tracker.trackReferencedAmbientModule) { - var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); - if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; - context.tracker.trackReferencedAmbientModule(decl); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205 /* ClassExpression */: - return "(Anonymous class)"; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - return "(Anonymous function)"; + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + context.encounteredError = true; + } + return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -32793,27 +32827,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 234 /* FunctionDeclaration */: - case 238 /* EnumDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 241 /* EnumDeclaration */: + case 246 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -32821,7 +32855,7 @@ var ts; 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 !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -32843,31 +32877,31 @@ var ts; case 158 /* CallSignature */: case 160 /* IndexSignature */: case 149 /* Parameter */: - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: case 162 /* TypeReference */: case 167 /* ArrayType */: case 168 /* TupleType */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 173 /* ParenthesizedType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 175 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: return false; // Type parameters are always visible case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 274 /* SourceFile */: - case 242 /* NamespaceExportDeclaration */: + case 277 /* SourceFile */: + case 245 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return false; default: return false; @@ -32876,10 +32910,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 252 /* ExportSpecifier */) { + else if (node.parent.kind === 255 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -32975,12 +33009,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232 /* VariableDeclaration */: - case 233 /* VariableDeclarationList */: - case 248 /* ImportSpecifier */: - case 247 /* NamedImports */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 235 /* VariableDeclaration */: + case 236 /* VariableDeclarationList */: + case 251 /* ImportSpecifier */: + case 250 /* NamedImports */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: return false; default: return true; @@ -33057,7 +33091,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180 /* ObjectBindingPattern */) { + if (pattern.kind === 182 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -33127,22 +33161,27 @@ var ts; // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); + // If the parent is a tuple type, the rest element has an array type with a union of the + // remaining tuple element types. Otherwise, the rest element has an array type with same + // element type as the parent type. + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -33153,7 +33192,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2 /* Subtype */) : type; } @@ -33170,7 +33209,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -33180,11 +33219,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* 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, @@ -33203,7 +33242,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // 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 @@ -33275,20 +33314,20 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : - declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : ts.getSpecialPropertyAssignmentKind(expression); if (special === 4 /* ThisProperty */) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. declarationInConstructor = thisContainer.kind === 155 /* Constructor */ || - thisContainer.kind === 234 /* FunctionDeclaration */ || - (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 /* FunctionDeclaration */ || + (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -33309,7 +33348,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { // If we don't have an explicit JSDoc type, get the type from the expression. var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 /* Anonymous */ && @@ -33391,7 +33430,7 @@ var ts; // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -33436,12 +33475,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } - // If the pattern has at least one element, and no rest element, then it should imply a tuple type. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -33458,7 +33498,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 /* ObjectBindingPattern */ + return pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -33527,7 +33567,7 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 249 /* ExportAssignment */) { + if (declaration.kind === 252 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -33731,8 +33771,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 202 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 187 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 202 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -33869,35 +33909,35 @@ var ts; return undefined; } switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 153 /* MethodSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 177 /* MappedType */: - case 171 /* ConditionalType */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 179 /* MappedType */: + case 173 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177 /* MappedType */) { + if (node.kind === 179 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171 /* ConditionalType */) { + else if (node.kind === 173 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && + (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -33905,7 +33945,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, 236 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -33914,9 +33954,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 235 /* ClassDeclaration */ || - node.kind === 205 /* ClassExpression */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || + node.kind === 207 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -33950,15 +33990,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - // Prefer an @augments tag because it may have type parameters. - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -33981,7 +34013,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -34014,7 +34046,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { if (type.symbol.flags & 32 /* Class */) { @@ -34077,7 +34109,7 @@ var ts; // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a // partial instantiation of the members without the base types fully resolved - type.members = undefined; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -34102,7 +34134,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -34138,7 +34170,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */) { + if (declaration.kind === 239 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -34196,7 +34228,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -34223,7 +34255,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 200 /* BinaryExpression */) { + else if (expr.kind === 202 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -34237,12 +34269,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 71 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -34256,7 +34288,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -34283,7 +34315,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 @@ -34373,7 +34405,7 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 178 /* LiteralType */: + case 180 /* LiteralType */: return true; case 167 /* ArrayType */: return isThislessType(node.elementType); @@ -34753,6 +34785,28 @@ var ts; return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 /* RestParameter */ : + i >= minLength_1 ? 4096 /* OptionalParameter */ : 0; + var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); @@ -34930,6 +34984,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); @@ -34938,6 +34993,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); @@ -35096,7 +35152,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 175 /* TypeOperator */ && + return constraintDeclaration.kind === 177 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -35216,6 +35272,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144 /* Union */)) { @@ -35673,10 +35740,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJavaScriptFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 283 /* JSDocOptionalType */ + node.type && node.type.kind === 286 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -35695,7 +35762,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -35710,7 +35777,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -35805,7 +35872,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178 /* LiteralType */) { + if (type && type.kind === 180 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -35853,9 +35920,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 8192 /* RestParameter */); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { // Replace the last parameter with a rest parameter. parameters.pop(); @@ -35961,9 +36027,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -36006,16 +36072,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1 /* Number */) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -36117,32 +36180,40 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - // When an 'infer T' declaration is immediately contained in a type reference node - // (such as 'Foo'), T's constraint is inferred from the constraint of the - // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are - // present, we form an intersection of the inferred constraint types. - if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - // Type parameter constraints can reference other type parameters so - // constraints need to be instantiated. If instantiation produces the - // type parameter itself, we discard that inference. For example, in - // type Foo = [T, U]; - // type Bar = T extends Foo ? Foo : T; - // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174 /* InferType */) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162 /* TypeReference */) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + // When an 'infer T' declaration is immediately contained in a rest parameter + // declaration, we infer an 'unknown[]' constraint. + else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -36237,7 +36308,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 290 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 293 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -36296,7 +36367,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -36389,9 +36460,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -36503,9 +36574,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return declaration; } } @@ -36626,18 +36697,26 @@ var ts; // // Note that the generic type created by this function has no symbol associated with it. The same // is true for each of the synthesized type parameters. - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536 /* TypeParameter */); - typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + if (i < maxLength) { + var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4 /* Property */, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; @@ -36655,21 +36734,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -37063,7 +37168,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -37128,7 +37233,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -37148,6 +37253,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { @@ -37158,7 +37269,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -37175,14 +37286,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } @@ -37288,7 +37407,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to 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 (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -37428,7 +37547,7 @@ var ts; return true; } while (node) { - if (node.kind === 171 /* ConditionalType */) { + if (node.kind === 173 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -37526,7 +37645,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } else { - error(node, targetMeaning === 67216319 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + var errorMessage = targetMeaning === 67216319 /* Value */ + ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here + : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -37732,7 +37854,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -37751,8 +37873,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return anyType; case 142 /* UnknownKeyword */: return unknownType; @@ -37774,16 +37896,16 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 162 /* TypeReference */: return getTypeFromTypeReference(node); case 161 /* TypePredicate */: return booleanType; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); @@ -37791,38 +37913,41 @@ var ts; return getTypeFromArrayTypeNode(node); case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return getTypeFromOptionalTypeNode(node); + case 171 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 173 /* ParenthesizedType */: - case 282 /* JSDocNonNullableType */: - case 278 /* JSDocTypeExpression */: + case 175 /* ParenthesizedType */: + case 170 /* RestType */: + case 285 /* JSDocNonNullableType */: + case 281 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 172 /* InferType */: + case 174 /* InferType */: return getTypeFromInferTypeNode(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode @@ -37971,7 +38096,7 @@ 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(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | (ts.getCheckFlags(symbol) & 1024 /* Late */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (1024 /* Late */ | 4096 /* OptionalParameter */ | 8192 /* RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -37982,11 +38107,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -38051,14 +38171,14 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 213 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -38196,32 +38316,32 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive); - case 262 /* JsxAttribute */: { + case 265 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265 /* JsxExpression */: { + case 268 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -38238,7 +38358,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -38248,7 +38368,7 @@ var ts; } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 213 /* Block */ ? false : isContextSensitive(body); + return body.kind === 216 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -38318,8 +38438,206 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268 /* JsxExpression */: + case 193 /* ParenthesizedExpression */: + return elaborateError(node.expression, source, target); + case 202 /* BinaryExpression */: + switch (node.operatorToken.kind) { + case 58 /* EqualsToken */: + case 26 /* CommaToken */: + return elaborateError(node.right, source, target); + } + break; + case 186 /* ObjectLiteralExpression */: + return elaborateObjectLiteral(node, source, target); + case 185 /* ArrayLiteralExpression */: + return elaborateArrayLiteral(node, source, target); + case 266 /* JsxAttributes */: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator, source, target) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + var resultObj = {}; + // Use the expression type, if available + var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + getIndexInfoOfType(target, 0 /* String */) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3 /*break*/, 3]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2 /*return*/]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3 /*break*/, 4]; + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3 /*break*/, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3 /*break*/, 3]; + nameType = getLiteralType(i); + return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3 /*break*/, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 32768 /* Never */)) { + return [3 /*break*/, 7]; + } + _b = prop.kind; + switch (_b) { + case 157 /* SetAccessor */: return [3 /*break*/, 2]; + case 156 /* GetAccessor */: return [3 /*break*/, 2]; + case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + } + return [3 /*break*/, 6]; + case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3 /*break*/, 7]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3 /*break*/, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** * This is *not* a bi-directional relationship. @@ -38340,13 +38658,20 @@ var ts; if (source === target) { return -1 /* True */; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0 /* False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0 /* False */; + } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; @@ -38367,14 +38692,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -38393,7 +38715,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0 /* False */; } @@ -38468,30 +38790,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - // If both have rest parameters, get the max and add 1 to - // compensate for the rest parameter. - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - // Return the count for whichever signature doesn't have rest parameters. - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -38512,11 +38810,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { + return relation === 1 /* Succeeded */; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, false); + enumRelation.set(id, 3 /* FailedAndReported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -38527,13 +38825,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); + enumRelation.set(id, 3 /* FailedAndReported */); + } + else { + enumRelation.set(id, 2 /* Failed */); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1 /* Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -38624,7 +38925,7 @@ var ts; * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -38654,12 +38955,16 @@ var ts; var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); // Cause the error to appear with the error that triggered it + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); // Cause the error to appear with the error that triggered it } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); // TODO: GH#18217 + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { @@ -38741,6 +39046,22 @@ var ts; if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); + if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + target = nullStrippedTarget; + } + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; @@ -38992,11 +39313,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } return 0 /* False */; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072 /* Object */) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4 /* Reference */) { + return source.target === target.target; + } + if (overlapObjFlags & 16 /* Anonymous */) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { var match; @@ -39128,9 +39467,8 @@ var ts; 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.set(id, 3 /* FailedAndReported */); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -39417,7 +39755,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -39440,6 +39778,33 @@ var ts; } } var result = -1 /* True */; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0 /* False */; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0 /* False */; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0 /* False */; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -39961,20 +40326,26 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); // A source signature matches a target signature if the two signatures have the same number of required, // optional, and rest parameters. - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } // A source signature partially matches a target signature if the target signature has no fewer required // parameters and no more overall parameters than the source signature (where a signature with a rest // parameter is always considered to have more overall parameters than one without). - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -40016,10 +40387,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0 /* False */; @@ -40039,9 +40410,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -40091,7 +40459,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); @@ -40138,6 +40511,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -40197,7 +40576,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -40410,7 +40789,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -40420,23 +40799,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 177 /* MappedType */: + case 179 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -40453,24 +40832,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -40609,10 +40986,14 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - // Two tuple types with different arity are definitely unrelated. + // Two tuple types with incompatible arities are definitely unrelated. // Two object types that each have a property that is unmatched in the other are definitely unrelated. - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) && !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false); } function getTypeFromInference(inference) { @@ -40895,12 +41276,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -41015,17 +41417,14 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + // If we have contravariant inferences we find the best common subtype and treat + // that as a single covariant candidate. + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { inferredType = getCovariantInference(inference, context, signature); - // If we have inferred 'never' but have contravariant candidates. To get a more specific type we - // infer from the contravariant candidates instead. - if (inferredType.flags & 32768 /* Never */ && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - // We only have contravariant inferences, infer the best common subtype of those - inferredType = getContravariantInference(inference); } else if (context.flags & 2 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -41102,13 +41501,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 185 /* PropertyAccessExpression */) { + if (node.kind === 187 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182 /* BindingElement */) { + if (node.kind === 184 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -41117,7 +41516,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180 /* ObjectBindingPattern */) { + if (parent.kind === 182 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: @@ -41140,26 +41539,26 @@ var ts; switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && + (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 185 /* PropertyAccessExpression */: - return target.kind === 185 /* PropertyAccessExpression */ && + case 187 /* PropertyAccessExpression */: + return target.kind === 187 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182 /* BindingElement */: - if (target.kind !== 185 /* PropertyAccessExpression */) + case 184 /* BindingElement */: + if (target.kind !== 187 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232 /* VariableDeclaration */) { + if (source.parent.parent.kind === 235 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -41167,7 +41566,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185 /* PropertyAccessExpression */) { + while (source.kind === 187 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -41180,7 +41579,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 === 185 /* PropertyAccessExpression */ && + return target.kind === 187 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -41188,7 +41587,7 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185 /* PropertyAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -41232,7 +41631,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -41358,7 +41757,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; } @@ -41366,15 +41765,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -41391,21 +41790,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return stringType; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return undefinedType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -41413,7 +41812,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 /* ObjectBindingPattern */ ? + var type = pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -41431,35 +41830,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221 /* ForInStatement */) { + if (node.parent.parent.kind === 224 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.parent.kind === 225 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 /* VariableDeclaration */ ? + return node.kind === 235 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? + return node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 /* VariableDeclaration */ && node.initializer && + return node.kind === 235 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && + node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -41471,13 +41870,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 191 /* ParenthesizedExpression */ || - parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 193 /* ParenthesizedExpression */ || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -41640,11 +42039,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 185 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 187 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 186 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 200 /* BinaryExpression */ && + parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -41692,7 +42091,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 = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -41763,7 +42162,7 @@ var ts; else if (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 !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 187 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -41819,7 +42218,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 /* CallExpression */ ? + var expr = node.kind === 189 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -41827,7 +42226,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -41992,7 +42391,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 /* PropertyAccessExpression */ && + return expr.kind === 187 /* PropertyAccessExpression */ && computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -42043,10 +42442,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 === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -42261,7 +42660,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -42281,15 +42680,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -42325,8 +42724,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 /* ModuleBlock */ || - node.kind === 274 /* SourceFile */ || + node.kind === 243 /* ModuleBlock */ || + node.kind === 277 /* SourceFile */ || node.kind === 152 /* PropertyDeclaration */; }); } @@ -42372,10 +42771,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 185 /* PropertyAccessExpression */ || - parent.kind === 187 /* CallExpression */ && parent.expression === node || - parent.kind === 186 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 182 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 187 /* PropertyAccessExpression */ || + parent.kind === 189 /* CallExpression */ && parent.expression === node || + parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); @@ -42409,7 +42808,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 */)) { @@ -42430,7 +42829,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.kind === 235 /* ClassDeclaration */ + if (declaration.kind === 238 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -42442,12 +42841,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205 /* ClassExpression */) { + else if (declaration.kind === 207 /* 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.kind !== 274 /* SourceFile */) { + while (container.kind !== 277 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; @@ -42497,23 +42896,23 @@ var ts; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - var isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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 === 192 /* FunctionExpression */ || - flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 /* FunctionExpression */ || + flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). - var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 252 /* ExportSpecifier */) || - node.parent.kind === 209 /* NonNullExpression */ || - declaration.kind === 232 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || + node.parent.kind === 211 /* NonNullExpression */ || + declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -42544,7 +42943,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -42569,8 +42968,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 === 220 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && + if (container.kind === 223 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -42584,7 +42983,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 191 /* ParenthesizedExpression */) { + while (current.parent.kind === 193 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -42592,7 +42991,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -42650,7 +43049,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); // If a containing class does not have extends clause or the class extends null // skip checking whether super statement is called before "this" accessing. if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -42677,17 +43076,17 @@ var ts; 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 === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 238 /* EnumDeclaration */: + case 241 /* 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; @@ -42725,8 +43124,8 @@ 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 === 192 /* FunctionExpression */ && - container.parent.kind === 200 /* BinaryExpression */ && + if (container.kind === 194 /* FunctionExpression */ && + container.parent.kind === 202 /* BinaryExpression */ && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.prototype.y = f @@ -42757,7 +43156,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -42774,12 +43173,12 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 /* 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 === 193 /* ArrowFunction */) { + while (container && container.kind === 195 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -42799,7 +43198,7 @@ var ts; 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 === 184 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -42887,7 +43286,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184 /* ObjectLiteralExpression */) { + if (container.parent.kind === 186 /* 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 errorType; @@ -42899,7 +43298,7 @@ var ts; } // at this point the only legal case for parent is ClassLikeDeclaration var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -42931,7 +43330,7 @@ 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 === 184 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 154 /* MethodDeclaration */ || container.kind === 153 /* MethodSignature */ || @@ -42955,8 +43354,8 @@ var ts; function getContainingObjectLiteral(func) { return (func.kind === 154 /* MethodDeclaration */ || func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 184 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 192 /* FunctionExpression */ && func.parent.kind === 270 /* PropertyAssignment */ ? func.parent.parent : + func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -42968,7 +43367,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193 /* ArrowFunction */) { + if (func.kind === 195 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -42995,7 +43394,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270 /* PropertyAssignment */) { + if (literal.parent.kind !== 273 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -43009,9 +43408,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { + if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -43034,27 +43433,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. @@ -43064,10 +43460,8 @@ var ts; return getTypeAtPosition(contextualSignature, indexOfParameter); } // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -43098,7 +43492,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182 /* BindingElement */) { + if (parentDeclaration.kind !== 184 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -43180,7 +43574,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189 /* TaggedTemplateExpression */) { + if (template.parent.kind === 191 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -43228,8 +43622,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504 /* StructuredType */) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, /*noReductions*/ true); } function getIndexTypeOfContextualType(type, kind) { @@ -43258,8 +43663,8 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -43325,8 +43730,8 @@ var ts; case 95 /* NullKeyword */: case 71 /* Identifier */: return true; - case 185 /* PropertyAccessExpression */: - case 191 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 193 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -43345,14 +43750,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270 /* PropertyAssignment */) + if (prop.kind !== 273 /* PropertyAssignment */) continue; if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine @@ -43393,52 +43798,52 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 193 /* ArrowFunction */: - case 225 /* ReturnStatement */: + case 195 /* ArrowFunction */: + case 228 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 183 /* ArrayLiteralExpression */: { + case 185 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 211 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); + case 214 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -43512,6 +43917,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -43522,8 +43928,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) @@ -43539,7 +43961,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -43584,11 +44007,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; + return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -43660,18 +44082,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 182 /* BindingElement */ && !!node.initializer) || - (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 184 /* BindingElement */ && !!node.initializer) || + (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -43696,13 +44119,17 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; + if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } @@ -43710,28 +44137,30 @@ 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 === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - if (patternElement.kind !== 206 /* OmittedExpression */) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { + if (e.kind !== 208 /* OmittedExpression */) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2 /* Subtype */); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2 /* Subtype */) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -43816,7 +44245,7 @@ var ts; var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -43830,11 +44259,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 /* PropertyAssignment */ || - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 273 /* PropertyAssignment */ || + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -43855,8 +44284,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -43881,7 +44310,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272 /* SpreadAssignment */) { + else if (memberDecl.kind === 275 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -43975,13 +44404,16 @@ var ts; type.flags & 131072 /* Object */ && !isGenericMappedType(type) || type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { + function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -43989,6 +44421,9 @@ var ts; else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -44011,16 +44446,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - // TODO (yuisu): comment - switch (tagName.kind) { - case 185 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: - return false; - case 71 /* Identifier */: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -44063,7 +44489,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -44086,7 +44512,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 255 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -44247,12 +44673,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -44289,6 +44727,10 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928 /* Type */); + } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -44695,7 +45137,7 @@ var ts; // 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, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. @@ -44716,31 +45158,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -44787,9 +45205,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? + var errorNode = node.kind === 187 /* PropertyAccessExpression */ || node.kind === 235 /* VariableDeclaration */ ? node.name : - node.kind === 179 /* ImportType */ ? + node.kind === 181 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -44959,7 +45377,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 !== 185 /* PropertyAccessExpression */ || + if (node.kind !== 187 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; @@ -44991,16 +45409,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && node.parent.kind !== 162 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -45008,7 +45431,7 @@ var ts; switch (node.kind) { case 152 /* PropertyDeclaration */: return true; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -45064,13 +45487,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319 /* Value */); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319 /* Value */); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -45129,16 +45558,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179 /* ImportType */: + case 181 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -45172,7 +45601,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer.kind === 236 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -45201,7 +45630,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 /* ForInStatement */ && + if (node.kind === 224 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -45219,7 +45648,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 190 /* 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); @@ -45286,7 +45715,7 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (node.kind !== 150 /* Decorator */) { @@ -45352,14 +45781,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204 /* SpreadElement */) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -45371,12 +45797,12 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { // 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 = node.typeArguments; - if (node.template.kind === 202 /* TemplateExpression */) { + if (node.template.kind === 204 /* 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 lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -45398,8 +45824,8 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 188 /* NewExpression */); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190 /* NewExpression */); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. @@ -45412,15 +45838,14 @@ var ts; } // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -45445,9 +45870,10 @@ var ts; // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1 /* InferUnionTypes */, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8 /* ReturnType */); @@ -45497,7 +45923,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -45512,11 +45938,13 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; 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 !== 206 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -45530,6 +45958,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) @@ -45547,6 +45979,35 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + // We are inferring from a spread expression in the last argument position, i.e. both the parameter + // and the argument are ...x forms. + return arg.kind === 213 /* SyntheticExpression */ ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -45606,7 +46067,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 190 /* 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. @@ -45620,24 +46081,32 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; 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 !== 206 /* OmittedExpression */) { - // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) - var paramType = getTypeAtPosition(signature, i); - // If the effective argument type is undefined, there is no synthetic type for the argument. - // In that case, we should check the argument. - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { + if (i === restIndex && (restType.flags & 65536 /* TypeParameter */ || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, /*context*/ undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) + var paramType = getTypeAtPosition(signature, i); + // If the effective argument type is undefined, there is no synthetic type for the argument. + // In that case, we should check the argument. + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } @@ -45647,9 +46116,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { + if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { return callee.expression; } } @@ -45664,10 +46133,10 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [undefined]; // TODO: GH#18217 - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -45684,7 +46153,28 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + // We have a spread argument in the last position and no other spread arguments. If the type + // of the argument is a tuple type, spread the tuple elements into the argument list. We can + // call checkExpressionCached because spread expressions never have a contextual type. + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213 /* SyntheticExpression */, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } /** @@ -45703,8 +46193,8 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; case 152 /* PropertyDeclaration */: @@ -45749,7 +46239,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* 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); @@ -45794,7 +46284,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -45849,7 +46339,7 @@ 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 === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -45898,7 +46388,7 @@ var ts; if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -45911,7 +46401,7 @@ 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 === 150 /* Decorator */ || - (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { + (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -45924,7 +46414,7 @@ var ts; // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -45944,7 +46434,7 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 189 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -46019,7 +46509,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 === 187 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 /* 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 @@ -46066,10 +46556,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -46184,11 +46674,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -46204,7 +46695,7 @@ var ts; if (superType !== errorType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -46383,8 +46874,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -46410,8 +46900,8 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -46487,16 +46977,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -46572,7 +47062,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -46586,7 +47077,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185 /* PropertyAccessExpression */) { + while (parent && parent.kind === 187 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -46618,7 +47109,7 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 188 /* NewExpression */) { + if (node.kind === 190 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 /* Constructor */ && @@ -46692,7 +47183,7 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -46749,9 +47240,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 234 /* FunctionDeclaration */ + ? 237 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 232 /* VariableDeclaration */ + ? 235 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -46829,10 +47320,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1 /* Number */) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536 /* TypeParameter */) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -46871,11 +47459,11 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -46940,7 +47528,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213 /* Block */) { + if (func.body.kind !== 216 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -47029,7 +47617,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -47054,7 +47642,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -47097,11 +47685,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; case 154 /* MethodDeclaration */: - return func.parent.kind === 184 /* ObjectLiteralExpression */; + return func.parent.kind === 186 /* ObjectLiteralExpression */; default: return false; } @@ -47125,7 +47713,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 (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -47165,7 +47753,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -47226,7 +47814,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213 /* Block */) { + if (node.body.kind === 216 /* Block */) { checkSourceElement(node.body); } else { @@ -47239,10 +47827,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -47272,7 +47860,7 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && + (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); @@ -47289,13 +47877,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 246 /* NamespaceImport */; + return !!declaration && declaration.kind === 249 /* NamespaceImport */; } } } @@ -47304,7 +47892,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -47313,7 +47901,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { + if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -47490,7 +48078,7 @@ 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 === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { var name = property.name; if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); @@ -47505,7 +48093,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 274 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -47517,7 +48105,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 272 /* SpreadAssignment */) { + else if (property.kind === 275 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -47552,27 +48140,23 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206 /* OmittedExpression */) { - if (element.kind !== 204 /* SpreadElement */) { + if (element.kind !== 208 /* OmittedExpression */) { + if (element.kind !== 206 /* SpreadElement */) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - // We still need to check element expression here because we may need to set appropriate flag on the expression - // such as NodeCheckFlags.LexicalThis on "this"expression. - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -47581,12 +48165,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -47595,7 +48182,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -47611,25 +48198,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184 /* ObjectLiteralExpression */) { + if (target.kind === 186 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183 /* ArrayLiteralExpression */) { + if (target.kind === 185 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 272 /* SpreadAssignment */ ? + var error = target.parent.kind === 275 /* 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)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -47647,35 +48234,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 189 /* TaggedTemplateExpression */: - case 202 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: - case 193 /* ArrowFunction */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 195 /* TypeOfExpression */: - case 209 /* NonNullExpression */: - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 197 /* TypeOfExpression */: + case 211 /* NonNullExpression */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: return true; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -47687,9 +48274,9 @@ var ts; } return false; // Some forms listed here for clarity - case 196 /* VoidExpression */: // Explicit opt-out - case 190 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 208 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 198 /* VoidExpression */: // Explicit opt-out + case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -47705,7 +48292,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -47904,7 +48491,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -47925,7 +48512,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34 /* EqualsEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -47982,7 +48585,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' return anyType; @@ -48007,7 +48610,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263 /* JsxAttributes */) { + if (node.kind === 266 /* JsxAttributes */) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -48043,7 +48646,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; + return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -48145,7 +48748,7 @@ var ts; function getTypeOfExpression(node, cache) { // 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 === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -48195,8 +48798,8 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { @@ -48232,74 +48835,76 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checkCallExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return checkClassExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return checkAssertion(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return checkNonNullAssertion(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return checkMetaProperty(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkDeleteExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return checkVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return checkAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return undefinedWideningType; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return checkYieldExpression(node); - case 265 /* JsxExpression */: + case 213 /* SyntheticExpression */: + return node.type; + case 268 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return checkJsxElement(node, checkMode); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -48328,6 +48933,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 /* Instantiable */ && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -48354,7 +48962,7 @@ var ts; } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -48415,10 +49023,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 158 /* CallSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 163 /* FunctionType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -48439,7 +49047,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { + else if (name.kind === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -48452,7 +49060,7 @@ var ts; checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + else if (node.kind === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -48517,7 +49125,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -48646,7 +49254,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* 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 @@ -48734,7 +49342,7 @@ var ts; // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -48756,7 +49364,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -48907,11 +49515,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170 /* RestType */) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169 /* OptionalType */) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -48925,7 +49550,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 186 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -48962,7 +49587,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -48978,9 +49603,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 !== 236 /* InterfaceDeclaration */ && - n.parent.kind !== 235 /* ClassDeclaration */ && - n.parent.kind !== 205 /* ClassExpression */ && + if (n.parent.kind !== 239 /* InterfaceDeclaration */ && + n.parent.kind !== 238 /* ClassDeclaration */ && + n.parent.kind !== 207 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported @@ -49110,7 +49735,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -49121,7 +49746,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 === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -49250,22 +49875,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -49273,17 +49898,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 234 /* FunctionDeclaration */: - case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 237 /* FunctionDeclaration */: + case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -49554,7 +50179,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -49617,12 +50242,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -49654,7 +50279,7 @@ var ts; } } return commonEntityName; - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); case 162 /* TypeReference */: return node.typeName; @@ -49687,7 +50312,7 @@ var ts; 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -49776,7 +50401,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -49788,7 +50413,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -49871,27 +50496,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274 /* SourceFile */: - case 239 /* ModuleDeclaration */: - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 242 /* ModuleDeclaration */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -49905,7 +50530,7 @@ var ts; case 159 /* ConstructSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -49918,10 +50543,7 @@ var ts; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -49951,7 +50573,7 @@ var ts; } break; case 160 /* IndexSignature */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: // Can't be private break; default: @@ -49967,7 +50589,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -50002,7 +50624,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -50020,9 +50642,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -50037,7 +50659,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0 /* Local */, unuseds.length === 1 @@ -50055,7 +50677,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -50076,7 +50698,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -50090,22 +50712,22 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; + return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 213 /* Block */) { + if (node.kind === 216 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -50200,7 +50822,7 @@ var ts; } // 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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 /* 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)); } @@ -50215,7 +50837,7 @@ var ts; } // 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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 277 /* 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)); } @@ -50250,7 +50872,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 === 232 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -50262,17 +50884,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 214 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 217 /* 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 === 213 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 240 /* ModuleBlock */ || - container.kind === 239 /* ModuleDeclaration */ || - container.kind === 274 /* SourceFile */); + (container.kind === 216 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 243 /* ModuleBlock */ || + container.kind === 242 /* ModuleDeclaration */ || + container.kind === 277 /* 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 @@ -50298,7 +50920,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 185 /* PropertyAccessExpression */) { + if (n.kind === 187 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -50318,7 +50940,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 182 /* BindingElement */) { + symbol.valueDeclaration.kind === 184 /* 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) { @@ -50371,8 +50993,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182 /* BindingElement */) { - if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 184 /* BindingElement */) { + if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -50393,7 +51015,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -50406,13 +51028,13 @@ var ts; // 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 !== 221 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -50429,8 +51051,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221 /* ForInStatement */) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -50445,7 +51067,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -50455,7 +51077,7 @@ var ts; if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -50470,8 +51092,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || - (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || + (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -50510,7 +51132,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215 /* EmptyStatement */) { + if (node.thenStatement.kind === 218 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -50530,12 +51152,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -50569,14 +51191,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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. @@ -50590,7 +51212,7 @@ var ts; // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -50608,7 +51230,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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); @@ -50622,7 +51244,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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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)) { @@ -50986,7 +51608,7 @@ var ts; } } else if (func.kind === 155 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -51002,7 +51624,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -51035,7 +51657,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 === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -51047,7 +51669,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -51076,7 +51698,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -51174,16 +51796,17 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } // perform property check if property or indexer is declared in 'type' // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || + if (propDeclaration && name && + (propDeclaration.kind === 202 /* BinaryExpression */ || + name.kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -51357,7 +51980,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); @@ -51369,6 +51992,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -51435,7 +52062,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -51454,7 +52081,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -51480,7 +52107,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; + return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -51519,7 +52146,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.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 205 /* ClassExpression */) { + if (derivedClassDecl.kind === 207 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -51633,7 +52260,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -51696,7 +52323,7 @@ var ts; } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -51711,7 +52338,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -51738,7 +52365,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -51748,7 +52375,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -51776,7 +52403,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: var identifier = expr; @@ -51784,14 +52411,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 185 /* PropertyAccessExpression */) { + if (ex.kind === 187 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -51823,8 +52450,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -51838,7 +52465,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304 /* Ambient */) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -51854,7 +52481,7 @@ var ts; if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -51862,7 +52489,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 !== 238 /* EnumDeclaration */) { + if (declaration.kind !== 241 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -51885,8 +52512,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 235 /* ClassDeclaration */ || - (declaration.kind === 234 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 238 /* ClassDeclaration */ || + (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -51949,7 +52576,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, 235 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -51999,23 +52626,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* 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 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -52026,12 +52653,12 @@ var ts; break; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 234 /* FunctionDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -52059,7 +52686,7 @@ var ts; node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -52076,9 +52703,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 250 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -52111,14 +52738,14 @@ var ts; (symbol.flags & 67901928 /* Type */ ? 67901928 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 252 /* ExportSpecifier */ ? + var message = node.kind === 255 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 252 /* ExportSpecifier */ + && node.kind === 255 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -52145,7 +52772,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -52169,7 +52796,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -52205,10 +52832,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -52225,7 +52852,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -52254,8 +52881,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -52343,7 +52970,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -52361,10 +52988,10 @@ 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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -52402,111 +53029,113 @@ var ts; return checkArrayType(node); case 168 /* TupleType */: return checkTupleType(node); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: + case 169 /* OptionalType */: + case 170 /* RestType */: return checkSourceElement(node.type); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return checkTypeOperator(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return checkConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return checkInferType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return checkImportType(node); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 282 /* JSDocNonNullableType */: - case 281 /* JSDocNullableType */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: - case 287 /* JSDocTypeLiteral */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: + case 290 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 278 /* JSDocTypeExpression */: + case 281 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return checkMappedType(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return checkBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return checkVariableStatement(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return checkExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return checkIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return checkDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return checkWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return checkForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return checkForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkForOfStatement(node); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return checkReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return checkSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return checkLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return checkThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return checkTryStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return checkBindingElement(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return checkClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return checkImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return checkExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return checkExportAssignment(node); - case 215 /* EmptyStatement */: - case 231 /* DebuggerStatement */: + case 218 /* EmptyStatement */: + case 234 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -52583,15 +53212,15 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -52600,11 +53229,17 @@ var ts; case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: checkClassExpressionDeferred(node); break; + case 259 /* JsxSelfClosingElement */: + checkJsxSelfClosingElementDeferred(node); + break; + case 258 /* JsxElement */: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -52639,7 +53274,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -52733,13 +53368,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -52747,8 +53382,8 @@ var ts; // falls 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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* 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. @@ -52757,7 +53392,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -52806,10 +53441,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148 /* TypeParameter */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -52823,10 +53458,10 @@ var ts; return node.parent.kind === 162 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185 /* PropertyAccessExpression */) { + while (node.parent.kind === 187 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 207 /* ExpressionWithTypeArguments */; + return node.parent.kind === 209 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -52857,10 +53492,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -52886,7 +53521,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -52896,7 +53531,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 /* PropertyAccessExpression */ && + entityName.parent.kind === 187 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -52904,7 +53539,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -52914,7 +53549,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 243 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -52932,7 +53567,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 === 207 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -52948,10 +53583,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293 /* JSDocParameterTag */) { + if (entityName.parent.kind === 296 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 297 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 300 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -52968,12 +53603,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185 /* PropertyAccessExpression */) { + if (entityName.kind === 187 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -52986,7 +53621,7 @@ var ts; var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 262 /* JsxAttribute */) { + else if (entityName.parent.kind === 265 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161 /* TypePredicate */) { @@ -52996,7 +53631,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -53016,8 +53651,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 /* BindingElement */ && - grandParent.kind === 180 /* ObjectBindingPattern */ && + else if (parent.kind === 184 /* BindingElement */ && + grandParent.kind === 182 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -53028,7 +53663,7 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: @@ -53043,7 +53678,7 @@ var ts; return checkExpression(node).symbol; } // falls through - case 174 /* ThisType */: + case 176 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; @@ -53061,7 +53696,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -53079,14 +53714,14 @@ var ts; case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -53159,28 +53794,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 222 /* ForOfStatement */) { + if (expr.parent.kind === 225 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 200 /* BinaryExpression */) { + if (expr.parent.kind === 202 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 270 /* PropertyAssignment */) { + if (expr.parent.kind === 273 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -53259,7 +53894,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -53315,7 +53950,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { var symbolFile = parentSymbol_1.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. @@ -53370,7 +54005,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 === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -53411,16 +54046,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -53430,7 +54065,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -53511,22 +54146,23 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273 /* EnumMember */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 276 /* EnumMember */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273 /* EnumMember */) { + if (node.kind === 276 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8 /* EnumMember */)) { // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -53664,7 +54300,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } @@ -53761,7 +54397,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; + return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -53773,7 +54409,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67901928 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -53824,7 +54460,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -53839,12 +54475,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 274 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 277 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -53852,10 +54488,14 @@ var ts; var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); // Initialize global symbol table var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -53929,6 +54569,32 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -54022,7 +54688,7 @@ var ts; } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { + if (node.kind !== 241 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -54042,7 +54708,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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -54065,7 +54731,7 @@ 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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149 /* Parameter */) { @@ -54101,7 +54767,7 @@ 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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149 /* Parameter */) { @@ -54110,8 +54776,8 @@ var ts; flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -54123,13 +54789,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 240 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -54139,14 +54805,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 238 /* ClassDeclaration */) { if (node.kind !== 154 /* MethodDeclaration */ && node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 156 /* GetAccessor */ && node.kind !== 157 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -54188,7 +54854,7 @@ var ts; } return false; } - else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -54223,29 +54889,29 @@ var ts; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 160 /* IndexSignature */: - case 239 /* ModuleDeclaration */: - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 242 /* ModuleDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 149 /* Parameter */: return false; default: - if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return false; } switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 236 /* InterfaceDeclaration */: - case 214 /* VariableStatement */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 217 /* VariableStatement */: + case 240 /* TypeAliasDeclaration */: return true; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -54259,9 +54925,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -54394,7 +55060,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206 /* OmittedExpression */) { + if (arg.kind === 208 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -54475,15 +55141,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 234 /* FunctionDeclaration */ || - node.kind === 192 /* FunctionExpression */ || + ts.Debug.assert(node.kind === 237 /* FunctionDeclaration */ || + node.kind === 194 /* FunctionExpression */ || node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -54507,7 +55173,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 /* SpreadAssignment */) { + if (prop.kind === 275 /* SpreadAssignment */) { continue; } var name = prop.name; @@ -54515,7 +55181,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 /* 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); @@ -54539,8 +55205,8 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -54590,7 +55256,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 264 /* JsxSpreadAttribute */) { + if (attr.kind === 267 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -54600,7 +55266,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -54609,12 +55275,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 233 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -54629,20 +55295,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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); @@ -54711,7 +55377,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 71 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -54749,7 +55415,7 @@ var ts; return true; } if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 184 /* ObjectLiteralExpression */) { + if (node.parent.kind === 186 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -54778,7 +55444,7 @@ var ts; return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (node.parent.kind === 166 /* TypeLiteral */) { @@ -54792,11 +55458,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 223 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 226 /* 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); @@ -54804,8 +55470,8 @@ var ts; return false; } break; - case 227 /* SwitchStatement */: - if (node.kind === 224 /* BreakStatement */ && !node.label) { + case 230 /* SwitchStatement */: + if (node.kind === 227 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -54820,13 +55486,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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 === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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); @@ -54839,7 +55505,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { + if (node.name.kind === 183 /* ArrayBindingPattern */ || node.name.kind === 182 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -54853,14 +55519,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { + if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -54871,7 +55537,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -54881,19 +55547,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -54948,15 +55614,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return false; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -54966,7 +55632,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -55033,7 +55699,7 @@ var ts; return true; } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -55070,13 +55736,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 237 /* TypeAliasDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 243 /* ImportEqualsDeclaration */ || - node.kind === 250 /* ExportDeclaration */ || - node.kind === 249 /* ExportAssignment */ || - node.kind === 242 /* NamespaceExportDeclaration */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 240 /* TypeAliasDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 253 /* ExportDeclaration */ || + node.kind === 252 /* ExportAssignment */ || + node.kind === 245 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -55085,7 +55751,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 === 214 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 217 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -55112,7 +55778,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 === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -55134,10 +55800,10 @@ var ts; 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, 178 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -55192,8 +55858,8 @@ var ts; /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -55201,14 +55867,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245 /* ImportClause */: // For default import - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: // For rename import `x as y` + case 248 /* ImportClause */: // For default import + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: // For rename import `x as y` return true; case 71 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 248 /* ImportSpecifier */; + return decl.parent.kind === 251 /* ImportSpecifier */; default: return false; } @@ -55224,8 +55890,12 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448 /* Literal */); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -55391,7 +56061,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 /* Node */ | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -55484,10 +56154,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 303 /* CommaListExpression */ ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147 /* ComputedPropertyName */); @@ -55850,14 +56519,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169 /* OptionalType */); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170 /* RestType */); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -55865,7 +56558,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -55884,7 +56577,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171 /* ConditionalType */); + var node = createSynthesizedNode(173 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -55902,7 +56595,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172 /* InferType */); + var node = createSynthesizedNode(174 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -55914,7 +56607,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179 /* ImportType */); + var node = createSynthesizedNode(181 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -55932,7 +56625,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173 /* ParenthesizedType */); + var node = createSynthesizedNode(175 /* ParenthesizedType */); node.type = type; return node; } @@ -55944,11 +56637,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174 /* ThisType */); + return createSynthesizedNode(176 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175 /* TypeOperator */); + var node = createSynthesizedNode(177 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -55959,7 +56652,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176 /* IndexedAccessType */); + var node = createSynthesizedNode(178 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -55973,7 +56666,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177 /* MappedType */); + var node = createSynthesizedNode(179 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -55991,7 +56684,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178 /* LiteralType */); + var node = createSynthesizedNode(180 /* LiteralType */); node.literal = literal; return node; } @@ -56004,7 +56697,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ObjectBindingPattern */); + var node = createSynthesizedNode(182 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56016,7 +56709,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181 /* ArrayBindingPattern */); + var node = createSynthesizedNode(183 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56028,7 +56721,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182 /* BindingElement */); + var node = createSynthesizedNode(184 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -56047,7 +56740,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -56061,7 +56754,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -56075,7 +56768,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185 /* PropertyAccessExpression */); + var node = createSynthesizedNode(187 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -56092,7 +56785,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186 /* ElementAccessExpression */); + var node = createSynthesizedNode(188 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -56106,7 +56799,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* CallExpression */); + var node = createSynthesizedNode(189 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -56122,7 +56815,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188 /* NewExpression */); + var node = createSynthesizedNode(190 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -56138,7 +56831,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -56161,7 +56854,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190 /* TypeAssertionExpression */); + var node = createSynthesizedNode(192 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -56175,7 +56868,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191 /* ParenthesizedExpression */); + var node = createSynthesizedNode(193 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -56187,7 +56880,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192 /* FunctionExpression */); + var node = createSynthesizedNode(194 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -56211,7 +56904,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193 /* ArrowFunction */); + var node = createSynthesizedNode(195 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -56245,7 +56938,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194 /* DeleteExpression */); + var node = createSynthesizedNode(196 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56257,7 +56950,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195 /* TypeOfExpression */); + var node = createSynthesizedNode(197 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56269,7 +56962,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196 /* VoidExpression */); + var node = createSynthesizedNode(198 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56281,7 +56974,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197 /* AwaitExpression */); + var node = createSynthesizedNode(199 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56293,7 +56986,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -56306,7 +56999,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -56319,7 +57012,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200 /* BinaryExpression */); + var node = createSynthesizedNode(202 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -56336,7 +57029,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201 /* ConditionalExpression */); + var node = createSynthesizedNode(203 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -56366,7 +57059,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202 /* TemplateExpression */); + var node = createSynthesizedNode(204 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -56404,7 +57097,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203 /* YieldExpression */); + var node = createSynthesizedNode(205 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -56418,7 +57111,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204 /* SpreadElement */); + var node = createSynthesizedNode(206 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -56430,7 +57123,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205 /* ClassExpression */); + var node = createSynthesizedNode(207 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56451,11 +57144,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206 /* OmittedExpression */); + return createSynthesizedNode(208 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -56469,7 +57162,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208 /* AsExpression */); + var node = createSynthesizedNode(210 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -56483,7 +57176,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209 /* NonNullExpression */); + var node = createSynthesizedNode(211 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -56495,7 +57188,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210 /* MetaProperty */); + var node = createSynthesizedNode(212 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -56509,7 +57202,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211 /* TemplateSpan */); + var node = createSynthesizedNode(214 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -56523,25 +57216,18 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212 /* SemicolonClassElement */); + return createSynthesizedNode(215 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213 /* Block */); + var block = createSynthesizedNode(216 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - /* @internal */ - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216 /* ExpressionStatement */); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -56549,7 +57235,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214 /* VariableStatement */); + var node = createSynthesizedNode(217 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -56564,21 +57250,27 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215 /* EmptyStatement */); + return createSynthesizedNode(218 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + ts.createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217 /* IfStatement */); + var node = createSynthesizedNode(220 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -56594,7 +57286,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218 /* DoStatement */); + var node = createSynthesizedNode(221 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -56608,7 +57300,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219 /* WhileStatement */); + var node = createSynthesizedNode(222 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -56622,7 +57314,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220 /* ForStatement */); + var node = createSynthesizedNode(223 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -56640,7 +57332,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForInStatement */); + var node = createSynthesizedNode(224 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -56656,7 +57348,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222 /* ForOfStatement */); + var node = createSynthesizedNode(225 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -56674,7 +57366,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223 /* ContinueStatement */); + var node = createSynthesizedNode(226 /* ContinueStatement */); node.label = asName(label); return node; } @@ -56686,7 +57378,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224 /* BreakStatement */); + var node = createSynthesizedNode(227 /* BreakStatement */); node.label = asName(label); return node; } @@ -56698,7 +57390,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225 /* ReturnStatement */); + var node = createSynthesizedNode(228 /* ReturnStatement */); node.expression = expression; return node; } @@ -56710,7 +57402,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226 /* WithStatement */); + var node = createSynthesizedNode(229 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -56724,7 +57416,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227 /* SwitchStatement */); + var node = createSynthesizedNode(230 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -56738,7 +57430,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228 /* LabeledStatement */); + var node = createSynthesizedNode(231 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -56752,7 +57444,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229 /* ThrowStatement */); + var node = createSynthesizedNode(232 /* ThrowStatement */); node.expression = expression; return node; } @@ -56764,7 +57456,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230 /* TryStatement */); + var node = createSynthesizedNode(233 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -56780,11 +57472,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231 /* DebuggerStatement */); + return createSynthesizedNode(234 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232 /* VariableDeclaration */); + var node = createSynthesizedNode(235 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -56801,7 +57493,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(233 /* VariableDeclarationList */); + var node = createSynthesizedNode(236 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -56814,7 +57506,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234 /* FunctionDeclaration */); + var node = createSynthesizedNode(237 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -56840,7 +57532,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* ClassDeclaration */); + var node = createSynthesizedNode(238 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56862,7 +57554,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236 /* InterfaceDeclaration */); + var node = createSynthesizedNode(239 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56884,7 +57576,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56904,7 +57596,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238 /* EnumDeclaration */); + var node = createSynthesizedNode(241 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56923,7 +57615,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* ModuleDeclaration */); + var node = createSynthesizedNode(242 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -56942,7 +57634,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240 /* ModuleBlock */); + var node = createSynthesizedNode(243 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -56954,7 +57646,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241 /* CaseBlock */); + var node = createSynthesizedNode(244 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -56966,7 +57658,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -56978,7 +57670,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56996,7 +57688,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244 /* ImportDeclaration */); + var node = createSynthesizedNode(247 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -57014,7 +57706,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245 /* ImportClause */); + var node = createSynthesizedNode(248 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -57028,7 +57720,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246 /* NamespaceImport */); + var node = createSynthesizedNode(249 /* NamespaceImport */); node.name = name; return node; } @@ -57040,7 +57732,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247 /* NamedImports */); + var node = createSynthesizedNode(250 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -57052,7 +57744,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248 /* ImportSpecifier */); + var node = createSynthesizedNode(251 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -57066,7 +57758,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249 /* ExportAssignment */); + var node = createSynthesizedNode(252 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -57083,7 +57775,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ExportDeclaration */); + var node = createSynthesizedNode(253 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -57101,7 +57793,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251 /* NamedExports */); + var node = createSynthesizedNode(254 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -57113,7 +57805,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252 /* ExportSpecifier */); + var node = createSynthesizedNode(255 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -57128,7 +57820,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254 /* ExternalModuleReference */); + var node = createSynthesizedNode(257 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -57141,7 +57833,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255 /* JsxElement */); + var node = createSynthesizedNode(258 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -57157,7 +57849,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57173,7 +57865,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257 /* JsxOpeningElement */); + var node = createSynthesizedNode(260 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57189,7 +57881,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258 /* JsxClosingElement */); + var node = createSynthesizedNode(261 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -57201,7 +57893,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259 /* JsxFragment */); + var node = createSynthesizedNode(262 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -57217,7 +57909,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262 /* JsxAttribute */); + var node = createSynthesizedNode(265 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -57231,7 +57923,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263 /* JsxAttributes */); + var node = createSynthesizedNode(266 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -57243,7 +57935,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -57255,7 +57947,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265 /* JsxExpression */); + var node = createSynthesizedNode(268 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -57269,7 +57961,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266 /* CaseClause */); + var node = createSynthesizedNode(269 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -57283,7 +57975,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267 /* DefaultClause */); + var node = createSynthesizedNode(270 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -57295,7 +57987,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268 /* HeritageClause */); + var node = createSynthesizedNode(271 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -57308,7 +58000,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269 /* CatchClause */); + var node = createSynthesizedNode(272 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -57323,7 +58015,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270 /* PropertyAssignment */); + var node = createSynthesizedNode(273 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -57338,7 +58030,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -57352,7 +58044,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272 /* SpreadAssignment */); + var node = createSynthesizedNode(275 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -57365,7 +58057,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273 /* EnumMember */); + var node = createSynthesizedNode(276 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -57386,7 +58078,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274 /* SourceFile */); + var updated = createSynthesizedNode(277 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -57470,7 +58162,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301 /* NotEmittedStatement */); + var node = createSynthesizedNode(304 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -57482,7 +58174,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(308 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57494,7 +58186,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(307 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57509,7 +58201,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(302 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(305 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -57525,7 +58217,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 303 /* CommaListExpression */) { + if (node.kind === 306 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -57535,7 +58227,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303 /* CommaListExpression */); + var node = createSynthesizedNode(306 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -57548,14 +58240,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275 /* Bundle */); + var node = ts.createNode(278 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276 /* UnparsedSource */); + var node = ts.createNode(279 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -57563,7 +58255,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277 /* InputFiles */); + var node = ts.createNode(280 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -57706,7 +58398,7 @@ var ts; // 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 === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -58217,7 +58909,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -58235,13 +58927,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -58268,7 +58960,7 @@ var ts; } else { switch (callee.kind) { - case 185 /* PropertyAccessExpression */: { + case 187 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58281,7 +58973,7 @@ var ts; } break; } - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58341,9 +59033,9 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -58668,7 +59360,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 191 /* ParenthesizedExpression */) { + if (skipped.kind === 193 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -58702,8 +59394,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(200 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -58712,7 +59404,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 203 /* YieldExpression */) { + && operand.kind === 205 /* YieldExpression */) { return false; } return true; @@ -58800,7 +59492,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -58815,7 +59507,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -58829,8 +59521,7 @@ var ts; // 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 var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 303 /* CommaListExpression */ + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } @@ -58848,10 +59539,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 /* ClassExpression */ || - check.kind === 192 /* FunctionExpression */ || - check.kind === 303 /* CommaListExpression */ || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) + return check.kind === 207 /* ClassExpression */ || + check.kind === 194 /* FunctionExpression */ || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -58865,9 +59555,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.createParen(expression); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -58890,7 +59580,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -58928,7 +59618,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -58939,27 +59629,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { + if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { + if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: return ts.createParenthesizedType(member); @@ -58970,8 +59660,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 172 /* InferType */: + case 177 /* TypeOperator */: + case 174 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -58997,25 +59687,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: node = node.operand; continue; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: node = node.left; continue; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: node = node.condition; continue; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: - node = node.expression; - continue; - case 302 /* PartiallyEmittedExpression */: + case 210 /* AsExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 211 /* NonNullExpression */: + case 305 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -59023,12 +59713,17 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || + node.kind === 306 /* CommaListExpression */; + } + ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; @@ -59039,13 +59734,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 209 /* NonNullExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 211 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -59070,7 +59765,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { node = node.expression; } return node; @@ -59078,11 +59773,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 191 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 208 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 209 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 302 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -59100,7 +59795,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 191 /* ParenthesizedExpression */ + return node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -59165,10 +59860,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -59287,7 +59982,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -59299,11 +59994,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -59336,11 +60031,11 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 204 /* SpreadElement */: - case 272 /* SpreadAssignment */: + case 206 /* SpreadElement */: + case 275 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -59352,7 +60047,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -59364,7 +60059,7 @@ var ts; : propertyName; } break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -59376,7 +60071,7 @@ var ts; : propertyName; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -59394,13 +60089,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -59440,11 +60135,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -59568,7 +60263,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -59605,7 +60300,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { return node; } switch (kind) { @@ -59660,217 +60355,221 @@ var ts; case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168 /* TupleType */: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* UnionType */: + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 169 /* OptionalType */: + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* RestType */: + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 172 /* InferType */: + case 174 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177 /* MappedType */: + case 179 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 213 /* Block */: + case 216 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 216 /* ExpressionStatement */: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* IfStatement */: + case 219 /* ExpressionStatement */: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForStatement */: + case 223 /* 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, ts.liftToBlock)); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -59916,17 +60615,17 @@ var ts; return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 212 /* SemicolonClassElement */: - case 215 /* EmptyStatement */: - case 206 /* OmittedExpression */: - case 231 /* DebuggerStatement */: - case 301 /* NotEmittedStatement */: + case 215 /* SemicolonClassElement */: + case 218 /* EmptyStatement */: + case 208 /* OmittedExpression */: + case 234 /* DebuggerStatement */: + case 304 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -59993,49 +60692,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* NewExpression */: + case 190 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -60043,123 +60742,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ArrowFunction */: + case 195 /* 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 191 /* ParenthesizedExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208 /* AsExpression */: + case 210 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 213 /* Block */: + case 216 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219 /* WhileStatement */: - case 226 /* WithStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60168,7 +60867,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60176,139 +60875,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -60381,7 +61080,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) && node.kind !== 207 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -60625,7 +61324,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -60772,7 +61470,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -60818,7 +61516,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -60826,13 +61524,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + case 246 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -60862,13 +61560,13 @@ var ts; } } break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -60876,7 +61574,7 @@ var ts; } } break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -60896,7 +61594,7 @@ var ts; } } break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -61512,13 +62210,14 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -61542,14 +62241,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -61577,16 +62276,18 @@ var ts; */ function saveStateAndInvoke(node, f) { // Save state - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } /** @@ -61596,15 +62297,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 240 /* ModuleBlock */: - case 213 /* Block */: - currentScope = node; + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 243 /* ModuleBlock */: + case 216 /* Block */: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -61616,7 +62318,11 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } + if (ts.isClassDeclaration(node)) { + // XXX: should probably also cover interfaces and type aliases that can have type variables? + currentNameScope = node; } break; } @@ -61660,10 +62366,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -61684,13 +62390,13 @@ var ts; return node; } switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -61710,11 +62416,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 250 /* ExportDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 245 /* ImportClause */ || - (node.kind === 243 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 254 /* ExternalModuleReference */)) { + if (node.kind === 253 /* ExportDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 248 /* ImportClause */ || + (node.kind === 246 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 257 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -61756,7 +62462,7 @@ var ts; case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -61797,6 +62503,8 @@ var ts; // TypeScript accessibility and readonly modifiers are elided. case 167 /* ArrayType */: case 168 /* TupleType */: + case 169 /* OptionalType */: + case 170 /* RestType */: case 166 /* TypeLiteral */: case 161 /* TypePredicate */: case 148 /* TypeParameter */: @@ -61812,36 +62520,36 @@ var ts; case 163 /* FunctionType */: case 165 /* TypeQuery */: case 162 /* TypeReference */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 171 /* ConditionalType */: - case 173 /* ParenthesizedType */: - case 174 /* ThisType */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: - case 178 /* LiteralType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 175 /* ParenthesizedType */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: // TypeScript type nodes are elided. case 160 /* IndexSignature */: // TypeScript index signatures are elided. case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; case 152 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; case 155 /* Constructor */: return visitConstructor(node); - case 236 /* InterfaceDeclaration */: + case 239 /* 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61852,7 +62560,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61863,13 +62571,13 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); case 154 /* MethodDeclaration */: @@ -61882,13 +62590,13 @@ var ts; case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case 149 /* Parameter */: @@ -61901,35 +62609,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -61965,7 +62673,7 @@ var ts; var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) @@ -62008,7 +62716,7 @@ var ts; var statements = [classStatement]; // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -62369,7 +63077,7 @@ var ts; // // super(...arguments); // - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } // Add the property initializers. Transforms this: @@ -62411,7 +63119,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -62448,7 +63156,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -62495,7 +63203,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -62798,7 +63506,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } /** @@ -62925,8 +63633,8 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -62948,8 +63656,8 @@ var ts; return serializeTypeNode(node.type); case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: @@ -63037,7 +63745,7 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return serializeTypeNode(node.type); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -63052,7 +63760,7 @@ var ts; return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -63072,18 +63780,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: return serializeUnionOrIntersectionType(node); case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: case 142 /* UnknownKeyword */: - case 174 /* ThisType */: - case 179 /* ImportType */: + case 176 /* ThisType */: + case 181 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63096,7 +63804,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -63135,7 +63843,7 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); @@ -63182,7 +63890,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. + name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -63516,7 +64224,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -63597,7 +64305,7 @@ var ts; * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -63621,7 +64329,7 @@ var ts; // enum body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63646,7 +64354,7 @@ var ts; // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63694,7 +64402,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } /** * Transforms the value of an enum member. @@ -63772,12 +64480,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentScope.kind === 274 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 238 /* EnumDeclaration */) { + if (node.kind === 241 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -63839,7 +64547,7 @@ var ts; // module body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63863,7 +64571,7 @@ var ts; // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63896,7 +64604,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240 /* ModuleBlock */) { + if (body.kind === 243 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -63942,13 +64650,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 !== 240 /* ModuleBlock */) { + if (body.kind !== 243 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -63989,7 +64697,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 246 /* NamespaceImport */) { + if (node.kind === 249 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -64144,17 +64852,17 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -64221,16 +64929,16 @@ 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(71 /* Identifier */); - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(239 /* ModuleDeclaration */); + context.enableEmitNotification(242 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; } /** * Hook for node emit. @@ -64291,9 +64999,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -64331,9 +65039,9 @@ 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 !== 274 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); + if (container && container.kind !== 277 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -64468,15 +65176,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -64485,27 +65193,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 213 /* Block */: - case 227 /* SwitchStatement */: - case 241 /* CaseBlock */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 230 /* TryStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 226 /* WithStatement */: - case 228 /* LabeledStatement */: + case 216 /* Block */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 229 /* WithStatement */: + case 231 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -64540,7 +65248,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -64706,7 +65414,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 === 193 /* ArrowFunction */; + var isArrowFunction = node.kind === 195 /* 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 @@ -64779,11 +65487,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -64827,11 +65535,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -64863,7 +65571,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -64962,25 +65670,25 @@ var ts; return node; } switch (node.kind) { - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitVoidExpression(node); case 155 /* Constructor */: return visitConstructorDeclaration(node); @@ -64990,19 +65698,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); case 149 /* Parameter */: return visitParameter(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -65036,7 +65744,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -65048,7 +65756,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 272 /* SpreadAssignment */) { + if (e.kind === 275 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -65057,7 +65765,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -65075,7 +65783,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 !== 184 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -65214,13 +65922,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -65388,11 +66096,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -65436,11 +66144,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -65472,7 +66180,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -65585,13 +66293,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -65601,13 +66309,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -65682,7 +66390,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265 /* JsxExpression */) { + else if (node.kind === 268 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -65776,7 +66484,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255 /* JsxElement */) { + if (node.kind === 258 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -66082,7 +66790,7 @@ var ts; return node; } switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66315,13 +67023,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 225 /* ReturnStatement */ + && node.kind === 228 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -66349,63 +67057,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return visitClassExpression(node); case 149 /* Parameter */: return visitParameter(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -66416,28 +67124,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitMetaProperty(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -66524,14 +67232,14 @@ 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 === 224 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -66542,7 +67250,7 @@ var ts; } } else { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -66659,7 +67367,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -66723,7 +67431,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), /*location*/ extendsClauseElement)); } } @@ -66842,11 +67550,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 225 /* ReturnStatement */) { + if (statement.kind === 228 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 217 /* IfStatement */) { + else if (statement.kind === 220 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -66854,7 +67562,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 213 /* Block */) { + else if (statement.kind === 216 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -66912,7 +67620,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -66922,8 +67630,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 /* BinaryExpression */ - || superCallExpression.left.kind !== 187 /* CallExpression */) { + if (superCallExpression.kind !== 202 /* BinaryExpression */ + || superCallExpression.left.kind !== 189 /* 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. @@ -67038,7 +67746,7 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -67052,7 +67760,7 @@ 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.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -67104,7 +67812,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) ]), 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 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) @@ -67120,7 +67828,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -67140,7 +67848,7 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return statements; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -67154,8 +67862,8 @@ var ts; // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -67186,7 +67894,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: @@ -67230,7 +67938,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -67248,7 +67956,7 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); + var statement = ts.createExpressionStatement(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. @@ -67391,7 +68099,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -67436,7 +68144,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193 /* ArrowFunction */); + ts.Debug.assert(node.kind === 195 /* 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 @@ -67504,10 +68212,10 @@ 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 191 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + case 193 /* ParenthesizedExpression */: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 202 /* BinaryExpression */: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); } @@ -67525,9 +68233,9 @@ var ts; // 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 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -67569,7 +68277,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -67728,14 +68436,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -67793,11 +68501,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -67886,13 +68594,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -67991,11 +68699,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -68159,7 +68867,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -68176,7 +68884,7 @@ var ts; ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { @@ -68285,10 +68993,10 @@ var ts; case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -68540,7 +69248,7 @@ var ts; statements.push(funcStatements[classBodyStart]); classBodyStart++; // Add the class alias following the declaration. - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } // Find the trailing 'return' statement (4) while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { @@ -68677,7 +69385,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -68944,9 +69652,9 @@ var ts; context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(193 /* ArrowFunction */); - context.enableEmitNotification(192 /* FunctionExpression */); - context.enableEmitNotification(234 /* FunctionDeclaration */); + context.enableEmitNotification(195 /* ArrowFunction */); + context.enableEmitNotification(194 /* FunctionExpression */); + context.enableEmitNotification(237 /* FunctionDeclaration */); } } /** @@ -68987,10 +69695,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 235 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -69072,11 +69780,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -69084,7 +69792,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -69137,15 +69845,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257 /* JsxOpeningElement */); - context.enableEmitNotification(258 /* JsxClosingElement */); - context.enableEmitNotification(256 /* JsxSelfClosingElement */); + context.enableEmitNotification(260 /* JsxOpeningElement */); + context.enableEmitNotification(261 /* JsxClosingElement */); + context.enableEmitNotification(259 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(270 /* PropertyAssignment */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(273 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -69164,9 +69872,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -69498,13 +70206,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -69517,24 +70225,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return visitBreakStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return visitContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -69555,21 +70263,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitConditionalExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69582,9 +70290,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -69760,7 +70468,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } /** @@ -69812,7 +70520,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -69824,7 +70532,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -69948,7 +70656,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* Statement */, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -70101,7 +70809,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -70200,35 +70908,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: return transformAndEmitBlock(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return transformAndEmitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return transformAndEmitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return transformAndEmitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return transformAndEmitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -70265,7 +70973,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -70416,7 +71124,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -70426,7 +71134,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -70487,7 +71195,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); @@ -70510,7 +71218,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -70658,7 +71366,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -70671,7 +71379,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -71534,7 +72242,7 @@ var ts; // indicate entry into a protected region by pushing the label numbers // for each block in the protected region. var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, [ ts.createArrayLiteral([ createLabel(startLabel), @@ -71548,7 +72256,7 @@ var ts; if (markLabelEnd) { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -71706,7 +72414,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -71900,11 +72608,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(277 /* 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. @@ -71997,7 +72705,7 @@ var ts; // // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, + ts.createExpressionStatement(ts.createCall(define, /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ // Add the dependency array argument: // @@ -72048,9 +72756,9 @@ var ts; 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.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(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"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -72074,7 +72782,7 @@ var ts; // } // })(function ...) var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, + ts.createExpressionStatement(ts.createCall(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // @@ -72153,7 +72861,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. @@ -72208,7 +72916,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); @@ -72226,23 +72934,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -72269,17 +72977,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -72373,7 +73081,7 @@ var ts; ts.createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; @@ -72468,7 +73176,7 @@ var ts; if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -72536,7 +73244,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( @@ -72549,7 +73257,7 @@ var ts; } else { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -72588,13 +73296,13 @@ var ts; 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)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { // export * from "mod"; - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } /** @@ -72700,7 +73408,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -72761,7 +73469,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -72816,10 +73524,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -72949,10 +73657,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), @@ -72973,7 +73681,7 @@ var ts; * @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); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -73018,7 +73726,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -73082,10 +73790,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -73106,7 +73814,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -73181,7 +73889,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -73257,11 +73965,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(277 /* 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. @@ -73323,7 +74031,7 @@ var ts; 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.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) @@ -73482,7 +74190,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -73507,7 +74215,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250 /* ExportDeclaration */) { + if (externalImport.kind !== 253 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -73561,9 +74269,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) ])), - ts.createStatement(ts.createCall(exportFunction, + ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) ], /*multiline*/ true)); } @@ -73585,19 +74293,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -73613,7 +74321,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { @@ -73622,7 +74330,7 @@ var ts; // emit as: // // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, /*typeArguments*/ undefined, [parameterName]))); } break; @@ -73647,15 +74355,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -73756,7 +74464,7 @@ 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.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -73793,7 +74501,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -73831,7 +74539,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 274 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 277 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -73895,7 +74603,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 === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -73957,10 +74665,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -74112,7 +74820,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -74140,43 +74848,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitDefaultClause(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitTryStatement(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -74359,7 +75067,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 200 /* BinaryExpression */) { + && node.kind === 202 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -74424,7 +75132,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274 /* SourceFile */; + return container !== undefined && container.kind === 277 /* SourceFile */; } else { return false; @@ -74457,7 +75165,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -74505,7 +75213,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -74541,10 +75249,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -74637,14 +75345,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 199 /* PostfixUnaryExpression */) { + if (node.kind === 201 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -74666,7 +75374,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -74705,7 +75413,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274 /* SourceFile */); + context.enableEmitNotification(277 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -74734,10 +75442,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -74844,7 +75552,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74873,7 +75581,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -74920,7 +75628,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { 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 : @@ -74939,7 +75647,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 === 235 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { 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 : @@ -75030,7 +75738,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -75044,7 +75752,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234 /* FunctionDeclaration */: + case 237 /* 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 : @@ -75100,7 +75808,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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 : @@ -75113,7 +75821,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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 163 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -75128,10 +75836,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159 /* ConstructSignature */: @@ -75145,17 +75853,17 @@ var ts; 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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -75170,7 +75878,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 235 /* ClassDeclaration */) { + if (node.parent.parent.kind === 238 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = node.parent.token === 108 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -75267,7 +75975,13 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + // If it is visible via `// `, then we should just use that + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -75322,10 +76036,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -75353,7 +76067,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -75451,7 +76165,7 @@ var ts; return name; } else { - if (name.kind === 181 /* ArrayBindingPattern */) { + if (name.kind === 183 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -75459,7 +76173,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206 /* OmittedExpression */) { + if (elem.kind === 208 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -75517,7 +76231,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 /* Parameter */ @@ -75539,20 +76253,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return false; } return false; @@ -75606,7 +76320,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -75618,7 +76332,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -75645,7 +76359,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -75750,14 +76464,14 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 207 /* ExpressionWithTypeArguments */: { + case 209 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -75811,7 +76525,7 @@ var ts; return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -75825,7 +76539,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171 /* ConditionalType */: { + case 173 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -75843,7 +76557,7 @@ var ts; case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179 /* ImportType */: { + case 181 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -75882,7 +76596,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250 /* ExportDeclaration */: { + case 253 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -75891,7 +76605,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -75921,10 +76635,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -75945,24 +76659,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 236 /* InterfaceDeclaration */: { + case 239 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 234 /* FunctionDeclaration */: { + case 237 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type return cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); } - case 239 /* ModuleDeclaration */: { + case 242 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240 /* ModuleBlock */) { + if (inner && inner.kind === 243 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -75983,7 +76697,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 235 /* ClassDeclaration */: { + case 238 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -76023,7 +76737,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 @@ -76053,10 +76767,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238 /* EnumDeclaration */: { + case 241 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -76075,7 +76789,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239 /* ModuleDeclaration */) { + if (input.kind === 242 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -76096,7 +76810,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206 /* OmittedExpression */) { + if (e.kind === 208 /* OmittedExpression */) { return; } if (e.name) { @@ -76150,7 +76864,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 274 /* SourceFile */; + var parentIsFile = node.parent.kind === 277 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -76171,7 +76885,7 @@ var ts; var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3 /* MultiLineCommentTrivia */) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -76185,7 +76899,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -76198,7 +76912,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* InterfaceDeclaration */) { return true; } return false; @@ -76227,7 +76941,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: @@ -76237,17 +76951,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: - case 214 /* VariableStatement */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 217 /* VariableStatement */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return true; } return false; @@ -76264,14 +76978,14 @@ var ts; case 153 /* MethodSignature */: case 158 /* CallSignature */: case 160 /* IndexSignature */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 148 /* TypeParameter */: - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: case 162 /* TypeReference */: - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 179 /* ImportType */: + case 181 /* ImportType */: return true; } return false; @@ -76347,7 +77061,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(306 /* Count */); + var enabledSyntaxKindFeatures = new Array(309 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -76682,7 +77396,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap @@ -76692,7 +77405,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 277 /* 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 = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -76783,7 +77496,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** * Emits a mapping. @@ -76843,6 +77555,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -76853,50 +77566,55 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { // empty } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); // First, decode the old component sourcemap - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); + } + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -76913,7 +77631,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -76968,13 +77686,15 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -77090,7 +77810,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 304 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 10 /* JsxText */; @@ -77111,7 +77831,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 === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -77453,7 +78173,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275 /* Bundle */) { + if (sourceFile.kind === 278 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; @@ -77588,6 +78308,11 @@ var ts; // Setup and perform the transformation to retrieve declarations from the input files var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + // Checker wont collect the linked aliases since thats only done when declaration is enabled. + // Do that here when emitting only dts files + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -77615,9 +78340,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71 /* Identifier */) { + resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -77717,9 +78455,9 @@ var ts; break; } switch (node.kind) { - case 274 /* SourceFile */: return printFile(node); - case 275 /* Bundle */: return printBundle(node); - case 276 /* UnparsedSource */: return printUnparsedSource(node); + case 277 /* SourceFile */: return printFile(node); + case 278 /* Bundle */: return printBundle(node); + case 279 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -77864,7 +78602,7 @@ var ts; } return pipelineEmitWithoutComments; case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { return pipelineEmitWithSourceMap; } // falls through @@ -77890,7 +78628,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); + ts.Debug.assert(hint !== 0 /* SourceFile */); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -77909,7 +78647,7 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 276 /* UnparsedSource */: + case 279 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: @@ -77954,7 +78692,7 @@ var ts; return emitTypeReference(node); case 163 /* FunctionType */: return emitFunctionType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 164 /* ConstructorType */: return emitConstructorType(node); @@ -77966,178 +78704,181 @@ var ts; return emitArrayType(node); case 168 /* TupleType */: return emitTupleType(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return emitOptionalType(node); + case 171 /* UnionType */: return emitUnionType(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return emitIntersectionType(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return emitConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return emitInferType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return emitParenthesizedType(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return emitThisType(); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return emitTypeOperator(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return emitMappedType(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return emitLiteralType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return emitImportTypeNode(node); - case 279 /* JSDocAllType */: + case 282 /* JSDocAllType */: write("*"); return; - case 280 /* JSDocUnknownType */: + case 283 /* JSDocUnknownType */: write("?"); return; - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 285 /* JSDocVariadicType */: - return emitJSDocVariadicType(node); + case 170 /* RestType */: + case 288 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return emitBindingElement(node); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return emitTemplateSpan(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 213 /* Block */: + case 216 /* Block */: return emitBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return emitVariableStatement(node); - case 215 /* EmptyStatement */: + case 218 /* EmptyStatement */: return emitEmptyStatement(); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return emitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return emitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return emitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return emitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return emitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return emitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return emitForOfStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return emitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return emitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return emitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return emitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return emitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return emitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return emitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return emitTryStatement(node); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return emitClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return emitModuleBlock(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return emitCaseBlock(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return emitImportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return emitImportClause(node); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return emitNamespaceImport(node); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return emitNamedImports(node); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return emitImportSpecifier(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return emitExportDeclaration(node); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return emitNamedExports(node); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return emitExportSpecifier(node); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return; // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 258 /* JsxClosingElement */: - case 261 /* JsxClosingFragment */: + case 261 /* JsxClosingElement */: + case 264 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return emitJsxAttribute(node); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return emitJsxAttributes(node); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return emitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return emitDefaultClause(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return emitHeritageClause(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -78172,71 +78913,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return emitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return emitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return emitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return emitArrowFunction(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return emitDeleteExpression(node); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return emitVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return emitAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return emitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return emitConditionalExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return emitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return emitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return emitSpreadExpression(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return emitClassExpression(node); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: return emitAsExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return emitNonNullExpression(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return emitJsxElement(node); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return emitCommaList(node); } } @@ -78253,7 +78994,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 /* Bundle */ ? node : undefined; + var bundle = node.kind === 278 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -78379,7 +79120,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -78548,7 +79289,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -78557,6 +79298,10 @@ var ts; emitList(node, node.elementTypes, 272 /* TupleTypeElements */); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260 /* UnionTypeConstituents */); } @@ -78838,7 +79583,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 === 198 /* PrefixUnaryExpression */ + return operand.kind === 200 /* PrefixUnaryExpression */ && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } @@ -78958,7 +79703,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217 /* IfStatement */) { + if (node.elseStatement.kind === 220 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -79029,7 +79774,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { emit(node); } else { @@ -79131,7 +79876,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272 /* VariableDeclarationList */); } @@ -79324,7 +80069,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239 /* ModuleDeclaration */) { + while (body.kind === 242 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -80249,7 +80994,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -80314,81 +81059,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: ts.forEach(node.statements, generateNames); break; - case 228 /* LabeledStatement */: - case 226 /* WithStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 231 /* LabeledStatement */: + case 229 /* WithStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: generateNames(node.statement); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: generateNames(node.declarationList); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: generateNames(node.importClause); break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -80397,8 +81142,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 152 /* PropertyDeclaration */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -80584,17 +81329,17 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 252 /* ExportAssignment */: return generateNameForExportDefault(); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return generateNameForClassExpression(); case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -81255,17 +82000,20 @@ var ts; } return context; } - function formatLocation(file, start, host) { + /* @internal */ + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -81284,11 +82032,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -82015,7 +82763,16 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + // Use local caches + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + // Before falling back to the host + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -82275,10 +83032,10 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: - case 232 /* VariableDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: + case 235 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -82286,41 +83043,41 @@ var ts; } } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -82333,25 +83090,25 @@ 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: // 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; } // falls through - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); } break; case 152 /* PropertyDeclaration */: @@ -82373,11 +83130,11 @@ var ts; return; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -83043,14 +83800,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -84704,11 +85461,12 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - // Note: fromSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + // Note: importingSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -84721,7 +85479,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); @@ -84739,13 +85497,13 @@ var ts; function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -84815,11 +85573,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0 /* EqualTo */) { resolvedParts.pop(); originalParts.pop(); } @@ -84853,17 +85612,16 @@ var ts; return [target]; } /** - * Looks for a existing imports that use symlinks to this module. + * Looks for existing imports that use symlinks to this module. * Only if no symlink is available, the real path will be used. */ - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -84939,7 +85697,7 @@ var ts; var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); @@ -85347,7 +86105,7 @@ var ts; } var trace = host.trace && (function (s) { host.trace(s + newLine); }); var watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? ts.WatchLogLevel.Verbose : - compilerOptions.diagnostis ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; // TODO: GH#18217 var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -85879,16 +86637,20 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */) ? ".jsx" /* Jsx */ : ".js" /* Js */); + var newExtension = ts.fileExtensionIs(inputFileName, ".json" /* Json */) ? ".json" /* Json */ : + ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -86060,9 +86822,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -86112,7 +86871,7 @@ var ts; // Everything is broken - we don't even know what to watch. Give up. return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { // Watch this file @@ -86139,7 +86898,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -86344,14 +87103,18 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -86359,7 +87122,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -86655,12 +87422,12 @@ var ts; } // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -86729,7 +87496,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; @@ -86752,18 +87519,24 @@ var ts; })(ts || (ts = {})); //# sourceMappingURL=compiler.js.map "use strict"; -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 __assign = (this && this.__assign) || function () { + __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; + }; + return __assign.apply(this, arguments); }; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -86799,7 +87572,7 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ - ts.defaultPreferences = {}; + ts.emptyOptions = {}; var TextChange = /** @class */ (function () { function TextChange() { } @@ -87035,35 +87808,35 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 149 /* Parameter */: - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 269 /* CatchClause */: - case 262 /* JsxAttribute */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 272 /* CatchClause */: + case 265 /* JsxAttribute */: return 1 /* Value */; case 148 /* TypeParameter */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: case 166 /* TypeLiteral */: return 2 /* Type */; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 273 /* EnumMember */: - case 235 /* ClassDeclaration */: + case 276 /* EnumMember */: + case 238 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -87073,26 +87846,26 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* EnumDeclaration */: - case 247 /* NamedImports */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 241 /* EnumDeclaration */: + case 250 /* NamedImports */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 249 /* ExportAssignment */) { + else if (node.parent.kind === 252 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -87125,7 +87898,7 @@ var ts; // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 243 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { while (node.parent.kind === 146 /* QualifiedName */) { @@ -87151,16 +87924,16 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 185 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { + if (root.parent.kind === 187 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -87171,25 +87944,25 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return true; } switch (node.parent.kind) { case 162 /* TypeReference */: return true; - case 179 /* ImportType */: + case 181 /* ImportType */: return !node.parent.isTypeOf; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 189 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 190 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -87202,7 +87975,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -87227,11 +88000,11 @@ var ts; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -87243,20 +88016,20 @@ var ts; switch (node.parent.kind) { case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 273 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 276 /* EnumMember */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return node.parent.argumentExpression === node; case 147 /* ComputedPropertyName */: return true; - case 178 /* LiteralType */: - return node.parent.parent.kind === 176 /* IndexedAccessType */; + case 180 /* LiteralType */: + return node.parent.parent.kind === 178 /* IndexedAccessType */; default: return false; } @@ -87280,17 +88053,17 @@ var ts; return undefined; } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return node; } } @@ -87298,26 +88071,26 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return "class" /* classElement */; - case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 237 /* TypeAliasDeclaration */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 240 /* TypeAliasDeclaration */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 238 /* EnumDeclaration */: return "enum" /* enumElement */; - case 232 /* VariableDeclaration */: + case 241 /* EnumDeclaration */: return "enum" /* enumElement */; + case 235 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return "function" /* functionElement */; case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; @@ -87332,15 +88105,14 @@ var ts; case 158 /* CallSignature */: return "call" /* callSignatureElement */; case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 273 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 276 /* EnumMember */: return "enum member" /* enumMemberElement */; case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: - case 252 /* ExportSpecifier */: - case 246 /* NamespaceImport */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: + case 249 /* NamespaceImport */: return "alias" /* alias */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -87364,11 +88136,13 @@ var ts; return "" /* unknown */; } } + case 71 /* Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; } function getKindOfVariableDeclaration(v) { - return ts.isConst(v) + return ts.isVarConst(v) ? "const" /* constElement */ : ts.isLet(v) ? "let" /* letElement */ @@ -87401,6 +88175,10 @@ var ts; return startEndContainsRange(r1.pos, r1.end, r2); } ts.rangeContainsRange = rangeContainsRange; + function rangeContainsRangeExclusive(r1, r2) { + return rangeContainsPositionExclusive(r1, r2.pos) && rangeContainsPositionExclusive(r1, r2.end); + } + ts.rangeContainsRangeExclusive = rangeContainsRangeExclusive; function rangeContainsPosition(r, pos) { return r.pos <= pos && pos <= r.end; } @@ -87421,6 +88199,10 @@ var ts; return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); } ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function nodeOverlapsWithStartEnd(node, sourceFile, start, end) { + return startEndOverlapsWithStartEnd(node.getStart(sourceFile), node.end, start, end); + } + ts.nodeOverlapsWithStartEnd = nodeOverlapsWithStartEnd; function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { var start = Math.max(start1, start2); var end = Math.min(end1, end2); @@ -87440,28 +88222,28 @@ var ts; return false; } switch (n.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: - case 180 /* ObjectBindingPattern */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: case 166 /* TypeLiteral */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 241 /* CaseBlock */: - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 244 /* CaseBlock */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 188 /* NewExpression */: + case 190 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 187 /* CallExpression */: - case 191 /* ParenthesizedExpression */: - case 173 /* ParenthesizedType */: + case 189 /* CallExpression */: + case 193 /* ParenthesizedExpression */: + case 175 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -87469,13 +88251,13 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 159 /* ConstructSignature */: case 158 /* CallSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -87485,19 +88267,19 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 183 /* ArrayLiteralExpression */: - case 181 /* ArrayBindingPattern */: - case 186 /* ElementAccessExpression */: + case 185 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 188 /* ElementAccessExpression */: case 147 /* ComputedPropertyName */: case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); @@ -87506,44 +88288,44 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); case 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 195 /* TypeOfExpression */: - case 194 /* DeleteExpression */: - case 196 /* VoidExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: + case 197 /* TypeOfExpression */: + case 196 /* DeleteExpression */: + case 198 /* VoidExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -87607,38 +88389,30 @@ var ts; * position >= start and (position < end or (position === end && token is literal or keyword or identifier)) */ function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, /*includeJsDocComment*/ true, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); + return getTouchingToken(sourceFile, position, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); } ts.getTouchingPropertyName = getTouchingPropertyName; /** * Returns the token if position is in [start, end). * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true */ - function getTouchingToken(sourceFile, position, includeJsDocComment, includePrecedingTokenAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false, includeJsDocComment); + function getTouchingToken(sourceFile, position, includePrecedingTokenAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile, position, includeJsDocComment, includeEndPosition) { - if (includeEndPosition === void 0) { includeEndPosition = false; } - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, includeEndPosition, includeJsDocComment); + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, /*includeEndPosition*/ false); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition, includeJsDocComment) { + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition) { var current = sourceFile; outer: while (true) { - if (ts.isToken(current)) { - // exit early - return current; - } // find the child that contains 'position' for (var _i = 0, _a = current.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; - if (!includeJsDocComment && ts.isJSDocNode(child)) { - continue; - } - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { // If this child begins after position, then all subsequent children will as well. break; @@ -87669,7 +88443,7 @@ var ts; function findTokenOnLeftOfPosition(file, position) { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. - var tokenAtPosition = getTokenAtPosition(file, position, /*includeJsDocComment*/ false); + var tokenAtPosition = getTokenAtPosition(file, position); if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } @@ -87683,19 +88457,14 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - var children = n.getChildren(); - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; + return ts.firstDefined(n.getChildren(), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || // previous token ends exactly at the beginning of child (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child, sourceFile)) { - return find(child); - } - } - return undefined; + return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find(child) : undefined; + }); } } ts.findNextToken = findNextToken; @@ -87703,7 +88472,7 @@ var ts; * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { + function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) { var result = find(startNode || sourceFile); ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; @@ -87720,7 +88489,7 @@ var ts; // we need to find the last token in a previous child. // 2) `position` is within the same span: we recurse on `child`. if (position < child.end) { - var start = child.getStart(sourceFile, includeJsDoc); + var start = child.getStart(sourceFile, /*includeJsDoc*/ !excludeJsdoc); var lookInPreviousChild = (start >= position) || // cursor in the leading trivia !nodeHasTokens(child, sourceFile) || isWhiteSpaceOnlyJsxText(child); @@ -87735,7 +88504,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 277 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); // 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. @@ -87795,7 +88564,7 @@ var ts; * returns true if the position is in between the open and close elements of an JSX expression. */ function isInsideJsxElementOrAttribute(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); if (!token) { return false; } @@ -87807,17 +88576,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { return true; } return false; @@ -87827,7 +88596,7 @@ var ts; return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; } function isInTemplateString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; @@ -87869,7 +88638,7 @@ var ts; if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { - return { called: token, nTypeArguments: nTypeArguments }; + return ts.isDeclarationName(token) ? undefined : { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -87939,19 +88708,13 @@ var ts; * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - function isInComment(sourceFile, position, tokenAtPosition, predicate) { - return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); + function isInComment(sourceFile, position, tokenAtPosition) { + return ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*precedingToken*/ undefined, tokenAtPosition); } ts.isInComment = isInComment; function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*"; - } + var token = getTokenAtPosition(sourceFile, position); + return !!ts.findAncestor(token, ts.isJSDoc); } ts.hasDocComment = hasDocComment; function nodeHasTokens(n, sourceFile) { @@ -87960,7 +88723,7 @@ var ts; return n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node) { - var flags = ts.getCombinedModifierFlags(node); + var flags = ts.isDeclaration(node) ? ts.getCombinedModifierFlags(node) : 0 /* None */; var result = []; if (flags & 8 /* Private */) result.push("private" /* privateMemberModifier */); @@ -87980,10 +88743,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -88028,18 +88791,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 183 /* ArrayLiteralExpression */ || - node.kind === 184 /* ObjectLiteralExpression */) { + if (node.kind === 185 /* ArrayLiteralExpression */ || + node.kind === 186 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 200 /* BinaryExpression */ && + if (node.parent.kind === 202 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 222 /* ForOfStatement */ && + if (node.parent.kind === 225 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -88047,7 +88810,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -88055,19 +88818,17 @@ var ts; } ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; function isInReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ true); } ts.isInReferenceComment = isInReferenceComment; function isInNonReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ false); } ts.isInNonReferenceComment = isInNonReferenceComment; + function isInReferenceCommentWorker(sourceFile, position, shouldBeReference) { + var range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined); + return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); + } function createTextSpanFromNode(node, sourceFile) { return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); } @@ -88181,13 +88942,17 @@ var ts; QuotePreference[QuotePreference["Single"] = 0] = "Single"; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); + function quotePreferenceFromString(str, sourceFile) { + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + } + ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference) { return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; } else { - var firstModuleSpecifier = ts.firstOrUndefined(sourceFile.imports); - return !!firstModuleSpecifier && !ts.isStringDoubleQuoted(firstModuleSpecifier, sourceFile) ? 0 /* Single */ : 1 /* Double */; + var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, ts.isStringLiteral); + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; } } ts.getQuotePreference = getQuotePreference; @@ -88267,6 +89032,37 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + var NodeMap = /** @class */ (function () { + function NodeMap() { + this.map = ts.createMap(); + } + NodeMap.prototype.get = function (node) { + var res = this.map.get(String(ts.getNodeId(node))); + return res && res.value; + }; + NodeMap.prototype.getOrUpdate = function (node, setValue) { + var res = this.get(node); + if (res) + return res; + var value = setValue(); + this.set(node, value); + return value; + }; + NodeMap.prototype.set = function (node, value) { + this.map.set(String(ts.getNodeId(node)), { node: node, value: value }); + }; + NodeMap.prototype.has = function (node) { + return this.map.has(String(ts.getNodeId(node))); + }; + NodeMap.prototype.forEach = function (cb) { + this.map.forEach(function (_a) { + var node = _a.node, value = _a.value; + return cb(value, node); + }); + }; + return NodeMap; + }()); + ts.NodeMap = NodeMap; function getParentNodeInSpan(node, file, span) { if (!node) return undefined; @@ -88282,6 +89078,10 @@ var ts; return ts.textSpanContainsPosition(span, node.getStart(file)) && node.getEnd() <= ts.textSpanEnd(span); } + function findModifier(node, kind) { + return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); + } + ts.findModifier = findModifier; /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); @@ -88494,7 +89294,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && + (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -89112,10 +89912,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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -89327,18 +90127,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -89425,22 +90225,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -89469,17 +90269,17 @@ var ts; var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 232 /* VariableDeclaration */ || + if (parent.kind === 235 /* VariableDeclaration */ || parent.kind === 152 /* PropertyDeclaration */ || parent.kind === 149 /* Parameter */ || - parent.kind === 262 /* JsxAttribute */) { + parent.kind === 265 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 200 /* BinaryExpression */ || - parent.kind === 198 /* PrefixUnaryExpression */ || - parent.kind === 199 /* PostfixUnaryExpression */ || - parent.kind === 201 /* ConditionalExpression */) { + if (parent.kind === 202 /* BinaryExpression */ || + parent.kind === 200 /* PrefixUnaryExpression */ || + parent.kind === 201 /* PostfixUnaryExpression */ || + parent.kind === 203 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -89490,7 +90290,7 @@ var ts; } else if (tokenKind === 9 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -89506,7 +90306,7 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -89516,17 +90316,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -89578,12 +90378,12 @@ var ts; }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker)); + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; - function getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; + var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); @@ -89595,7 +90395,6 @@ var ts; } } else { - // Check for node modules return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } } @@ -89761,14 +90560,16 @@ var ts; function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") && ts.startsWith(path, fragment) ? [{ name: path, kind: "directory" /* directory */ }] : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); - if (!ts.startsWith(fragment, pathPrefix)) { - return [{ name: pathPrefix, kind: "directory" /* directory */ }]; + var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); + return remainingFragment === undefined ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { + return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); + }); + function justPathMappingName(name) { + return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; } - var remainingFragment = fragment.slice(pathPrefix.length); - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { if (!host.readDirectory) { @@ -89825,7 +90626,7 @@ var ts; return nonRelativeModuleNames; } function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { - var token = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, position); var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); var range = commentRanges && ts.find(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end; }); if (!range) { @@ -90298,11 +91099,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.parent.parent.kind) { case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent)), isNewIdentifier: false }; - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -90310,12 +91111,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 179 /* ImportType */: + case 181 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(node.parent.parent) && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -90332,7 +91133,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -90345,8 +91146,8 @@ var ts; } return undefined; } - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -90355,9 +91156,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 254 /* ExternalModuleReference */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 257 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -90434,7 +91235,7 @@ var ts; || ts.codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) : symbol.name; } - function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, getCanonicalFileName, preferences, cancellationToken) { + function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); var name = entryId.name; @@ -90463,7 +91264,7 @@ var ts; } case "symbol": { var symbol = symbolCompletion.symbol, location = symbolCompletion.location, symbolToOriginInfoMap = symbolCompletion.symbolToOriginInfoMap, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -90506,14 +91307,14 @@ var ts; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, allSourceFiles, preferences) { + function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, allSourceFiles, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || symbolOriginInfo.type !== "export") { return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; + var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, allSourceFiles, formatContext, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { @@ -90554,11 +91355,11 @@ var ts; return getContextualTypeFromParent(previousToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -90568,7 +91369,7 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo @@ -90583,15 +91384,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checker.getContextualType(parent); - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 266 /* CaseClause */: + case 269 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -90607,16 +91408,15 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 274 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); - var currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // TODO: GH#15853 + var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) log("getCompletionData: Get current token: " + (ts.timestamp() - start)); start = ts.timestamp(); - // Completion not allowed inside comments, bail out if this is the case var insideComment = ts.isInComment(sourceFile, position, currentToken); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); var insideJsDocTagTypeExpression = false; @@ -90659,11 +91459,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { - currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 299 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 302 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -90681,7 +91481,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); // The decision to provide completion depends on the contextToken, which is determined through the previousToken. // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file @@ -90690,7 +91490,7 @@ var ts; // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { var start_1 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1)); } // Find the node where completion is requested on. @@ -90713,15 +91513,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; case 146 /* QualifiedName */: node = parent.left; break; - case 179 /* ImportType */: - case 210 /* MetaProperty */: + case 181 /* ImportType */: + case 212 /* MetaProperty */: node = parent; break; default: @@ -90734,7 +91534,7 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 185 /* PropertyAccessExpression */) { + if (parent && parent.kind === 187 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -90742,39 +91542,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 200 /* BinaryExpression */: - if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { - // It has a left-hand side, so we're not in an opening JSX tag. + case 202 /* BinaryExpression */: + if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: + case 260 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -90827,11 +91626,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: - case 294 /* JSDocReturnTag */: - case 296 /* JSDocTypeTag */: - case 298 /* JSDocTypedefTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: + case 297 /* JSDocReturnTag */: + case 299 /* JSDocTypeTag */: + case 301 /* JSDocTypedefTag */: return true; default: return false; @@ -90865,7 +91664,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -90889,27 +91688,31 @@ var ts; // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker, /*isForAccess*/ true)); + symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker)); } else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } } } function addPropertySymbol(symbol) { + // For a computed property with an accessible name like `Symbol.iterator`, + // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. - var symbolSymbol = ts.firstDefined(symbol.declarations, function (decl) { - var name = ts.getNameOfDeclaration(decl); - var leftName = name.kind === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; - return leftName && typeChecker.getSymbolAtLocation(leftName); - }); - if (symbolSymbol) { - symbols.push(symbolSymbol); - symbolToOriginInfoMap[ts.getSymbolId(symbolSymbol)] = { type: "symbol-member" }; + var computedPropertyName = ts.firstDefined(symbol.declarations, function (decl) { return ts.tryCast(ts.getNameOfDeclaration(decl), ts.isComputedPropertyName); }); + if (computedPropertyName) { + var leftMostName = getLeftMostName(computedPropertyName.expression); // The completion is for `Symbol`, not `iterator`. + var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); + // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. + var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); + if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + symbols.push(firstAccessibleSymbol); + symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = { type: "symbol-member" }; + } } else { symbols.push(symbol); @@ -90993,10 +91796,10 @@ var ts; var symbolMeanings = 67901928 /* Type */ | 67216319 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 274 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { - for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { + for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { type: "this-type" }; symbols.push(symbol); @@ -91029,10 +91832,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 274 /* SourceFile */: - case 202 /* TemplateExpression */: - case 265 /* JsxExpression */: - case 213 /* Block */: + case 277 /* SourceFile */: + case 204 /* TemplateExpression */: + case 268 /* JsxExpression */: + case 216 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -91079,12 +91882,12 @@ var ts; return parentKind === 152 /* PropertyDeclaration */ || parentKind === 151 /* PropertySignature */ || parentKind === 149 /* Parameter */ || - parentKind === 232 /* VariableDeclaration */ || + parentKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 237 /* TypeAliasDeclaration */; + return parentKind === 240 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 208 /* AsExpression */; + return parentKind === 210 /* AsExpression */; } } return false; @@ -91187,11 +91990,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; + if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; } } return false; @@ -91201,36 +92004,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 187 /* CallExpression */ // func( a, | + return containingNodeKind === 189 /* CallExpression */ // func( a, | || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 188 /* NewExpression */ // new C(a, | - || containingNodeKind === 183 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 200 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 190 /* NewExpression */ // new C(a, | + || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 187 /* CallExpression */ // func( | + return containingNodeKind === 189 /* CallExpression */ // func( | || containingNodeKind === 155 /* Constructor */ // constructor( | - || containingNodeKind === 188 /* NewExpression */ // new C(a| - || containingNodeKind === 191 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 173 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + || containingNodeKind === 190 /* NewExpression */ // new C(a| + || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + return containingNodeKind === 185 /* ArrayLiteralExpression */ // [ | || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 129 /* ModuleKeyword */: // module | case 130 /* NamespaceKeyword */: // namespace | return true; case 23 /* DotToken */: - return containingNodeKind === 239 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 200 /* BinaryExpression */; // x = a| + return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 202 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: @@ -91268,16 +92071,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = hasIndexSignature(typeForObject); - typeMembers = getPropertiesForCompletion(typeForObject, typeChecker, /*isForAccess*/ false); + typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -91288,7 +92091,7 @@ var ts; // through type declaration or inference. // 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 = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 222 /* ForOfStatement */; + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 225 /* ForOfStatement */; if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); @@ -91335,7 +92138,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -91379,8 +92182,8 @@ var ts; if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented var baseSymbols = ts.flatMap(ts.getAllSuperTypeNodes(decl), function (baseTypeNode) { - var type = typeChecker.getTypeAtLocation(baseTypeNode); // TODO: GH#18217 - return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); + var type = typeChecker.getTypeAtLocation(baseTypeNode); + return type && typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); } @@ -91450,14 +92253,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: - case 263 /* JsxAttributes */: - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { + case 187 /* PropertyAccessExpression */: + case 266 /* JsxAttributes */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 262 /* JsxAttribute */) { + else if (parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91469,7 +92272,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent && ((parent.kind === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91479,8 +92282,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 265 /* JsxExpression */ && - parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { + parent.kind === 268 /* JsxExpression */ && + parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91488,7 +92291,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91508,49 +92311,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 232 /* VariableDeclaration */ || - containingNodeKind === 233 /* VariableDeclarationList */ || - containingNodeKind === 214 /* VariableStatement */ || - containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 235 /* VariableDeclaration */ || + containingNodeKind === 236 /* VariableDeclarationList */ || + containingNodeKind === 217 /* VariableStatement */ || + containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 182 /* BindingElement */; // var {x :html| + return containingNodeKind === 184 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 269 /* CatchClause */ || + return containingNodeKind === 272 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | - containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | + containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| + (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 248 /* ImportSpecifier */ || - containingNodeKind === 252 /* ExportSpecifier */ || - containingNodeKind === 246 /* NamespaceImport */; + return containingNodeKind === 251 /* ImportSpecifier */ || + containingNodeKind === 255 /* ExportSpecifier */ || + containingNodeKind === 249 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -91634,9 +92437,9 @@ 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 !== 270 /* PropertyAssignment */ && - m.kind !== 271 /* ShorthandPropertyAssignment */ && - m.kind !== 182 /* BindingElement */ && + if (m.kind !== 273 /* PropertyAssignment */ && + m.kind !== 274 /* ShorthandPropertyAssignment */ && + m.kind !== 184 /* BindingElement */ && m.kind !== 154 /* MethodDeclaration */ && m.kind !== 156 /* GetAccessor */ && m.kind !== 157 /* SetAccessor */) { @@ -91658,7 +92461,7 @@ var ts; // NOTE: if one only performs this step when m.name is an identifier, // things like '__proto__' are not filtered out. var name = ts.getNameOfDeclaration(m); - existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; + existingName = name && ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } @@ -91717,7 +92520,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 262 /* JsxAttribute */) { + if (attr.kind === 265 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -91824,47 +92627,28 @@ var ts; } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { - var jsDoc = getJsDocHavingNode(node).jsDoc; - if (!jsDoc) - return undefined; - for (var _i = 0, jsDoc_1 = jsDoc; _i < jsDoc_1.length; _i++) { - var _a = jsDoc_1[_i], pos = _a.pos, end = _a.end, tags = _a.tags; - if (!tags || position < pos || position > end) - continue; - for (var i = tags.length - 1; i >= 0; i--) { - var tag = tags[i]; - if (position >= tag.pos) { - return tag; - } - } - } + var jsdoc = ts.findAncestor(node, ts.isJSDoc); + return jsdoc && jsdoc.tags && (ts.rangeContainsPosition(jsdoc, position) ? ts.findLast(jsdoc.tags, function (tag) { return tag.pos < position; }) : undefined); } - function getJsDocHavingNode(node) { - if (!ts.isToken(node)) - return node; - switch (node.kind) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - // if the current token is var, let or const, skip the VariableDeclarationList - return node.parent.parent; - default: - return node.parent; - } + function getPropertiesForObjectExpression(contextualType, obj, checker) { + return contextualType.isUnion() + ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { + // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. + return !(memberType.flags & 32764 /* Primitive */ || + checker.isArrayLikeType(memberType) || + ts.typeHasCallOrConstructSignatures(memberType, checker) || + checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); + })) + : contextualType.getApparentProperties(); } /** * Gets all properties on a type, but if that type is a union of several types, * excludes array-like types or callable/constructable types. */ - function getPropertiesForCompletion(type, checker, isForAccess) { - if (!(type.isUnion())) { - return ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); - } - // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - var filteredTypes = isForAccess ? type.types : type.types.filter(function (memberType) { - return !(memberType.flags & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); - }); - return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); + function getPropertiesForCompletion(type, checker) { + return type.isUnion() + ? ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") + : ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } /** * Returns the immediate owning class declaration of a context token, @@ -91873,7 +92657,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 300 /* SyntaxList */: + case 303 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -91920,7 +92704,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -91929,12 +92713,16 @@ var ts; return ts.Debug.assertNever(triggerCharacter); } } + function binaryExpressionMayBeOpenTag(_a) { + var left = _a.left; + return ts.nodeIsMissing(left); + } function isStringLiteralOrTemplate(node) { switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: return true; default: return false; @@ -92068,7 +92856,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -92100,16 +92888,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 227 /* SwitchStatement */: - if (statement.kind === 223 /* ContinueStatement */) { + case 230 /* SwitchStatement */: + if (statement.kind === 226 /* ContinueStatement */) { return false; } // falls through - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -92119,24 +92907,17 @@ var ts; }); } function getModifierOccurrences(modifier, declaration) { - var modifierFlag = ts.modifierToFlag(modifier); - return ts.mapDefined(getNodesToSearchForModifier(declaration, modifierFlag), function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - var mod = ts.find(node.modifiers, function (m) { return m.kind === modifier; }); - ts.Debug.assert(!!mod); - return mod; - } - }); + return ts.mapDefined(getNodesToSearchForModifier(declaration, ts.modifierToFlag(modifier)), function (node) { return ts.findModifier(node, modifier); }); } function getNodesToSearchForModifier(declaration, modifierFlag) { // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: - case 213 /* Block */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: + case 216 /* Block */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -92146,10 +92927,10 @@ var ts; } case 155 /* Constructor */: case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: var 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. @@ -92182,7 +92963,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 218 /* DoStatement */) { + if (loopNode.kind === 221 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -92202,13 +92983,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -92580,12 +93361,13 @@ var ts; if (!markSeenDirectImport(direct)) { continue; } - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -92598,20 +93380,20 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -92621,7 +93403,7 @@ var ts; directImports.push(direct); } break; - case 179 /* ImportType */: + case 181 /* ImportType */: directImports.push(direct); break; default: @@ -92638,7 +93420,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -92693,7 +93475,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 243 /* ImportEqualsDeclaration */) { + if (decl.kind === 246 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -92703,7 +93485,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 179 /* ImportType */) { + if (decl.kind === 181 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -92718,17 +93500,17 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 250 /* ExportDeclaration */) { + if (decl.kind === 253 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -92778,7 +93560,7 @@ var ts; } } else { - var localSymbol = element.kind === 252 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 255 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -92807,7 +93589,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 274 /* SourceFile */) { + if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -92837,7 +93619,8 @@ var ts; var map = ts.createMap(); for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { @@ -92854,7 +93637,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -92869,15 +93652,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: { + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -92901,7 +93684,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 185 /* PropertyAccessExpression */) { + if (parent.kind === 187 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -93023,10 +93806,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 232 /* VariableDeclaration */) { + if (parent.kind === 235 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -93035,15 +93818,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -93076,21 +93859,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 274 /* SourceFile */) { + if (parent.kind === 277 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -93125,13 +93908,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // 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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; @@ -93147,8 +93930,7 @@ var ts; return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true }); } } - function findReferencedEntries(program, cancellationToken, sourceFiles, sourceFile, position, options) { - var node = ts.getTouchingPropertyName(sourceFile, position); + function findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options) { return ts.map(flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options)), toReferenceEntry); } FindAllReferences.findReferencedEntries = findReferencedEntries; @@ -93235,13 +94017,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 205 /* ClassExpression */) { + else if (node.kind === 207 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -93354,10 +94136,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -93515,7 +94297,7 @@ var ts; this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; - /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ + /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { if (searchOptions === void 0) { searchOptions = {}; } // Note: if this is an external module symbol, the name doesn't include quotes. @@ -93598,6 +94380,24 @@ var ts; } } } + function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { + var importTracker = FindAllReferences.createImportTracker(sourceFiles, ts.arrayToSet(sourceFiles, function (f) { return f.fileName; }), checker, cancellationToken); + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers; + for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { + var importLocation = importSearches_2[_i][0]; + cb(importLocation); + } + for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) { + var indirectUser = indirectUsers_2[_b]; + for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { + var node = _d[_c]; + if (ts.isIdentifier(node) && checker.getSymbolAtLocation(node) === exportSymbol) { + cb(node); + } + } + } + } + Core.eachExportReference = eachExportReference; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; @@ -93630,9 +94430,9 @@ var ts; : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 184 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 182 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -93654,7 +94454,7 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -93664,7 +94464,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 235 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -93693,7 +94493,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -93732,6 +94532,28 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function eachSignatureCall(signature, sourceFiles, checker, cb) { + if (!signature.name || !ts.isIdentifier(signature.name)) + return; + var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; + for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { + var name = _b[_a]; + if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) + continue; + var called = ts.climbPastPropertyAccess(name); + var call = called.parent; + if (!ts.isCallExpression(call) || call.expression !== called) + continue; + var referenceSymbol = checker.getSymbolAtLocation(name); + if (referenceSymbol && checker.getRootSymbols(referenceSymbol).some(function (s) { return s === symbol; })) { + cb(call); + } + } + } + } + Core.eachSignatureCall = eachSignatureCall; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos); }); @@ -93956,6 +94778,7 @@ var ts; function getReferenceForShorthandProperty(_a, search, state) { var flags = _a.flags, valueDeclaration = _a.valueDeclaration; var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + var name = valueDeclaration && ts.getNameOfDeclaration(valueDeclaration); /* * 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 @@ -93963,8 +94786,8 @@ var ts; * 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. */ - if (!(flags & 33554432 /* Transient */) && search.includes(shorthandValueSymbol)) { - addReference(ts.getNameOfDeclaration(valueDeclaration), shorthandValueSymbol, state); + if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { @@ -94072,7 +94895,7 @@ var ts; if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -94092,7 +94915,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 213 /* Block */) { + if (body.kind === 216 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -94120,13 +94943,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 183 /* ArrayLiteralExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 185 /* ArrayLiteralExpression */: return true; default: return false; @@ -94224,20 +95047,20 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 = ts.flatMap(searchSpaceNode.kind === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -94245,19 +95068,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 274 /* SourceFile */: - return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); + case 277 /* SourceFile */: + return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -94459,16 +95282,17 @@ var ts; }); } ts.getEditsForFileRename = getEditsForFileRename; + // exported for tests function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var canonicalPath = getCanonicalFileName(path); - if (canonicalPath === canonicalOldPath) + if (getCanonicalFileName(path) === canonicalOldPath) return newFileOrDirPath; - var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + var suffix = ts.tryRemoveDirectoryPrefix(path, canonicalOldPath, getCanonicalFileName); return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; }; } + ts.getPathUpdater = getPathUpdater; function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) @@ -94539,9 +95363,10 @@ var ts; } } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { + var allFiles = program.getSourceFiles(); var _loop_3 = function (sourceFile) { - var newFromOld = oldToNew(sourceFile.fileName); - var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.fileName; + var newFromOld = oldToNew(sourceFile.path); + var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.path; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); var oldFromNew = newToOld(sourceFile.fileName); var oldImportFromPath = oldFromNew || sourceFile.fileName; @@ -94554,19 +95379,23 @@ var ts; var newAbsolute = oldToNew(oldAbsolute); return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); }, function (importLiteral) { + var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + // No need to update if it's an ambient module^M + if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. // TODO:GH#18217 ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) - : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); - // If neither the importing source file nor the imported file moved, do nothing. - return toImport === undefined || !toImport.updated && !importingSourceFileMoved - ? undefined - : ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, preferences); + : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew); + // Need an update if the imported file moved, or the importing file moved and was using a relative path. + return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text))) + ? ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, allFiles, preferences) + : undefined; }); }; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; + for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { + var sourceFile = allFiles_1[_i]; _loop_3(sourceFile); } } @@ -94576,12 +95405,10 @@ var ts; function combinePathsSafe(pathA, pathB) { return ts.ensurePathIsNonModuleName(combineNormal(pathA, pathB)); } - function getSourceFileToImport(importLiteral, importingSourceFile, program, host, oldToNew) { - var symbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); - if (symbol) { - if (symbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) - return undefined; // No need to update if it's an ambient module - var oldFileName = ts.find(symbol.declarations, ts.isSourceFile).fileName; + function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) { + if (importedModuleSymbol) { + // `find` should succeed because we checked for ambient modules before calling this function. + var oldFileName = ts.find(importedModuleSymbol.declarations, ts.isSourceFile).fileName; var newFileName = oldToNew(oldFileName); return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true }; } @@ -94657,7 +95484,8 @@ var ts; return getDefinitionInfoForIndexSignatures(node, typeChecker); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); - if (calledDeclaration) { + // Don't go to the component constructor definition for a JSX element, just go to the component definition. + if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && ts.isConstructorDeclaration(calledDeclaration))) { var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. @@ -94677,7 +95505,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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -94726,7 +95554,7 @@ var ts; */ function symbolMatchesSignature(s, calledDeclaration) { return s === calledDeclaration.symbol || s === calledDeclaration.symbol.parent || - ts.isVariableDeclaration(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; + !ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; } function getReferenceAtPosition(sourceFile, position, program) { var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); @@ -94819,11 +95647,11 @@ var ts; return true; } switch (declaration.kind) { - case 245 /* ImportClause */: - case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: return true; - case 248 /* ImportSpecifier */: - return declaration.parent.kind === 247 /* NamedImports */; + case 251 /* ImportSpecifier */: + return declaration.parent.kind === 250 /* NamedImports */; default: return false; } @@ -94877,7 +95705,7 @@ var ts; return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); } function findReferenceInPosition(refs, pos) { - return ts.find(refs, function (ref) { return ref.pos <= pos && pos <= ref.end; }); + return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; function getDefinitionInfoForFileReference(name, targetFileName) { @@ -94982,11 +95810,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: return [declaration]; - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -95007,16 +95835,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return withNode(tag.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -95146,7 +95974,7 @@ var ts; if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { return undefined; } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; @@ -95164,10 +95992,7 @@ var ts; var singleLineResult = "/** */"; return { newText: singleLineResult, caretOffset: 3 }; } - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - // replace non-whitespace characters in prefix with spaces. - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); + var indentationStr = getIndentationStringAtPosition(sourceFile, position); // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -95175,8 +96000,7 @@ var ts; // * TODO: other tags. // * the closing comment line // * if the caret was directly in front of the object, then we add an extra line and indentation. - var preamble = "/**" + newLine + - indentationStr + " * "; + var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + @@ -95184,6 +96008,14 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function getIndentationStringAtPosition(sourceFile, position) { + var text = sourceFile.text; + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + var pos = lineStart; + for (; pos <= position && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) + ; + return text.slice(lineStart, pos); + } function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; @@ -95195,20 +96027,21 @@ var ts; function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: case 151 /* PropertySignature */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 237 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 240 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -95216,14 +96049,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 274 /* SourceFile */: + case 277 /* SourceFile */: return undefined; - case 239 /* ModuleDeclaration */: + case 242 /* 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 { }'. - return commentOwner.parent.kind === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 200 /* BinaryExpression */: { + return commentOwner.parent.kind === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 202 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -95243,14 +96076,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return rightHandSide.parameters; - case 205 /* ClassExpression */: { + case 207 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -95279,15 +96112,12 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; _loop_4(sourceFile); } rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - return rawItems.map(createNavigateToItem); + return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } NavigateTo.getNavigateToItems = getNavigateToItems; function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { @@ -95302,23 +96132,23 @@ var ts; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 + // If the pattern has dots in it, then also see if the declaration container matches as well. + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } } else { - // If the pattern has dots in it, then also see if the declaration container matches as well. rawItems.push({ name: name, fileName: fileName, matchKind: match.kind, isCaseSensitive: match.isCaseSensitive, declaration: declaration }); } } } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 245 /* ImportClause */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - var importer = checker.getSymbolAtLocation(declaration.name); + case 248 /* ImportClause */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; default: @@ -95363,14 +96193,14 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; + if (name && name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + return ts.emptyArray; } // Now, walk up our containers, adding all their names to the container array. var container = ts.getContainerNode(declaration); while (container) { if (!tryAddSingleDeclarationName(container, containers)) { - return undefined; + return ts.emptyArray; } container = ts.getContainerNode(container); } @@ -95395,7 +96225,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ // TODO: GH#18217 Just use `container ? ...` + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -95556,19 +96386,19 @@ var ts; addLeafNode(node); } break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addLeafNode(importClause); + addLeafNode(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -95579,8 +96409,8 @@ var ts; } } break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -95601,12 +96431,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -95616,9 +96446,9 @@ var ts; } endNode(); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -95626,18 +96456,18 @@ var ts; } endNode(); break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 252 /* ExportSpecifier */: - case 243 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: case 160 /* IndexSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -95645,7 +96475,7 @@ var ts; case 3 /* PrototypeProperty */: case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); - break; + return; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: @@ -95721,7 +96551,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -95731,7 +96561,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -95761,7 +96591,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -95769,16 +96599,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -95788,16 +96618,16 @@ var ts; } } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -95835,25 +96665,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 274 /* SourceFile */: - case 237 /* TypeAliasDeclaration */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 277 /* SourceFile */: + case 240 /* TypeAliasDeclaration */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return true; case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -95863,8 +96693,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; @@ -95875,7 +96705,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; + return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; }); } } @@ -95932,7 +96762,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -95943,16 +96773,16 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 + return decl.body.kind === 242 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -95962,16 +96792,16 @@ var ts; return ts.declarationNameToString(node.name); } // See if it is a var initializer. If so, use the var name. - else if (node.parent.kind === 232 /* VariableDeclaration */) { + else if (node.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (node.parent.kind === 200 /* BinaryExpression */ && + else if (node.parent.kind === 202 /* BinaryExpression */ && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name - else if (node.parent.kind === 270 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 273 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -95984,9 +96814,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: return true; default: return false; @@ -96042,10 +96872,7 @@ var ts; }); // Delete or replace the first import. if (newImportDecls.length === 0) { - changeTracker.deleteNode(sourceFile, oldImportDecls[0], { - useNonAdjustedStartPosition: true, - useNonAdjustedEndPosition: false, - }); + changeTracker.delete(sourceFile, oldImportDecls[0]); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. @@ -96057,7 +96884,7 @@ var ts; } // Delete any subsequent imports. for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + changeTracker.delete(sourceFile, oldImportDecls[i]); } } } @@ -96353,7 +97180,7 @@ var ts; var currentLineStart = lineStarts[i]; var lineEnd = i + 1 === lineStarts.length ? sourceFile.getEnd() : lineStarts[i + 1] - 1; var lineText = sourceFile.text.substring(currentLineStart, lineEnd); - var result = lineText.match(/^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/); + var result = isRegionDelimiter(lineText); if (!result || ts.isInComment(sourceFile, currentLineStart)) { continue; } @@ -96371,6 +97198,10 @@ var ts; } } } + var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + function isRegionDelimiter(lineText) { + return regionDelimiterRegExp.exec(lineText); + } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); if (!comments) @@ -96378,11 +97209,19 @@ var ts; var firstSingleLineCommentStart = -1; var lastSingleLineCommentEnd = -1; var singleLineCommentCount = 0; + var sourceText = sourceFile.getFullText(); for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { var _a = comments_1[_i], kind = _a.kind, pos = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { case 2 /* SingleLineCommentTrivia */: + // never fold region delimiters into single-line comment regions + var commentText = sourceText.slice(pos, end); + if (isRegionDelimiter(commentText)) { + combineAndAddMultipleSingleLineComments(); + singleLineCommentCount = 0; + break; + } // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (singleLineCommentCount === 0) { @@ -96413,24 +97252,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* ArrowFunction */); } // 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. switch (n.parent.kind) { - case 218 /* DoStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 269 /* CatchClause */: + case 221 /* DoStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 272 /* CatchClause */: return spanForNode(n.parent); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -96445,16 +97284,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanForNode(n.parent); - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 241 /* CaseBlock */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 244 /* CaseBlock */: return spanForNode(n); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -96528,7 +97367,6 @@ var ts; if (!candidateMatch) { return undefined; } - candidateContainers = candidateContainers || []; // -1 because the last part was checked against the name, and only the rest // of the parts are checked against the container. if (dotSeparatedSegments.length - 1 > candidateContainers.length) { @@ -97287,21 +98125,12 @@ var ts; (function (ts) { var Rename; (function (Rename) { - function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); + function getRenameInfo(program, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }) : undefined; return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); - function isDefinedInLibraryFile(declaration) { - if (!defaultLibFileName) { - return false; - } - var sourceFile = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - return canonicalName === getCanonicalDefaultLibName(); - } } Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { @@ -97395,7 +98224,7 @@ var ts; InvocationKind[InvocationKind["Call"] = 0] = "Call"; InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; })(InvocationKind || (InvocationKind = {})); - function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { + function getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -97403,6 +98232,12 @@ var ts; // We are at the beginning of the file return undefined; } + if (shouldCarefullyCheckContext(triggerReason)) { + // In the middle of a string, don't provide signature help unless the user explicitly requested it. + if (ts.isInString(sourceFile, position, startingToken)) { + return undefined; + } + } var argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); if (!argumentInfo) return undefined; @@ -97421,6 +98256,10 @@ var ts; return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + function shouldCarefullyCheckContext(reason) { + // Only need to be careful if the user typed a character and signature help wasn't showing. + return !!reason && reason.kind === "characterTyped"; + } function getCandidateInfo(argumentInfo, checker) { var invocation = argumentInfo.invocation; if (invocation.kind === 0 /* Call */) { @@ -97538,10 +98377,10 @@ var ts; return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -97690,7 +98529,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 === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -97854,7 +98693,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var decl = ts.getDeclarationOfJSInitializer(node); if (decl) { var symbol_2 = decl.symbol; @@ -97864,7 +98703,7 @@ var ts; } } // falls through if no diagnostic was created - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -97894,11 +98733,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); // TODO: GH#18217 - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -97915,12 +98754,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -97943,7 +98782,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -97988,7 +98827,7 @@ var ts; if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return "parameter" /* parameterElement */; } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { return "const" /* constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { @@ -98031,11 +98870,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 257 /* JsxOpeningElement */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -98075,7 +98914,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 185 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 187 /* 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)) { @@ -98096,7 +98935,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 190 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* 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 @@ -98183,7 +99022,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 207 /* 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 @@ -98217,7 +99056,7 @@ var ts; } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } @@ -98227,7 +99066,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -98265,7 +99104,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 237 /* TypeAliasDeclaration */) { + else if (declaration.kind === 240 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -98282,7 +99121,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 273 /* EnumMember */) { + if (declaration.kind === 276 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -98312,17 +99151,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); break; - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -98331,7 +99170,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 243 /* ImportEqualsDeclaration */) { + if (declaration.kind === 246 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -98409,10 +99248,10 @@ var ts; // For some special property access expressions like `exports.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 === 274 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -98524,16 +99363,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 192 /* FunctionExpression */) { + if (declaration.kind === 194 /* FunctionExpression */) { return true; } - if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* FunctionDeclaration */) { + if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { + if (parent.kind === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { return false; } } @@ -98842,10 +99681,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 262 /* JsxAttribute */: - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 265 /* JsxAttribute */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. return ts.isKeyword(node.kind) || node.kind === 71 /* Identifier */; } @@ -99326,44 +100165,44 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 220 /* ForStatement */; + return context.contextNode.kind === 223 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 171 /* ConditionalType */: - case 208 /* AsExpression */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 173 /* ConditionalType */: + case 210 /* AsExpression */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 161 /* TypePredicate */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 182 /* BindingElement */: + case 184 /* BindingElement */: // equals in type X = ... - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: // equal in p = 0; case 149 /* Parameter */: - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] case 148 /* TypeParameter */: return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; @@ -99379,19 +100218,19 @@ var ts; return contextKind === 152 /* PropertyDeclaration */ || contextKind === 151 /* PropertySignature */ || contextKind === 149 /* Parameter */ || - contextKind === 232 /* VariableDeclaration */ || + contextKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 201 /* ConditionalExpression */ || - context.contextNode.kind === 171 /* ConditionalType */; + return context.contextNode.kind === 203 /* ConditionalExpression */ || + context.contextNode.kind === 173 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 180 /* ObjectBindingPattern */ || - context.contextNode.kind === 177 /* MappedType */ || + return context.contextNode.kind === 182 /* ObjectBindingPattern */ || + context.contextNode.kind === 179 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -99417,17 +100256,17 @@ var ts; return true; } switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 184 /* ObjectLiteralExpression */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 186 /* ObjectLiteralExpression */: + case 243 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -99435,13 +100274,13 @@ var ts; case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: case 158 /* CallSignature */: - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: case 155 /* Constructor */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -99450,40 +100289,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; + return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: case 166 /* TypeLiteral */: - case 239 /* ModuleDeclaration */: - case 250 /* ExportDeclaration */: - case 251 /* NamedExports */: - case 244 /* ImportDeclaration */: - case 247 /* NamedImports */: + case 242 /* ModuleDeclaration */: + case 253 /* ExportDeclaration */: + case 254 /* NamedExports */: + case 247 /* ImportDeclaration */: + case 250 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 269 /* CatchClause */: - case 240 /* ModuleBlock */: - case 227 /* SwitchStatement */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 272 /* CatchClause */: + case 243 /* ModuleBlock */: + case 230 /* SwitchStatement */: return true; - case 213 /* Block */: { + case 216 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { return true; } } @@ -99492,31 +100331,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 217 /* IfStatement */: - case 227 /* SwitchStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 230 /* TryStatement */: - case 218 /* DoStatement */: - case 226 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 229 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 269 /* CatchClause */: + case 272 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 184 /* ObjectLiteralExpression */; + return context.contextNode.kind === 186 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 187 /* CallExpression */; + return context.contextNode.kind === 189 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 188 /* NewExpression */; + return context.contextNode.kind === 190 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -99528,28 +100367,28 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 193 /* ArrowFunction */; + return context.contextNode.kind === 195 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 179 /* ImportType */; + return context.contextNode.kind === 181 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; + return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; + return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 262 /* JsxAttribute */; + return context.nextTokenParent.kind === 265 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 262 /* JsxAttribute */; + return context.contextNode.kind === 265 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 256 /* JsxSelfClosingElement */; + return context.contextNode.kind === 259 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -99567,14 +100406,14 @@ var ts; return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 239 /* ModuleDeclaration */; + return context.contextNode.kind === 242 /* ModuleDeclaration */; } function isObjectTypeContext(context) { return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -99588,21 +100427,21 @@ var ts; } switch (parent.kind) { case 162 /* TypeReference */: - case 190 /* TypeAssertionExpression */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 192 /* TypeAssertionExpression */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -99613,16 +100452,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 190 /* TypeAssertionExpression */; + return context.contextNode.kind === 192 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 209 /* NonNullExpression */; + return context.contextNode.kind === 211 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -99856,17 +100695,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 274 /* SourceFile */: - case 213 /* Block */: - case 240 /* ModuleBlock */: + return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 277 /* SourceFile */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -100089,10 +100928,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 235 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 236 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 234 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 238 /* EnumDeclaration */: return 238 /* EnumDeclaration */; + case 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; case 156 /* GetAccessor */: return 125 /* GetKeyword */; case 157 /* SetAccessor */: return 136 /* SetKeyword */; case 154 /* MethodDeclaration */: @@ -100102,7 +100941,10 @@ var ts; // falls through case 152 /* PropertyDeclaration */: case 149 /* Parameter */: - return ts.getNameOfDeclaration(node).kind; + var name = ts.getNameOfDeclaration(node); + if (name) { + return name.kind; + } } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { @@ -100146,15 +100988,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 177 /* MappedType */) { + if (container.kind !== 179 /* MappedType */) { return false; } break; @@ -100254,7 +101096,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -100622,56 +101464,47 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword + tokenAtPosition) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } + var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); + if (jsdoc) + tokenAtPosition = jsdoc.parent; var tokenStart = tokenAtPosition.getStart(sourceFile); if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } - if (precedingToken === undefined) { - precedingToken = ts.findPrecedingToken(position, sourceFile); - } + precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); - var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? - trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : - trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; - if (commentRanges) { - for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { - var range = commentRanges_1[_i]; - // The end marker of a single-line comment does not include the newline character. - // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for closed multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // However, unterminated multi-line comments *do* contain their end. - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - // - if ((range.pos < position && position < range.end || - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()))) { - return (range.kind === 3 /* MultiLineCommentTrivia */ || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; - } - } - } - return undefined; + var commentRanges = ts.concatenate(trailingRangesOfPreviousToken, leadingCommentRangesOfNextToken); + return commentRanges && ts.find(commentRanges, function (range) { return ts.rangeContainsPositionExclusive(range, position) || + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -100679,8 +101512,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -100785,9 +101618,9 @@ var ts; if (options.indentStyle === ts.IndentStyle.None) { return 0; } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword - if (enclosingCommentRange) { + var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -100805,7 +101638,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* 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 */) { @@ -100961,7 +101794,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 === 274 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -101009,7 +101842,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -101027,13 +101860,13 @@ var ts; switch (node.parent.kind) { case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.parent.properties; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return node.parent.elements; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: @@ -101044,21 +101877,21 @@ var ts; return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 188 /* NewExpression */: - case 187 /* CallExpression */: { + case 190 /* NewExpression */: + case 189 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -101098,10 +101931,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: node = node.expression; break; default: @@ -101166,82 +101999,82 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 216 /* ExpressionStatement */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 183 /* ArrayLiteralExpression */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 184 /* ObjectLiteralExpression */: + case 219 /* ExpressionStatement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 185 /* ArrayLiteralExpression */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 177 /* MappedType */: + case 179 /* MappedType */: case 168 /* TupleType */: - case 241 /* CaseBlock */: - case 267 /* DefaultClause */: - case 266 /* CaseClause */: - case 191 /* ParenthesizedExpression */: - case 185 /* PropertyAccessExpression */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 214 /* VariableStatement */: - case 249 /* ExportAssignment */: - case 225 /* ReturnStatement */: - case 201 /* ConditionalExpression */: - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: - case 256 /* JsxSelfClosingElement */: - case 265 /* JsxExpression */: + case 244 /* CaseBlock */: + case 270 /* DefaultClause */: + case 269 /* CaseClause */: + case 193 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 217 /* VariableStatement */: + case 252 /* ExportAssignment */: + case 228 /* ReturnStatement */: + case 203 /* ConditionalExpression */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: + case 259 /* JsxSelfClosingElement */: + case 268 /* JsxExpression */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 149 /* Parameter */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 173 /* ParenthesizedType */: - case 189 /* TaggedTemplateExpression */: - case 197 /* AwaitExpression */: - case 251 /* NamedExports */: - case 247 /* NamedImports */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 175 /* ParenthesizedType */: + case 191 /* TaggedTemplateExpression */: + case 199 /* AwaitExpression */: + case 254 /* NamedExports */: + case 250 /* NamedImports */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 152 /* PropertyDeclaration */: return true; - case 232 /* VariableDeclaration */: - case 270 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 235 /* VariableDeclaration */: + case 273 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } return true; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - return childKind !== 213 /* Block */; - case 250 /* ExportDeclaration */: - return childKind !== 251 /* NamedExports */; - case 244 /* ImportDeclaration */: - return childKind !== 245 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 247 /* NamedImports */); - case 255 /* JsxElement */: - return childKind !== 258 /* JsxClosingElement */; - case 259 /* JsxFragment */: - return childKind !== 261 /* JsxClosingFragment */; - case 170 /* IntersectionType */: - case 169 /* UnionType */: + return childKind !== 216 /* Block */; + case 253 /* ExportDeclaration */: + return childKind !== 254 /* NamedExports */; + case 247 /* ImportDeclaration */: + return childKind !== 248 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); + case 258 /* JsxElement */: + return childKind !== 261 /* JsxClosingElement */; + case 262 /* JsxFragment */: + return childKind !== 264 /* JsxClosingFragment */; + case 172 /* IntersectionType */: + case 171 /* UnionType */: if (childKind === 166 /* TypeLiteral */) { return false; } @@ -101253,17 +102086,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: { - if (parent.kind !== 213 /* Block */) { + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: { + if (parent.kind !== 216 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 194 /* FunctionExpression */ || grandParent.kind === 237 /* FunctionDeclaration */); } - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return true; default: return false; @@ -101392,7 +102225,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 184 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -101408,8 +102241,8 @@ var ts; this.formatContext = formatContext; this.changes = []; this.newFiles = []; - this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map + this.deletedNodes = []; } ChangeTracker.fromContext = function (context) { return new ChangeTracker(ts.getNewLineOrDefaultFromHost(context.host, context.formatContext.options), context.formatContext); @@ -101423,13 +102256,11 @@ var ts; this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); return this; }; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { - if (options === void 0) { options = {}; } - var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); - var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); - return this; + ChangeTracker.prototype.delete = function (sourceFile, node) { + this.deletedNodes.push({ sourceFile: sourceFile, node: node, }); + }; + ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { + this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } @@ -101444,30 +102275,6 @@ var ts; var endPosition = afterEndNode === undefined ? sourceFile.text.length : getAdjustedStartPosition(sourceFile, afterEndNode, options, Position.FullStart); this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); }; - ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { - var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); - if (!containingList) { - ts.Debug.fail("node is not a list element"); - return this; - } - var index = ts.indexOfNode(containingList, node); - if (index < 0) { - return this; - } - if (containingList.length === 1) { - this.deleteNode(sourceFile, node); - return this; - } - // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. - // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. - ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice"); - this.deletedNodesInLists.add(node); - this.deleteRange(sourceFile, { - pos: startPositionToDeleteNodeInList(sourceFile, node), - end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), - }); - return this; - }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); @@ -101533,7 +102340,7 @@ var ts; // If so, we do not want to separate the node from its comment if we can. // Otherwise, add an extra new line immediately before the error span. var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); - var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); @@ -101557,7 +102364,7 @@ var ts; } } else { - endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -101576,6 +102383,9 @@ var ts; else if (ts.isParameter(before)) { return {}; } + else if (ts.isStringLiteral(before) && ts.isImportDeclaration(before.parent) || ts.isNamedImports(before)) { + return { suffix: ", " }; + } return ts.Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { @@ -101635,6 +102445,9 @@ var ts; var endPosition = this.insertNodeAfterWorker(sourceFile, after, newNode); this.insertNodeAt(sourceFile, endPosition, newNode, this.getInsertNodeAfterOptions(sourceFile, after)); }; + ChangeTracker.prototype.insertNodeAtEndOfList = function (sourceFile, list, newNode) { + this.insertNodeAt(sourceFile, list.end, newNode, { prefix: ", " }); + }; ChangeTracker.prototype.insertNodesAfter = function (sourceFile, after, newNodes) { var endPosition = this.insertNodeAfterWorker(sourceFile, after, ts.first(newNodes)); this.insertNodesAt(sourceFile, endPosition, newNodes, this.getInsertNodeAfterOptions(sourceFile, after)); @@ -101655,32 +102468,34 @@ var ts; return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { - if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) { - return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - } - else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { - return { suffix: this.newLineCharacter }; - } - else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { - return { prefix: ", " }; - } - else if (ts.isPropertyAssignment(node)) { - return { suffix: "," + this.newLineCharacter }; - } - else if (ts.isParameter(node)) { - return {}; + switch (node.kind) { + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + case 235 /* VariableDeclaration */: + case 9 /* StringLiteral */: + case 71 /* Identifier */: + return { prefix: ", " }; + case 273 /* PropertyAssignment */: + return { suffix: "," + this.newLineCharacter }; + case 84 /* ExportKeyword */: + return { prefix: " " }; + case 149 /* Parameter */: + return {}; + default: + ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it + return { suffix: this.newLineCharacter }; } - return ts.Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 193 /* ArrowFunction */) { + if (node.kind === 195 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); - this.deleteNode(sourceFile, arrow); + deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` @@ -101688,14 +102503,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); } - if (node.body.kind !== 213 /* Block */) { + if (node.body.kind !== 216 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -101721,7 +102536,7 @@ var ts; if (index !== containingList.length - 1) { // any element except the last one // use next sibling as an anchor - var nextToken = ts.getTokenAtPosition(sourceFile, after.end, /*includeJsDocComment*/ false); + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); if (nextToken && isSeparator(after, nextToken)) { // for list // a, b, c @@ -101826,14 +102641,25 @@ var ts; } }); }; - ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () { + ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - this.deletedNodesInLists.forEach(function (node) { + var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var _loop_10 = function (sourceFile, node) { + if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { + deleteDeclaration.deleteDeclaration(this_1, deletedNodesInLists, sourceFile, node); + } + }; + var this_1 = this; + for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { + var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; + _loop_10(sourceFile, node); + } + deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (node !== ts.last(list)) return; - var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2); + var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !deletedNodesInLists.has(n); }, list.length - 2); if (lastNonDeletedIndex !== -1) { _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) }); } @@ -101846,8 +102672,8 @@ var ts; * so we can only call this once and can't get the non-formatted text separately. */ ChangeTracker.prototype.getChanges = function (validate) { + this.finishDeleteDeclarations(); this.finishClassesWithNodesInsertedAtStart(); - this.finishTrailingCommaAfterDeletingNodesInList(); var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) { var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements; @@ -101876,14 +102702,14 @@ var ts; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); - var _loop_10 = function (i) { + var _loop_11 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_10(i); + _loop_11(i); } var textChanges = normalized.map(function (c) { return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate)); @@ -101944,8 +102770,8 @@ var ts; })(changesToText || (changesToText = {})); function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { - var change = changes[i]; - text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + var _a = changes[i], span = _a.span, newText = _a.newText; + text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); } return text; } @@ -102147,6 +102973,177 @@ var ts; return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } + var deleteDeclaration; + (function (deleteDeclaration_1) { + function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { + switch (node.kind) { + case 149 /* Parameter */: { + var oldFunction = node.parent; + if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { + // Lambdas with exactly one parameter are special because, after removal, there + // must be an empty parameter list (i.e. `()`) and this won't necessarily be the + // case if the parameter is simply removed (e.g. in `x => 1`). + var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, + /*parameters*/ undefined, // TODO: GH#18217 + oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); + // Drop leading and trailing trivia of the new function because we're only going + // to replace the span (vs the full span) of the old function - the old leading + // and trailing trivia will remain. + ts.suppressLeadingAndTrailingTrivia(newFunction); + changes.replaceNode(sourceFile, oldFunction, newFunction); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 247 /* ImportDeclaration */: + deleteNode(changes, sourceFile, node, + // For first import, leave header comment in place + node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); + break; + case 184 /* BindingElement */: + var pattern = node.parent; + var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + if (preserveComma) { + deleteNode(changes, sourceFile, node); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 235 /* VariableDeclaration */: + deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); + break; + case 148 /* TypeParameter */: { + var typeParameters = ts.getEffectiveTypeParameterDeclarations(node.parent); + if (typeParameters.length === 1) { + var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; + var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1); + var nextToken = ts.getTokenAtPosition(sourceFile, end); + ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); + ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); + changes.deleteNodeRange(sourceFile, previousToken, nextToken); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 251 /* ImportSpecifier */: + var namedImports = node.parent; + if (namedImports.elements.length === 1) { + deleteImportBinding(changes, sourceFile, namedImports); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 249 /* NamespaceImport */: + deleteImportBinding(changes, sourceFile, node); + break; + default: + if (ts.isImportClause(node.parent) && node.parent.name === node) { + deleteDefaultImport(changes, sourceFile, node.parent); + } + else if (ts.isCallLikeExpression(node.parent)) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + else { + deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + } + } + } + deleteDeclaration_1.deleteDeclaration = deleteDeclaration; + function deleteDefaultImport(changes, sourceFile, importClause) { + if (!importClause.namedBindings) { + // Delete the whole import + deleteNode(changes, sourceFile, importClause.parent); + } + else { + // import |d,| * as ns from './file' + var start = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26 /* CommaToken */) { + // shift first non-whitespace position after comma to the start position of the node + var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); + changes.deleteRange(sourceFile, { pos: start, end: end }); + } + else { + deleteNode(changes, sourceFile, importClause.name); + } + } + } + function deleteImportBinding(changes, sourceFile, node) { + if (node.parent.name) { + // Delete named imports while preserving the default import + // import d|, * as ns| from './file' + // import d|, { a }| from './file' + var previousToken = ts.Debug.assertDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1)); + changes.deleteRange(sourceFile, { pos: previousToken.getStart(sourceFile), end: node.end }); + } + else { + // Delete the entire import declaration + // |import * as ns from './file'| + // |import { a } from './file'| + var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + deleteNode(changes, sourceFile, importDecl); + } + } + function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { + var parent = node.parent; + if (parent.kind === 272 /* CatchClause */) { + // TODO: There's currently no unused diagnostic for this, could be a suggestion + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + return; + } + if (parent.declarations.length !== 1) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + return; + } + var gp = parent.parent; + switch (gp.kind) { + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: + changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); + break; + case 223 /* ForStatement */: + deleteNode(changes, sourceFile, parent); + break; + case 217 /* VariableStatement */: + deleteNode(changes, sourceFile, gp); + break; + default: + ts.Debug.assertNever(gp); + } + } + })(deleteDeclaration || (deleteDeclaration = {})); + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + // Exported for tests only! (TODO: improve tests to not need this) + function deleteNode(changes, sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + changes.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + textChanges_3.deleteNode = deleteNode; + function deleteNodeInList(changes, deletedNodesInLists, sourceFile, node) { + var containingList = ts.Debug.assertDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile)); + var index = ts.indexOfNode(containingList, node); + ts.Debug.assert(index !== -1); + if (containingList.length === 1) { + deleteNode(changes, sourceFile, node); + return; + } + // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. + // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. + ts.Debug.assert(!deletedNodesInLists.has(node), "Deleting a node twice"); + deletedNodesInLists.add(node); + changes.deleteRange(sourceFile, { + pos: startPositionToDeleteNodeInList(sourceFile, node), + end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), + }); + } })(textChanges = ts.textChanges || (ts.textChanges = {})); })(ts || (ts = {})); /* @internal */ @@ -102202,15 +103199,14 @@ var ts; function createCombinedCodeActions(changes, commands) { return { changes: changes, commands: commands }; } + codefix.createCombinedCodeActions = createCombinedCodeActions; function createFileTextChanges(fileName, textChanges) { return { fileName: fileName, textChanges: textChanges }; } codefix.createFileTextChanges = createFileTextChanges; function codeFixAll(context, errorCodes, use) { var commands = []; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { - return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); - }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); }); return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } codefix.codeFixAll = codeFixAll; @@ -102223,6 +103219,7 @@ var ts; } } } + codefix.eachDiagnostic = eachDiagnostic; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -102273,7 +103270,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, }); function makeChange(changeTracker, sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var decorator = ts.findAncestor(token, ts.isDecorator); ts.Debug.assert(!!decorator, "Expected position to be owned by a decorator."); var replacement = ts.createCall(decorator.expression, /*typeArguments*/ undefined, /*argumentsArray*/ undefined); @@ -102305,7 +103302,7 @@ var ts; }); }, }); function getDeclaration(file, pos) { - var name = ts.getTokenAtPosition(file, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(file, pos); // For an arrow function with no name, 'name' lands on the first parameter. return ts.tryCast(ts.isParameter(name.parent) ? name.parent.parent : name.parent, parameterShouldGetTypeFromJSDoc); } @@ -102352,24 +103349,24 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 232 /* VariableDeclaration */ || + node.kind === 235 /* VariableDeclaration */ || node.kind === 151 /* PropertySignature */ || node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 162 /* TypeReference */: return transformJSDocTypeReference(node); @@ -102393,7 +103390,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 288 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -102459,8 +103456,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, err) { return doChange(changes, err.file, err.start, context.program.getTypeChecker()); }); }, }); function doChange(changes, sourceFile, position, checker) { - var deletedNodes = []; - var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false)); + var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; @@ -102469,20 +103465,20 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); + changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { ts.copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 - deleteNode(precedingNode); + changes.delete(sourceFile, precedingNode); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + changes.delete(sourceFile, ctorDeclaration); } break; } @@ -102492,22 +103488,6 @@ var ts; ts.copyComments(ctorDeclaration, newClassDeclaration, sourceFile); // Because the preceding node could be touched, we need to insert nodes before delete nodes. changes.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration); - for (var _i = 0, deletedNodes_1 = deletedNodes; _i < deletedNodes_1.length; _i++) { - var _a = deletedNodes_1[_i], node = _a.node, inList = _a.inList; - if (inList) { - changes.deleteNodeInList(sourceFile, node); - } - else { - changes.deleteNode(sourceFile, node); - } - } - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - // If parent node has already been deleted, do nothing - if (!deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n.node); })) { - deletedNodes.push({ node: node, inList: inList }); - } - } function createClassElementsFromSymbol(symbol) { var memberElements = []; // all instance members are stored in the "member" array of symbol @@ -102545,15 +103525,15 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 216 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 219 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); + changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -102561,12 +103541,12 @@ var ts; ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 193 /* ArrowFunction */: { + case 195 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 213 /* Block */) { + if (arrowFunctionBody.kind === 216 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -102594,7 +103574,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { @@ -102658,10 +103638,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -102714,20 +103694,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 187 /* CallExpression */: { + case 189 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -102769,8 +103749,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: { + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -102793,7 +103773,7 @@ var ts; if (ts.isExportsOrModuleExportsOrAlias(sourceFile, left)) { if (ts.isExportsOrModuleExportsOrAlias(sourceFile, right)) { // `const alias = module.exports;` or `module.exports = alias;` can be removed. - changes.deleteNode(sourceFile, assignment.parent); + changes.delete(sourceFile, assignment.parent); } else { var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right) @@ -102824,10 +103804,10 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 271 /* ShorthandPropertyAssignment */: - case 272 /* SpreadAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 275 /* SpreadAssignment */: return undefined; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); @@ -102884,7 +103864,7 @@ var ts; changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); if (semi) - changes.deleteNode(sourceFile, semi, { useNonAdjustedEndPosition: true }); + changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` @@ -102895,7 +103875,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -102903,10 +103883,10 @@ var ts; } } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -102924,7 +103904,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: { + case 182 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -102935,7 +103915,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 181 /* ArrayBindingPattern */: { + case 183 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -103018,11 +103998,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node; - case 182 /* BindingElement */: + case 184 /* BindingElement */: return parent.propertyName !== node; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -103081,7 +104061,7 @@ var ts; }); }, }); function getQualifiedName(sourceFile, pos) { - var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ true), ts.isQualifiedName); + var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), ts.isQualifiedName); ts.Debug.assert(!!qualifiedName, "Expected position to be owned by a qualified name."); return ts.isIdentifier(qualifiedName.left) ? qualifiedName : undefined; } @@ -103126,7 +104106,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -103154,7 +104134,7 @@ var ts; } } function getHeritageClauseSymbolTable(classDeclaration, checker) { - var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var heritageClauseNode = ts.getEffectiveBaseTypeNode(classDeclaration); if (!heritageClauseNode) return ts.createSymbolTable(); var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); @@ -103168,42 +104148,109 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var ChangeTracker = ts.textChanges.ChangeTracker; + codefix.importFixId = "fixMissingImport"; + var errorCodes = [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.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, + ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, + ]; codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics.Cannot_find_name_0.code, - ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.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, - ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, - ], - getCodeActions: function (context) { return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(context) - : getActionsForNonUMDImport(context); }, - // TODO: GH#20315 - fixIds: [], - getAllCodeActions: ts.notImplemented, + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span; + var info = getFixesInfo(context, errorCode, span.start); + if (!info) + return undefined; + var fixes = info.fixes, symbolName = info.symbolName; + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference); }); + }, + fixIds: [codefix.importFixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, preferences = context.preferences; + // Namespace fixes don't conflict, so just build a list. + var addToNamespace = []; + // Keys are import clause node IDs. + var addToExisting = ts.createMap(); + // Keys are module specifiers. + var newImports = ts.createMap(); + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getFixesInfo(context, diag.code, diag.start); + if (!info || !info.fixes.length) + return; + var fixes = info.fixes, symbolName = info.symbolName; + var fix = ts.first(fixes); + switch (fix.kind) { + case 0 /* UseNamespace */: + addToNamespace.push(fix); + break; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + var key = String(ts.getNodeId(importClause)); + var entry = addToExisting.get(key); + if (!entry) { + addToExisting.set(key, entry = { importClause: importClause, defaultImport: undefined, namedImports: [] }); + } + if (importKind === 0 /* Named */) { + ts.pushIfUnique(entry.namedImports, symbolName); + } + else { + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + } + break; + } + case 2 /* AddNew */: { + var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind; + var entry = newImports.get(moduleSpecifier); + if (!entry) { + newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined }); + } + switch (importKind) { + case 1 /* Default */: + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + break; + case 0 /* Named */: + ts.pushIfUnique(entry.namedImports, symbolName); + break; + case 3 /* Equals */: + case 2 /* Namespace */: + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; + break; + } + break; + } + default: + ts.Debug.assertNever(fix); + } + }); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) { + var fix = addToNamespace_1[_i]; + addNamespaceQualifier(changes, sourceFile, fix); + } + addToExisting.forEach(function (_a) { + var importClause = _a.importClause, defaultImport = _a.defaultImport, namedImports = _a.namedImports; + doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports); + }); + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + newImports.forEach(function (imports, moduleSpecifier) { + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports); + }); + })); + }, }); - function createCodeAction(descriptionDiagnostic, diagnosticArgs, changes) { - // TODO: GH#20315 - return codefix.createCodeFixActionNoFixId("import", changes, [descriptionDiagnostic].concat(diagnosticArgs)); - } - function convertToImportCodeFixContext(context, symbolToken, symbolName) { - var program = context.program; - var checker = program.getTypeChecker(); - return { - host: context.host, - formatContext: context.formatContext, - sourceFile: context.sourceFile, - program: program, - checker: checker, - compilerOptions: program.getCompilerOptions(), - getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), - symbolName: symbolName, - symbolToken: symbolToken, - preferences: context.preferences, - }; - } + // Sorted with the preferred fix coming first. + var ImportFixKind; + (function (ImportFixKind) { + ImportFixKind[ImportFixKind["UseNamespace"] = 0] = "UseNamespace"; + ImportFixKind[ImportFixKind["AddToExisting"] = 1] = "AddToExisting"; + ImportFixKind[ImportFixKind["AddNew"] = 2] = "AddNew"; + })(ImportFixKind || (ImportFixKind = {})); var ImportKind; (function (ImportKind) { ImportKind[ImportKind["Named"] = 0] = "Named"; @@ -103211,13 +104258,13 @@ var ts; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; })(ImportKind || (ImportKind = {})); - function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, symbolToken, preferences) { + function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, allSourceFiles, formatContext, symbolToken, preferences) { var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, checker, allSourceFiles); ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, exportInfos, host, preferences)).moduleSpecifier; - var ctx = { host: host, program: program, checker: checker, compilerOptions: compilerOptions, sourceFile: sourceFile, formatContext: formatContext, symbolName: symbolName, getCanonicalFileName: getCanonicalFileName, symbolToken: symbolToken, preferences: preferences }; - return { moduleSpecifier: moduleSpecifier, codeAction: ts.first(getCodeActionsForImport(exportInfos, ctx)) }; + var fix = ts.first(getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences)); + return { moduleSpecifier: moduleSpecifier, codeAction: codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences)) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, checker, allSourceFiles) { @@ -103237,23 +104284,16 @@ var ts; }); return result; } - function getCodeActionsForImport(exportInfos, context) { - var result = []; - getCodeActionsForImport_separateExistingAndNew(exportInfos, context, result, result); - return result; - } - function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, context.checker, context.sourceFile); }); - ts.append(useExisting, tryUseExistingNamespaceImport(existingImports, context, context.symbolToken, context.checker)); - var addToExisting = tryAddToExistingImport(existingImports, context); - if (addToExisting) { - useExisting.push(addToExisting); - } - else { // Don't bother providing an action to add a new import if we can add to an existing one. - getCodeActionsForAddImport(exportInfos, context, existingImports, addNew); - } - } - function tryUseExistingNamespaceImport(existingImports, context, symbolToken, checker) { + function getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences) { + var checker = program.getTypeChecker(); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var useNamespace = tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker); + var addToExisting = tryAddToExistingImport(existingImports); + // Don't bother providing an action to add a new import if we can add to an existing one. + var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); + return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + } + function tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -103270,29 +104310,31 @@ var ts; var declaration = _a.declaration; var namespace = getNamespaceImportName(declaration); if (namespace) { - var moduleSymbol = namespace && checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); - if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { - return getCodeActionForUseExistingNamespaceImport(namespace.text, context, symbolToken); + var moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { + return { kind: 0 /* UseNamespace */, namespacePrefix: namespace.text, symbolToken: symbolToken }; } } }); } - function tryAddToExistingImport(existingImports, context) { + function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 244 /* ImportDeclaration */ && declaration.importClause) { - var changes = tryUpdateExistingImport(context, declaration.importClause, importKind); - if (changes) { - var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); - return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [context.symbolName, moduleSpecifierWithoutQuotes], changes); - } - } + if (declaration.kind !== 247 /* ImportDeclaration */) + return undefined; + var importClause = declaration.importClause; + if (!importClause) + return undefined; + var name = importClause.name, namedBindings = importClause.namedBindings; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + ? { kind: 1 /* AddToExisting */, importClause: importClause, importKind: importKind } + : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 244 /* ImportDeclaration */) { + if (declaration.kind === 247 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -103303,141 +104345,61 @@ var ts; var imports = _b.imports; return ts.mapDefined(imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } - function getCodeActionForNewImport(context, _a) { - var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; - var sourceFile = context.sourceFile, symbolName = context.symbolName, preferences = context.preferences; - var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); - var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifierWithoutQuotes, ts.getQuotePreference(sourceFile, preferences)); - var importDecl = importKind !== 3 /* Equals */ - ? ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClauseOfKind(importKind, symbolName), quotedModuleSpecifier) - : ts.createImportEqualsDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createIdentifier(symbolName), ts.createExternalModuleReference(quotedModuleSpecifier)); - var changes = ChangeTracker.with(context, function (t) { return ts.insertImport(t, sourceFile, importDecl); }); - // 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 separating code and import statements. - return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); - } - function createImportClauseOfKind(kind, symbolName) { - var id = ts.createIdentifier(symbolName); - switch (kind) { - case 1 /* Default */: - return ts.createImportClause(id, /*namedBindings*/ undefined); - case 2 /* Namespace */: - return ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(id)); - case 0 /* Named */: - return ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, id)])); - default: - ts.Debug.assertNever(kind); - } - } function getNewImportInfos(program, sourceFile, moduleSymbols, host, preferences) { var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var modulePathsGroups = ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences); - return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); + return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ kind: 2 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); }); // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together return ts.flatten(choicesForEachExportingModule.sort(function (a, b) { return ts.first(a).moduleSpecifier.length - ts.first(b).moduleSpecifier.length; })); } - function getCodeActionsForAddImport(exportInfos, ctx, existingImports, addNew) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); - var newImportInfos = existingDeclaration - ? [existingDeclaration] - : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.host, ctx.preferences); - for (var _i = 0, newImportInfos_1 = newImportInfos; _i < newImportInfos_1.length; _i++) { - var info = newImportInfos_1[_i]; - addNew.push(getCodeActionForNewImport(ctx, info)); - } + return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 244 /* ImportDeclaration */ + var expression = declaration.kind === 247 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; - return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; - } - function tryUpdateExistingImport(context, importClause, importKind) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - var name = importClause.name; - var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 - switch (importKind) { - case 1 /* Default */: - return name ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(ts.createIdentifier(symbolName), namedBindings)); - }); - case 0 /* Named */: { - var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - if (namedBindings && namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length !== 0) { - // There are already named imports; add another. - return ChangeTracker.with(context, function (t) { return t.insertNodeInListAfter(sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier_1); }); - } - if (!namedBindings || namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length === 0) { - return ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); - }); - } - return undefined; - } - case 2 /* Namespace */: - return namedBindings ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamespaceImport(ts.createIdentifier(symbolName)))); - }); - case 3 /* Equals */: - return undefined; - default: - ts.Debug.assertNever(importKind); - } + return expression && ts.isStringLiteral(expression) ? { kind: 2 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix, context, symbolToken) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - var changes = ChangeTracker.with(context, function (tracker) { - return tracker.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); - }); - return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); + function getFixesInfo(context, errorCode, pos) { + var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos); + var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getFixesInfoForUMDImport(context, symbolToken) + : getFixesInfoForNonUMDImport(context, symbolToken); + return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } - function getActionsForUMDImport(context) { - var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); - var checker = context.program.getTypeChecker(); - var umdSymbol; - if (ts.isIdentifier(token)) { - // try the identifier to see if it is the umd symbol - umdSymbol = checker.getSymbolAtLocation(token); - } - if (!ts.isUMDExportSymbol(umdSymbol)) { - // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. - var parent = token.parent; - var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(parent); - if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 260 /* JsxOpeningFragment */) { - umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); - } - } - if (ts.isUMDExportSymbol(umdSymbol)) { - var symbol = checker.getAliasedSymbol(umdSymbol); - if (symbol) { - return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(context.program.getCompilerOptions()) }], convertToImportCodeFixContext(context, token, umdSymbol.name)); - } - } - return undefined; + function getFixesInfoForUMDImport(_a, token) { + var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; + var checker = program.getTypeChecker(); + var umdSymbol = getUmdSymbol(token, checker); + if (!umdSymbol) + return undefined; + var symbol = checker.getAliasedSymbol(umdSymbol); + var symbolName = umdSymbol.name; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()) }]; + var fixes = getFixForImport(exportInfos, symbolName, token, program, sourceFile, host, preferences); + return { fixes: fixes, symbolName: symbolName }; + } + function getUmdSymbol(token, checker) { + // try the identifier to see if it is the umd symbol + var umdSymbol = ts.isIdentifier(token) ? checker.getSymbolAtLocation(token) : undefined; + if (ts.isUMDExportSymbol(umdSymbol)) + return umdSymbol; + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + var parent = token.parent; + return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67216319 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + : undefined; } function getUmdImportKind(compilerOptions) { // Import a synthetic `default` if enabled. @@ -103461,11 +104423,10 @@ var ts; return ts.Debug.assertNever(moduleKind); } } - function getActionsForNonUMDImport(context) { + function getFixesInfoForNonUMDImport(_a, symbolToken) { + var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. - var sourceFile = context.sourceFile, span = context.span, program = context.program, cancellationToken = context.cancellationToken; var checker = program.getTypeChecker(); - var symbolToken = ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false); // If we're at ``, we must check if `Foo` is already in scope, and if so, get an import for `React` instead. var symbolName = ts.isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken @@ -103475,14 +104436,14 @@ var ts; if (!symbolName) return undefined; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default"); - var addToExistingDeclaration = []; - var addNewDeclaration = []; - getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).forEach(function (exportInfos) { - getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); - }); - return addToExistingDeclaration.concat(addNewDeclaration); + ts.Debug.assert(symbolName !== "default" /* Default */); + var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + var _ = _a[0], exportInfos = _a[1]; + return getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences); + })); + return { fixes: fixes, symbolName: symbolName }; } + // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). @@ -103495,35 +104456,121 @@ var ts; // check the default export var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) { - var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); - if ((localSymbol && localSymbol.escapedName === symbolName || - getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target) === symbolName) && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { - addSymbol(moduleSymbol, localSymbol || defaultExport, 1 /* Default */); + var info = getDefaultExportInfo(defaultExport, moduleSymbol, program); + if (info && info.name === symbolName && symbolHasMeaning(info.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultExport, 1 /* Default */); } } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } - function getEscapedNameForExportDefault(symbol) { - return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { - if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.escapedText; - } + }); + return originalSymbolToExportInfos; + } + function getDefaultExportInfo(defaultExport, moduleSymbol, program) { + var checker = program.getTypeChecker(); + var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) + return { symbolForMeaning: localSymbol, name: localSymbol.name }; + var name = getNameForExportDefault(defaultExport); + if (name !== undefined) + return { symbolForMeaning: defaultExport, name: name }; + if (defaultExport.flags & 2097152 /* Alias */) { + var aliased = checker.getAliasedSymbol(defaultExport); + return getDefaultExportInfo(aliased, ts.Debug.assertDefined(aliased.parent), program); + } + else { + var moduleName = moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target); + return moduleName === undefined ? undefined : { symbolForMeaning: defaultExport, name: moduleName }; + } + } + function getNameForExportDefault(symbol) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + if (ts.isExportAssignment(declaration)) { + if (ts.isIdentifier(declaration.expression)) { + return declaration.expression.text; + } + } + else if (ts.isExportSpecifier(declaration)) { + ts.Debug.assert(declaration.name.text === "default" /* Default */); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } + function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) { + var diag; + var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { + diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference); + }); + return codefix.createCodeFixAction("import", changes, diag, codefix.importFixId, ts.Diagnostics.Add_all_missing_imports); + } + function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) { + switch (fix.kind) { + case 0 /* UseNamespace */: + addNamespaceQualifier(changes, sourceFile, fix); + return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + doAddExistingFix(changes, sourceFile, importClause, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(importClause.parent.moduleSpecifier.getText()); + return [ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; + } + case 2 /* AddNew */: { + var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier; + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === 1 /* Default */ ? { defaultImport: symbolName, namedImports: ts.emptyArray, namespaceLikeImport: undefined } + : importKind === 0 /* Named */ ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined } + : { defaultImport: undefined, namedImports: ts.emptyArray, namespaceLikeImport: { importKind: importKind, name: symbolName } }); + return [ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; + } + default: + return ts.Debug.assertNever(fix); + } + } + function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { + if (defaultImport) { + ts.Debug.assert(!clause.name); + changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); + } + if (namedImports.length) { + var specifiers = namedImports.map(function (name) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); }); + if (clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements.length) { + for (var _i = 0, specifiers_1 = specifiers; _i < specifiers_1.length; _i++) { + var spec = specifiers_1[_i]; + changes.insertNodeInListAfter(sourceFile, ts.last(ts.cast(clause.namedBindings, ts.isNamedImports).elements), spec); + } + } + else { + if (specifiers.length) { + var namedImports_1 = ts.createNamedImports(specifiers); + if (clause.namedBindings) { + changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } - else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - return declaration.propertyName && declaration.propertyName.escapedText; + else { + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); } - }); + } } - }); - return originalSymbolToExportInfos; + } + } + function addNamespaceQualifier(changes, sourceFile, _a) { + var namespacePrefix = _a.namespacePrefix, symbolToken = _a.symbolToken; + changes.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); + } + function addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, _a) { + var defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport; + var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); + if (defaultImport !== undefined || namedImports.length) { + ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); + } + if (namespaceLikeImport) { + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ + ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) + : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + } } - function checkSymbolHasMeaning(_a, meaning) { + function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } @@ -103624,7 +104671,7 @@ var ts; // This is the identifier of the misspelled word. eg: // this.speling = 1; // ^^^^^^^ - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); // TODO: GH#15852 + var node = ts.getTokenAtPosition(sourceFile, pos); var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { @@ -103696,46 +104743,99 @@ var ts; var info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, context.preferences); + if (info.kind === InfoKind.enum) { + var token_1 = info.token, parentDeclaration_1 = info.parentDeclaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), token_1, parentDeclaration_1); }); + return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_missing_enum_member_0, token_1.text], fixId, ts.Diagnostics.Add_all_missing_members)]; + } + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); var addMember = inJs ? - ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, token.text, makeStatic)) : - getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, classDeclaration, token, makeStatic); + ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic)) : + getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, parentDeclaration, token, makeStatic); return ts.concatenate(ts.singleElementArray(methodCodeAction), addMember); }, fixIds: [fixId], getAllCodeActions: function (context) { - var seenNames = ts.createMap(); - return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var program = context.program, preferences = context.preferences; - var info = getInfo(diag.file, diag.start, program.getTypeChecker()); - if (!info) - return; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - if (!ts.addToSeen(seenNames, token.text)) { - return; - } - // Always prefer to add a method declaration if possible. - if (call) { - addMethodDeclaration(changes, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, preferences); - } - else { - if (inJs) { - addMissingMemberInJs(changes, classDeclarationSourceFile, classDeclaration, token.text, makeStatic); + var program = context.program, preferences = context.preferences; + var checker = program.getTypeChecker(); + var seen = ts.createMap(); + var classToMembers = new ts.NodeMap(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(diag.file, diag.start, checker); + if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { + return; + } + if (info.kind === InfoKind.enum) { + var token = info.token, parentDeclaration = info.parentDeclaration; + addEnumMemberDeclaration(changes, checker, token, parentDeclaration); } else { - var typeNode = getTypeNode(program.getTypeChecker(), classDeclaration, token); - addPropertyDeclaration(changes, classDeclarationSourceFile, classDeclaration, token.text, typeNode, makeStatic); + var parentDeclaration = info.parentDeclaration, token_2 = info.token; + var infos = classToMembers.getOrUpdate(parentDeclaration, function () { return []; }); + if (!infos.some(function (i) { return i.token.text === token_2.text; })) + infos.push(info); } - } - }); + }); + classToMembers.forEach(function (infos, classDeclaration) { + var superClasses = getAllSuperClasses(classDeclaration, checker); + var _loop_12 = function (info) { + // If some superclass added this property, don't add it again. + if (superClasses.some(function (superClass) { + var superInfos = classToMembers.get(superClass); + return !!superInfos && superInfos.some(function (_a) { + var token = _a.token; + return token.text === info.token.text; + }); + })) + return "continue"; + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + // Always prefer to add a method declaration if possible. + if (call) { + addMethodDeclaration(context, changes, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + } + else { + if (inJs) { + addMissingMemberInJs(changes, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic); + } + else { + var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token); + addPropertyDeclaration(changes, classDeclarationSourceFile, parentDeclaration, token.text, typeNode, makeStatic); + } + } + }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + _loop_12(info); + } + }); + })); }, }); + function getAllSuperClasses(cls, checker) { + var res = []; + while (cls) { + var superElement = ts.getClassExtendsHeritageElement(cls); + var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); + var superDecl = superSymbol && ts.find(superSymbol.declarations, ts.isClassLike); + if (superDecl) { + res.push(superDecl); + } + cls = superDecl; + } + return res; + } + var InfoKind; + (function (InfoKind) { + InfoKind[InfoKind["enum"] = 0] = "enum"; + InfoKind[InfoKind["class"] = 1] = "class"; + })(InfoKind || (InfoKind = {})); function getInfo(tokenSourceFile, tokenPos, checker) { // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ - var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos); if (!ts.isIdentifier(token)) { return undefined; } @@ -103744,14 +104844,21 @@ var ts; return undefined; var leftExpressionType = ts.skipConstraint(checker.getTypeAtLocation(parent.expression)); var symbol = leftExpressionType.symbol; - var classDeclaration = symbol && symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); - if (!classDeclaration) + if (!symbol || !symbol.declarations) return undefined; - var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); - var classDeclarationSourceFile = classDeclaration.getSourceFile(); - var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); - var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { token: token, classDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); + if (classDeclaration) { + var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); + var classDeclarationSourceFile = classDeclaration.getSourceFile(); + var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); + var call = ts.tryCast(parent.parent, ts.isCallExpression); + return { kind: InfoKind.class, token: token, parentDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + } + var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); + if (enumDeclaration) { + return { kind: InfoKind.enum, token: token, parentDeclaration: enumDeclaration }; + } + return undefined; } function getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic); }); @@ -103760,7 +104867,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 205 /* ClassExpression */) { + if (classDeclaration.kind === 207 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -103786,7 +104893,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 200 /* BinaryExpression */) { + if (token.parent.parent.kind === 202 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); // TODO: GH#18217 @@ -103840,11 +104947,11 @@ var ts; return codefix.createCodeFixActionNoFixId(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]); } function getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, token.text], fixId, ts.Diagnostics.Add_all_missing_members); } - function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); + function addMethodDeclaration(context, changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { + var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences); var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); @@ -103853,6 +104960,19 @@ var ts; changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); } } + function addEnumMemberDeclaration(changes, checker, token, enumDeclaration) { + /** + * create initializer only literal enum that has string initializer. + * value of initializer is a string literal that equal to name of enum member. + * numeric enum or empty enum will not create initializer. + */ + var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { + var type = checker.getTypeAtLocation(member); + return !!(type && type.flags & 68 /* StringLike */); + }); + var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); + changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -103886,7 +105006,7 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function getTypesPackageNameToInstall(host, sourceFile, pos, diagCode) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), ts.isStringLiteral).text; + var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) @@ -103927,11 +105047,11 @@ var ts; function getClass(sourceFile, pos) { // Token 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, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.cast(token.parent, ts.isClassLike); } function addMissingMembers(classDeclaration, sourceFile, checker, changeTracker, preferences) { - var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var extendsNode = ts.getEffectiveBaseTypeNode(classDeclaration); var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. @@ -103981,10 +105101,10 @@ var ts; }); function doChange(changes, sourceFile, constructor, superCall) { changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall); - changes.deleteNode(sourceFile, superCall); + changes.delete(sourceFile, superCall); } function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); if (token.kind !== 99 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); @@ -104023,7 +105143,7 @@ var ts; }); }, }); function getNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); return token.parent; } @@ -104059,7 +105179,7 @@ var ts; }); }, }); function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; @@ -104115,7 +105235,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos, diagCode) { - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(node)) return undefined; return { node: node, className: diagCode === didYouMeanStaticMemberCode ? ts.getContainingClass(node).name.text : undefined }; @@ -104149,25 +105269,30 @@ var ts; getCodeActions: function (context) { var errorCode = context.errorCode, sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); - var startToken = ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); - var importDecl = tryGetFullImport(startToken); + var sourceFiles = program.getSourceFiles(); + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var importDecl = tryGetFullImport(token); if (importDecl) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, importDecl); }); return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteFullDestructure(token, t, sourceFile, checker, sourceFiles, /*isFixAll*/ false); + }); if (delDestructure.length) { return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(t, sourceFile, startToken, /*deleted*/ undefined); }); + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(sourceFile, token, t); }); if (delVar.length) { return [codefix.createCodeFixAction(fixName, delVar, ts.Diagnostics.Remove_variable_statement, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var token = getToken(sourceFile, ts.textSpanEnd(context.span)); var result = []; - var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteDeclaration(sourceFile, token, t, checker, sourceFiles, /*isFixAll*/ false); + }); if (deletion.length) { - result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); + var name = ts.isComputedPropertyName(token.parent) ? token.parent : token; + result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, name.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } var prefix = ts.textChanges.ChangeTracker.with(context, function (t) { return tryPrefixDeclaration(t, errorCode, sourceFile, token); }); if (prefix.length) { @@ -104177,32 +105302,28 @@ var ts; }, fixIds: [fixIdPrefix, fixIdDelete], getAllCodeActions: function (context) { - // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors. - var deleted = new ts.NodeSet(); var sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); + var sourceFiles = program.getSourceFiles(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); - var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); + var token = ts.getTokenAtPosition(sourceFile, diag.start); switch (context.fixId) { case fixIdPrefix: if (ts.isIdentifier(token) && canPrefix(token)) { tryPrefixDeclaration(changes, diag.code, sourceFile, token); } break; - case fixIdDelete: - // Ignore if this range was already deleted. - if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) - break; - var importDecl = tryGetFullImport(startToken); + case fixIdDelete: { + var importDecl = tryGetFullImport(token); if (importDecl) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } - else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && - !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); + else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(sourceFile, token, changes)) { + tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, /*isFixAll*/ true); } break; + } default: ts.Debug.fail(JSON.stringify(context.fixId)); } @@ -104210,49 +105331,29 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(startToken) { - return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; + function tryGetFullImport(token) { + return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { - if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) + function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { + if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; - var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; - switch (decl.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(decl, checker, isFixAll)) - break; - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNodeInList(sourceFile, decl); - break; - case 182 /* BindingElement */: - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNode(sourceFile, decl); - break; - default: - return ts.Debug.assertNever(decl); + var decl = token.parent.parent; + if (decl.kind === 149 /* Parameter */) { + tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); + } + else { + changes.delete(sourceFile, decl); } return true; } - function tryDeleteFullVariableStatement(changes, sourceFile, startToken, deletedAncestors) { - var declarationList = ts.tryCast(startToken.parent, ts.isVariableDeclarationList); - if (declarationList && declarationList.getChildren(sourceFile)[0] === startToken) { - if (deletedAncestors) - deletedAncestors.add(declarationList); - changes.deleteNode(sourceFile, declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList); + function tryDeleteFullVariableStatement(sourceFile, token, changes) { + var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { + changes.delete(sourceFile, declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; } - function getToken(sourceFile, pos) { - var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true); - // this handles var ["computed"] = 12; - return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token; - } function tryPrefixDeclaration(changes, errorCode, sourceFile, token) { // Don't offer to prefix a property. if (errorCode !== ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code && ts.isIdentifier(token) && canPrefix(token)) { @@ -104263,209 +105364,61 @@ var ts; switch (token.parent.kind) { case 149 /* Parameter */: return true; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { - tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll); + function tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, isFixAll) { + tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll); if (ts.isIdentifier(token)) deleteAssignments(changes, sourceFile, token, checker); } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 185 /* PropertyAccessExpression */) + if (ref.parent.kind === 187 /* PropertyAccessExpression */) ref = ref.parent; - if (ref.parent.kind === 200 /* BinaryExpression */ && ref.parent.parent.kind === 216 /* ExpressionStatement */) { - changes.deleteNode(sourceFile, ref.parent.parent); + if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + changes.delete(sourceFile, ref.parent.parent); } }); } - function tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { + function tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll) { var parent = token.parent; - switch (parent.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); - break; - case 148 /* TypeParameter */: - var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent); - if (typeParameters.length === 1) { - var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; - var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false); - var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false); - ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); - ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); - changes.deleteNodeRange(sourceFile, previousToken, nextToken); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(parent, checker, isFixAll)) - break; - var oldFunction = parent.parent; - if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { - // Lambdas with exactly one parameter are special because, after removal, there - // must be an empty parameter list (i.e. `()`) and this won't necessarily be the - // case if the parameter is simply removed (e.g. in `x => 1`). - var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, // TODO: GH#18217 - oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); - // Drop leading and trailing trivia of the new function because we're only going - // to replace the span (vs the full span) of the old function - the old leading - // and trailing trivia will remain. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 182 /* BindingElement */: { - var pattern = parent.parent; - var preserveComma = pattern.kind === 181 /* ArrayBindingPattern */ && parent !== ts.last(pattern.elements); - if (preserveComma) { - changes.deleteNode(sourceFile, parent); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - } - // handle case where 'import a = A;' - case 243 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(token, 243 /* ImportEqualsDeclaration */); - changes.deleteNode(sourceFile, importEquals); - break; - case 248 /* ImportSpecifier */: - var namedImports = parent.parent; - if (namedImports.elements.length === 1) { - tryDeleteNamedImportBinding(changes, sourceFile, namedImports); - } - else { - // delete import specifier - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 245 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' - var importClause = parent; - if (!importClause.namedBindings) { // |import d from './file'| - changes.deleteNode(sourceFile, ts.getAncestor(importClause, 244 /* ImportDeclaration */)); - } - else { - // import |d,| * as ns from './file' - var start = importClause.name.getStart(sourceFile); - var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end, /*includeJsDocComment*/ false); - if (nextToken && nextToken.kind === 26 /* CommaToken */) { - // shift first non-whitespace position after comma to the start position of the node - var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); - changes.deleteRange(sourceFile, { pos: start, end: end }); - } - else { - changes.deleteNode(sourceFile, importClause.name); - } - } - break; - case 246 /* NamespaceImport */: - tryDeleteNamedImportBinding(changes, sourceFile, parent); - break; - default: - if (ts.isDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent); - changes.deleteNode(sourceFile, token.parent); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent.parent); - changes.deleteNode(sourceFile, token.parent.parent); - } - break; - } - } - function tryDeleteNamedImportBinding(changes, sourceFile, namedBindings) { - if (namedBindings.parent.name) { - // Delete named imports while preserving the default import - // import d|, * as ns| from './file' - // import d|, { a }| from './file' - var previousToken = ts.getTokenAtPosition(sourceFile, namedBindings.pos - 1, /*includeJsDocComment*/ false); - if (previousToken && previousToken.kind === 26 /* CommaToken */) { - changes.deleteRange(sourceFile, { pos: previousToken.getStart(), end: namedBindings.end }); - } + if (ts.isParameter(parent)) { + tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, isFixAll); } else { - // Delete the entire import declaration - // |import * as ns from './file'| - // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); - changes.deleteNode(sourceFile, importDecl); - } - } - // token.parent is a variableDeclaration - function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { - switch (varDecl.parent.parent.kind) { - case 220 /* ForStatement */: { - var forStatement = varDecl.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(forInitializer); - changes.deleteNode(sourceFile, forInitializer); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } - break; - } - case 222 /* ForOfStatement */: - var forOfStatement = varDecl.parent.parent; - ts.Debug.assert(forOfStatement.initializer.kind === 233 /* VariableDeclarationList */); - var forOfInitializer = forOfStatement.initializer; - if (deletedAncestors) - deletedAncestors.add(forOfInitializer.declarations[0]); - changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral()); - break; - case 221 /* ForInStatement */: - case 230 /* TryStatement */: - break; - default: - var variableStatement = varDecl.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(variableStatement); - changes.deleteNode(sourceFile, variableStatement); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } + changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); + } + } + function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { + if (mayDeleteParameter(p, checker, isFixAll)) { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { case 154 /* MethodDeclaration */: - // Don't remove a parameter if this overrides something + // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: { - // Can't remove a non-last parameter. Can remove a parameter in code-fix-all if future parameters are also unused. + case 237 /* FunctionDeclaration */: + return true; + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: { + // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); @@ -104480,6 +105433,14 @@ var ts; return ts.Debug.failBadSyntaxKind(parent); } } + function deleteUnusedArguments(changes, sourceFile, deletedParameter, sourceFiles, checker) { + ts.FindAllReferences.Core.eachSignatureCall(deletedParameter.parent, sourceFiles, checker, function (call) { + var index = deletedParameter.parent.parameters.indexOf(deletedParameter); + if (call.arguments.length > index) { // Just in case the call didn't provide enough arguments. + changes.delete(sourceFile, call.arguments[index]); + } + }); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104499,12 +105460,12 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -104515,16 +105476,16 @@ var ts; break; } // falls through - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - changes.deleteNode(sourceFile, container); + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + changes.delete(sourceFile, container); break; default: if (ts.isBlock(statement.parent)) { split(sliceAfter(statement.parent.statements, statement), shouldRemove, function (start, end) { return changes.deleteNodeRange(sourceFile, start, end); }); } else { - changes.deleteNode(sourceFile, statement); + changes.delete(sourceFile, statement); } } } @@ -104536,12 +105497,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -104575,7 +105536,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var labeledStatement = ts.cast(token.parent, ts.isLabeledStatement); var pos = token.getStart(sourceFile); var statementPos = labeledStatement.statement.getStart(sourceFile); @@ -104605,7 +105566,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 281 /* JSDocNullableType */) { + if (typeNode.kind === 284 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -104625,7 +105586,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -104634,7 +105595,7 @@ var ts; changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); // TODO: GH#18217 } function getInfo(sourceFile, pos, checker) { - var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), isTypeContainer); + var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), isTypeContainer); var typeNode = decl && decl.type; return typeNode && { typeNode: typeNode, type: checker.getTypeFromTypeNode(typeNode) }; } @@ -104642,22 +105603,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 208 /* AsExpression */: + case 210 /* AsExpression */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 156 /* GetAccessor */: case 160 /* IndexSignature */: - case 177 /* MappedType */: + case 179 /* MappedType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: - case 190 /* TypeAssertionExpression */: - case 232 /* VariableDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 192 /* TypeAssertionExpression */: + case 235 /* VariableDeclaration */: return true; default: return false; @@ -104704,7 +105665,7 @@ var ts; } } function getNodes(sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var containingFunction = ts.getContainingFunction(token); if (!containingFunction) { return; @@ -104714,11 +105675,11 @@ var ts; case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -104888,8 +105849,22 @@ var ts; signatureDeclaration.body = body; return signatureDeclaration; } - function createMethodFromCallExpression(_a, methodName, inJs, makeStatic, preferences) { + function createMethodFromCallExpression(context, _a, methodName, inJs, makeStatic, preferences) { var typeArguments = _a.typeArguments, args = _a.arguments, parent = _a.parent; + var checker = context.program.getTypeChecker(); + var types = ts.map(args, function (arg) { + var type = checker.getTypeAtLocation(arg); + if (type === undefined) { + return undefined; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + type = checker.getBaseTypeOfLiteralType(type); + return checker.typeToTypeNode(type); + }); + var names = ts.map(args, function (arg) { + return ts.isIdentifier(arg) ? arg.text : + ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + }); return ts.createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, @@ -104898,11 +105873,11 @@ var ts; /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); }), - /*parameters*/ createDummyParameters(args.length, /*names*/ undefined, /*minArgumentCount*/ undefined, inJs), + /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), createStubbedMethodBody(preferences)); } codefix.createMethodFromCallExpression = createMethodFromCallExpression; - function createDummyParameters(argCount, names, minArgumentCount, inJs) { + function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; for (var i = 0; i < argCount; i++) { var newParameter = ts.createParameter( @@ -104911,7 +105886,7 @@ var ts; /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -104937,7 +105912,7 @@ var ts; } var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); - var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*inJs*/ false); + var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); var restParameter = ts.createParameter( @@ -105001,18 +105976,19 @@ var ts; if (ts.isSourceFileJavaScript(sourceFile)) { return undefined; // TODO: GH#20113 } - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var declaration; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeenseen*/ ts.returnTrue); }); - return changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getNameOfDeclaration(declaration).getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start, /*includeJsDocComment*/ false), err.code, program, cancellationToken, markSeen); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen); }); }, }); @@ -105094,11 +106070,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return !!declaration.name; } return false; @@ -105158,8 +106134,8 @@ var ts; function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? @@ -105227,21 +106203,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -105249,13 +106225,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -105364,7 +106340,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -105392,7 +106368,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 187 /* CallExpression */) { + if (parent.kind === 189 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -105560,8 +106536,8 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 187 /* CallExpression */ : 188 /* NewExpression */; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -105588,7 +106564,7 @@ var ts; }); function getActionsForInvalidImportLocation(context) { var sourceFile = context.sourceFile; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -105663,7 +106639,7 @@ var ts; }, }); function getPropertyDeclaration(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined; } function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) { @@ -105748,7 +106724,7 @@ var ts; : ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, name, ts.createExternalModuleReference(required))); } function getInfo(sourceFile, pos) { - var parent = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false).parent; + var parent = ts.getTokenAtPosition(sourceFile, pos).parent; if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ true)) throw ts.Debug.failBadSyntaxKind(parent); var decl = ts.cast(parent.parent, ts.isVariableDeclaration); @@ -105781,7 +106757,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos) { - var name = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(name)) return undefined; // bad input var parent = name.parent; @@ -105805,7 +106781,7 @@ var ts; (function (codefix) { var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof"; var fixId = fixIdAddMissingTypeof; - var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code]; + var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { @@ -105820,9 +106796,9 @@ var ts; }); }, }); function getImportTypeNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 179 /* ImportType */); + ts.Debug.assert(token.parent.kind === 181 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -105858,7 +106834,7 @@ var ts; }); } }); function getInfo(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); if (ts.isClassDeclaration(indexSignature.parent)) return undefined; @@ -105887,129 +106863,325 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var generateGetAccessorAndSetAccessor; - (function (generateGetAccessorAndSetAccessor) { - var refactorName = "Convert import"; - var actionNameNamespaceToNamed = "Convert namespace import to named imports"; - var actionNameNamedToNamespace = "Convert named imports to namespace import"; - refactor.registerRefactor(refactorName, { - getAvailableActions: function (context) { - var i = getImportToConvert(context); - if (!i) + var refactorName = "Convert export"; + var actionNameDefaultToNamed = "Convert default export to named export"; + var actionNameNamedToDefault = "Convert named export to default export"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var info = getInfo(context); + if (!info) + return undefined; + var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; + var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + }, + }); + function getInfo(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var exportNode = ts.getParentNodeInSpan(token, file, span); + if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { + return undefined; + } + var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; + var flags = ts.getModifierFlags(exportNode); + var wasDefault = !!(flags & 512 /* Default */); + // If source file already has a default export, don't offer refactor. + if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + return undefined; + } + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: { + var node = exportNode; + return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + case 217 /* VariableStatement */: { + var vs = exportNode; + // Must be `export const x = something;`. + if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { return undefined; - var description = i.kind === 246 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 246 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; - return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; - }, - getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); - return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + var decl = ts.first(vs.declarationList.declarations); + if (!decl.initializer) + return undefined; + ts.Debug.assert(!wasDefault); + return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - }); - // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. - function getImportToConvert(context) { - var file = context.file; - var span = ts.getRefactorContextSpan(context); - var token = ts.getTokenAtPosition(file, span.start, /*includeJsDocComment*/ false); - var importDecl = ts.getParentNodeInSpan(token, file, span); - if (!importDecl || !ts.isImportDeclaration(importDecl)) + default: return undefined; - var importClause = importDecl.importClause; - return importClause && importClause.namedBindings; } - function doChange(sourceFile, program, changes, toConvert) { - var checker = program.getTypeChecker(); - if (toConvert.kind === 246 /* NamespaceImport */) { - doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + function doChange(exportingSourceFile, program, info, changes, cancellationToken) { + changeExport(exportingSourceFile, info, changes, program.getTypeChecker()); + changeImports(program, info, changes, cancellationToken); + } + function changeExport(exportingSourceFile, _a, changes, checker) { + var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; + if (wasDefault) { + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + } + else { + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + break; + case 217 /* VariableStatement */: + // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` + if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { + // We checked in `getInfo` that an initializer exists. + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + break; + } + // falls through + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: + // `export type T = number;` -> `type T = number; export default T;` + changes.deleteModifier(exportingSourceFile, exportKeyword); + changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); + break; + default: + ts.Debug.assertNever(exportNode); + } + } + } + function changeImports(program, _a, changes, cancellationToken) { + var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; + var checker = program.getTypeChecker(); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { + var importingSourceFile = ref.getSourceFile(); + if (wasDefault) { + changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text); } else { - doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + changeNamedToDefaultImport(importingSourceFile, ref, changes); } - } - function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { - var usedAsNamespaceOrDefault = false; - var nodesToReplace = []; - var conflictingNames = ts.createMap(); - ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { - if (!ts.isPropertyAccessExpression(id.parent)) { - usedAsNamespaceOrDefault = true; + }); + } + function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.default` --> `a.foo` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + // `default as foo` --> `foo`, `default as bar` --> `foo as bar` + changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); + break; + } + case 248 /* ImportClause */: { + var clause = parent; + ts.Debug.assert(clause.name === ref); + var spec = makeImportSpecifier(exportName, ref.text); + var namedBindings = clause.namedBindings; + if (!namedBindings) { + // `import foo from "./a";` --> `import { foo } from "./a";` + changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); + } + else if (namedBindings.kind === 249 /* NamespaceImport */) { + // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` + changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); + changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } else { - var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); - var exportName = parent.name.text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { - conflictingNames.set(exportName, true); - } - ts.Debug.assert(parent.expression === id); - nodesToReplace.push(parent); + // `import foo, { bar } from "./a"` --> `import { bar, foo } from "./a";` + changes.delete(importingSourceFile, ref); + changes.insertNodeAtEndOfList(importingSourceFile, namedBindings.elements, spec); } - }); - // We may need to change `mod.x` to `_x` to avoid a name conflict. - var exportNameToImportName = ts.createMap(); - for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { - var propertyAccess = nodesToReplace_1[_i]; - var exportName = propertyAccess.name.text; - var importName = exportNameToImportName.get(exportName); - if (importName === undefined) { - exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); - } - changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); - } - var importSpecifiers = []; - exportNameToImportName.forEach(function (name, propertyName) { - importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); - }); - var importDecl = toConvert.parent.parent; - if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { - // Need to leave the namespace import alone - changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); - } - else { - changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); + break; } + default: + ts.Debug.failBadSyntaxKind(parent); } - function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { - var importDecl = toConvert.parent.parent; - var moduleSpecifier = importDecl.moduleSpecifier; - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; - var namespaceNameConflicts = toConvert.elements.some(function (element) { - return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { - return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); - }) || false; - }); - var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; - var neededNamedImports = []; - var _loop_11 = function (element) { - var propertyName = (element.propertyName || element.name).text; - ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { - var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); - if (ts.isShorthandPropertyAssignment(id.parent)) { - changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); - } - else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { - if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { - neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); - } + } + function changeNamedToDefaultImport(importingSourceFile, ref, changes) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.foo` --> `a.default` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + if (spec.kind === 251 /* ImportSpecifier */) { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(spec.name.text); + if (spec.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, spec.parent, defaultImport); } else { - changes.replaceNode(sourceFile, id, access); + changes.delete(importingSourceFile, spec); + changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); } - }); - }; - for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { - var element = _a[_i]; - _loop_11(element); + } + else { + // `export { foo } from "./a";` --> `export { default as foo } from "./a";` + // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` + // `export { foo as default } from "./a";` --> `export { default } from "./a";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + } + break; + } + default: + ts.Debug.failBadSyntaxKind(parent); + } + } + function makeImportSpecifier(propertyName, name) { + return ts.createImportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + function makeExportSpecifier(propertyName, name) { + return ts.createExportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var refactorName = "Convert import"; + var actionNameNamespaceToNamed = "Convert namespace import to named imports"; + var actionNameNamedToNamespace = "Convert named imports to namespace import"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var i = getImportToConvert(context); + if (!i) + return undefined; + var description = i.kind === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 249 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + }); + // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. + function getImportToConvert(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var importDecl = ts.getParentNodeInSpan(token, file, span); + if (!importDecl || !ts.isImportDeclaration(importDecl)) + return undefined; + var importClause = importDecl.importClause; + return importClause && importClause.namedBindings; + } + function doChange(sourceFile, program, changes, toConvert) { + var checker = program.getTypeChecker(); + if (toConvert.kind === 249 /* NamespaceImport */) { + doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + else { + doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + } + } + function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { + var usedAsNamespaceOrDefault = false; + var nodesToReplace = []; + var conflictingNames = ts.createMap(); + ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { + if (!ts.isPropertyAccessExpression(id.parent)) { + usedAsNamespaceOrDefault = true; } - changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); - if (neededNamedImports.length) { - changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + else { + var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); + var exportName = parent.name.text; + if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + conflictingNames.set(exportName, true); + } + ts.Debug.assert(parent.expression === id); + nodesToReplace.push(parent); } + }); + // We may need to change `mod.x` to `_x` to avoid a name conflict. + var exportNameToImportName = ts.createMap(); + for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { + var propertyAccess = nodesToReplace_1[_i]; + var exportName = propertyAccess.name.text; + var importName = exportNameToImportName.get(exportName); + if (importName === undefined) { + exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); + } + changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); + } + var importSpecifiers = []; + exportNameToImportName.forEach(function (name, propertyName) { + importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); + }); + var importDecl = toConvert.parent.parent; + if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { + // Need to leave the namespace import alone + changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); } - function updateImport(old, defaultImportName, elements) { - return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + else { + changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); } - })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + } + function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { + var importDecl = toConvert.parent.parent; + var moduleSpecifier = importDecl.moduleSpecifier; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; + var namespaceNameConflicts = toConvert.elements.some(function (element) { + return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + }) || false; + }); + var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; + var neededNamedImports = []; + var _loop_13 = function (element) { + var propertyName = (element.propertyName || element.name).text; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); + if (ts.isShorthandPropertyAssignment(id.parent)) { + changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); + } + else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { + if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { + neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); + } + } + else { + changes.replaceNode(sourceFile, id, access); + } + }); + }; + for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { + var element = _a[_i]; + _loop_13(element); + } + changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); + if (neededNamedImports.length) { + changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + } + } + function updateImport(old, defaultImportName, elements) { + return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); /* @internal */ @@ -106167,7 +107339,7 @@ var ts; } // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start), sourceFile, span); // Do the same for the ending position var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; @@ -106320,7 +107492,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 235 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -106332,13 +107504,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 97 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 187 /* CallExpression */) { + if (node.parent.kind === 189 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -106353,8 +107525,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -106366,20 +107538,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 213 /* Block */: - if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { + case 216 /* Block */: + if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -106391,11 +107563,11 @@ var ts; break; } switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -106403,8 +107575,8 @@ var ts; seenLabels.pop(); break; } - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: { var label = node.label; if (label) { @@ -106414,20 +107586,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -106492,7 +107664,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 274 /* SourceFile */) { + if (current.kind === 277 /* SourceFile */) { return scopes; } } @@ -106584,12 +107756,12 @@ var ts; switch (scope.kind) { case 155 /* Constructor */: return "constructor"; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return "arrow function"; case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); @@ -106602,12 +107774,12 @@ var ts; } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 235 /* ClassDeclaration */ + return scope.kind === 238 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 240 /* ModuleBlock */ + return scope.kind === 243 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -106886,7 +108058,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 216 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 219 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.createVariableStatement( @@ -106905,9 +108077,9 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 216 /* ExpressionStatement */) { + if (node.parent.kind === 219 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. - changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); + changeTracker.delete(context.file, node.parent); } else { var localReference = ts.createIdentifier(localNameText); @@ -106992,7 +108164,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -107170,7 +108342,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 234 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -107233,7 +108405,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_12 = function (i) { + var _loop_14 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -107273,7 +108445,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_12(i); + _loop_14(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -107486,30 +108658,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 273 /* EnumMember */: + case 276 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return parent.kind !== 244 /* ImportDeclaration */ && - parent.kind !== 248 /* ImportSpecifier */; - case 204 /* SpreadElement */: - case 180 /* ObjectBindingPattern */: - case 182 /* BindingElement */: + return parent.kind !== 247 /* ImportDeclaration */ && + parent.kind !== 251 /* ImportSpecifier */; + case 206 /* SpreadElement */: + case 182 /* ObjectBindingPattern */: + case 184 /* BindingElement */: return false; case 71 /* Identifier */: - return parent.kind !== 182 /* BindingElement */ && - parent.kind !== 248 /* ImportSpecifier */ && - parent.kind !== 252 /* ExportSpecifier */; + return parent.kind !== 184 /* BindingElement */ && + parent.kind !== 251 /* ImportSpecifier */ && + parent.kind !== 255 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 213 /* Block */: - case 274 /* SourceFile */: - case 240 /* ModuleBlock */: - case 266 /* CaseClause */: + case 216 /* Block */: + case 277 /* SourceFile */: + case 243 /* ModuleBlock */: + case 269 /* CaseClause */: return true; default: return false; @@ -107529,8 +108701,7 @@ var ts; var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { - var file = context.file; - if (!getConvertibleFieldAtPosition(context, file)) + if (!getConvertibleFieldAtPosition(context)) return undefined; return [{ name: actionName, @@ -107545,7 +108716,7 @@ var ts; } function getEditsForAction(context, _actionName) { var file = context.file; - var fieldInfo = getConvertibleFieldAtPosition(context, file); + var fieldInfo = getConvertibleFieldAtPosition(context); if (!fieldInfo) return undefined; var isJS = ts.isSourceFileJavaScript(file); @@ -107606,13 +108777,13 @@ var ts; function startsWithUnderscore(name) { return name.charCodeAt(0) === 95 /* _ */; } - function getConvertibleFieldAtPosition(context, file) { - var startPosition = context.startPosition, endPosition = context.endPosition; - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + function getConvertibleFieldAtPosition(context) { + var file = context.file, startPosition = context.startPosition, endPosition = context.endPosition; + var node = ts.getTokenAtPosition(file, startPosition); var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; - if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) // TODO: GH#18217 + if (!declaration || !ts.nodeOverlapsWithStartEnd(declaration.name, file, startPosition, endPosition) // TODO: GH#18217 || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; @@ -107767,11 +108938,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return true; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -107824,10 +108995,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_13 = function (sourceFile) { + var _loop_15 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_14 = function (statement) { + var _loop_16 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -107849,22 +109020,22 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_14(statement); + _loop_16(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_13(sourceFile); + _loop_15(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + case 247 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -107895,20 +109066,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -107978,15 +109149,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -107999,23 +109170,23 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } else { if (name && defaultUnused) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } if (namedBindings) { if (namedBindingsUnused) { - changes.deleteNode(sourceFile, namedBindings); + changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 247 /* NamedImports */) { + else if (namedBindings.kind === 250 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) - changes.deleteNodeInList(sourceFile, element); + changes.delete(sourceFile, element); } } } @@ -108026,20 +109197,20 @@ var ts; switch (name.kind) { case 71 /* Identifier */: if (isUnused(name)) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { - changes.deleteNode(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); + changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } else { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (ts.isIdentifier(element.name) && isUnused(element.name)) { - changes.deleteNode(sourceFile, element.name); + changes.delete(sourceFile, element.name); } } } @@ -108136,13 +109307,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: return true; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -108154,7 +109325,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -108164,9 +109335,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -108175,7 +109346,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -108187,9 +109358,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return name; - case 180 /* ObjectBindingPattern */: { + case 182 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.createObjectBindingPattern(newElements) : undefined; @@ -108246,13 +109417,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -108260,17 +109431,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return cb(statement); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -108279,7 +109450,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -108311,23 +109482,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -108338,18 +109509,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -108424,7 +109595,7 @@ var ts; return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(file, startPosition); var func = ts.getContainingFunction(node); if (!func || !ts.isArrowFunction(func) || (!ts.rangeContainsRange(func, node) || ts.rangeContainsRange(func.body, node))) return undefined; @@ -108530,7 +109701,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 299 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 302 /* LastJSDocNode */; }); return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -108600,7 +109771,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(300 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(303 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -108657,7 +109828,7 @@ var ts; return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { - return ts.emptyArray; + return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -108911,7 +110082,7 @@ var ts; }; SourceFileObject.prototype.computeNamedDeclarations = function () { var result = ts.createMultiMap(); - ts.forEachChild(this, visit); + this.forEachChild(visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); @@ -108927,14 +110098,14 @@ var ts; return declarations; } function getDeclarationName(declaration) { - var name = ts.getNameOfDeclaration(declaration); + var name = ts.getNonAssignedNameOfDeclaration(declaration); return name && (ts.isComputedPropertyName(name) && ts.isPropertyAccessExpression(name.expression) ? name.expression.name.text : ts.isPropertyName(name) ? ts.getNameFromPropertyName(name) : undefined); } function visit(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: var functionDeclaration = node; @@ -108956,17 +110127,17 @@ var ts; } ts.forEachChild(node, visit); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 166 /* TypeLiteral */: @@ -108979,8 +110150,8 @@ var ts; break; } // falls through - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: { + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -108991,31 +110162,31 @@ var ts; } } // falls through - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: addDeclaration(node); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addDeclaration(importClause); + addDeclaration(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -109024,7 +110195,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -109392,7 +110563,7 @@ var ts; readFile: function (fileName) { // stub missing host functionality var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); if (entry) { return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot); } @@ -109442,7 +110613,7 @@ var ts; return; function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : (!!host.fileExists && host.fileExists(fileName)); @@ -109457,11 +110628,11 @@ var ts; return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); } function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { - ts.Debug.assert(hostCache !== undefined); + ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined // to the program to allow reporting of errors for missing files. - var hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path); + var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path); if (!hostFileInformation) { return undefined; } @@ -109557,17 +110728,17 @@ var ts; return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { - if (options === void 0) { options = ts.defaultPreferences; } + if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 - getCanonicalFileName, preferences, cancellationToken); + preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -109592,10 +110763,10 @@ var ts; return undefined; } // falls through - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_1 = typeChecker.getTypeAtLocation(node); @@ -109640,7 +110811,8 @@ var ts; return file.getLineAndCharacterOfPosition(position); } // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; function scanForSourcemapURL(fileName) { var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); @@ -109649,11 +110821,15 @@ var ts; } var starts = ts.getLineStarts(mappedFile); for (var index = starts.length - 1; index >= 0; index--) { - sourceMapCommentRegExp.lastIndex = starts[index]; - var comment = sourceMapCommentRegExp.exec(mappedFile.text); + var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); + var comment = sourceMapCommentRegExp.exec(lineText); if (comment) { return comment[1]; } + // If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!lineText.match(whitespaceOrMapCommentRegExp)) { + break; + } } } function convertDocumentToSourceMapper(file, contents, mapFileName) { @@ -109807,18 +110983,32 @@ var ts; return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; + return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); }); + } + else { + var refs = getReferences(node, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + return refs && refs.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + return ({ fileName: fileName, textSpan: textSpan }); + }); + } } function getReferencesAtPosition(fileName, position) { - return getReferences(fileName, position); + synchronizeHostData(); + return getReferences(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position); } - function getReferences(fileName, position, options) { + function getReferences(node, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. var sourceFiles = options && options.isForRename ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); - return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -109842,10 +111032,11 @@ var ts; /** * This is a semantic operation. */ - function getSignatureHelpItems(fileName, position) { + function getSignatureHelpItems(fileName, position, _a) { + var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); } /// Syntactic features function getNonBoundSourceFile(fileName) { @@ -109859,7 +111050,7 @@ var ts; return undefined; } switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: @@ -109867,7 +111058,7 @@ var ts; case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span @@ -109884,7 +111075,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 === 239 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 242 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -109954,7 +111145,7 @@ var ts; braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var token = ts.getTouchingToken(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, position); var matchKind = token.getStart(sourceFile) === position ? braceMatching.get(token.kind.toString()) : undefined; var match = matchKind && ts.findChildOfKind(token.parent, matchKind, sourceFile); // We want to order the braces when we return the result. @@ -109995,7 +111186,7 @@ var ts; return []; } function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = ts.createTextSpanFromBounds(start, end); @@ -110006,7 +111197,7 @@ var ts; }); } function getCombinedCodeFix(scope, fixId, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110014,7 +111205,7 @@ var ts; return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } function organizeImports(scope, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110022,7 +111213,7 @@ var ts; return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { @@ -110085,8 +111276,8 @@ var ts; } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); - return range && ts.createTextSpanFromRange(range); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); + return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -110214,8 +111405,7 @@ var ts; } function getRenameInfo(fileName, position) { synchronizeHostData(); - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - return ts.Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); + return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position); } function getRefactorContext(file, positionOrRange, preferences, formatOptions) { var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1]; @@ -110231,13 +111421,13 @@ var ts; }; } function getApplicableRefactors(fileName, positionOrRange, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getApplicableRefactors(getRefactorContext(file, positionOrRange, preferences)); } function getEditsForRefactor(fileName, formatOptions, positionOrRange, refactorName, actionName, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); @@ -110331,7 +111521,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 254 /* ExternalModuleReference */ || + node.parent.kind === 257 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -110349,7 +111539,7 @@ var ts; // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && + (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -110388,7 +111578,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 186 /* ElementAccessExpression */ && + node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -110419,7 +111609,7 @@ var ts; if (sourceFile.isDeclarationFile) { return undefined; } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { // Get previous token if the token is returned starts on new line @@ -110468,114 +111658,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return spanInVariableDeclaration(node); case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanInBlock(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInBlock(node.block); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 217 /* IfStatement */: + case 220 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return spanInForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 182 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 184 /* BindingElement */: // span on complete node return textSpan(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: // span in statement return spanInNode(node.statement); case 150 /* Decorator */: return spanInNodeArray(parent.decorators); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -110618,13 +111808,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 === 71 /* Identifier */ || - node.kind === 204 /* SpreadElement */ || - node.kind === 270 /* PropertyAssignment */ || - node.kind === 271 /* ShorthandPropertyAssignment */) && + node.kind === 206 /* SpreadElement */ || + node.kind === 273 /* PropertyAssignment */ || + node.kind === 274 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 200 /* BinaryExpression */) { + if (node.kind === 202 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -110646,22 +111836,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: return textSpan(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (node.parent.operatorToken.kind === 26 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -110670,20 +111860,20 @@ var ts; } } switch (node.parent.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; @@ -110692,7 +111882,7 @@ var ts; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -110722,7 +111912,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -110734,7 +111924,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 222 /* ForOfStatement */) { + parent.parent.kind === 225 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -110775,7 +111965,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -110798,26 +111988,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 221 /* ForInStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 224 /* 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 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 236 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -110842,21 +112032,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 182 /* BindingElement */) { + if (bindingPattern.parent.kind === 184 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 181 /* ArrayBindingPattern */ && node.kind !== 180 /* ObjectBindingPattern */); - var elements = node.kind === 183 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); + var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -110864,18 +112054,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 === 200 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 202 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -110883,25 +112073,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 238 /* EnumDeclaration */: - case 235 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -110909,7 +112099,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); @@ -110925,7 +112115,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 181 /* ArrayBindingPattern */: + case 183 /* 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); @@ -110940,12 +112130,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 187 /* CallExpression */ || - node.parent.kind === 188 /* NewExpression */) { + if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 189 /* CallExpression */ || + node.parent.kind === 190 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 191 /* ParenthesizedExpression */) { + if (node.parent.kind === 193 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -110954,21 +112144,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 191 /* ParenthesizedExpression */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 193 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -110978,20 +112168,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 273 /* PropertyAssignment */ || node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 190 /* TypeAssertionExpression */) { + if (node.parent.kind === 192 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 218 /* DoStatement */) { + if (node.parent.kind === 221 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -110999,7 +112189,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.kind === 225 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -111419,9 +112609,9 @@ var ts; return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -112219,18 +113409,24 @@ var ts; })(ts || (ts = {})); //# sourceMappingURL=jsTyping.js.map "use strict"; -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 __assign = (this && this.__assign) || function () { + __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; + }; + return __assign.apply(this, arguments); }; var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } @@ -112465,6 +113661,7 @@ var ts; CommandTypes["Change"] = "change"; CommandTypes["Close"] = "close"; CommandTypes["Completions"] = "completions"; + CommandTypes["CompletionInfo"] = "completionInfo"; CommandTypes["CompletionsFull"] = "completions-full"; CommandTypes["CompletionDetails"] = "completionEntryDetails"; CommandTypes["CompletionDetailsFull"] = "completionEntryDetails-full"; @@ -112596,16 +113793,15 @@ var ts; var server; (function (server) { var TextStorage = (function () { - function TextStorage(host, fileName) { + function TextStorage(host, fileName, initialVersion) { this.host = host; this.fileName = fileName; - this.svcVersion = 0; - this.textVersion = 0; + this.version = initialVersion || { svc: 0, text: 0 }; } TextStorage.prototype.getVersion = function () { return this.svc - ? "SVC-" + this.svcVersion + "-" + this.svc.getSnapshotVersion() - : "Text-" + this.textVersion; + ? "SVC-" + this.version.svc + "-" + this.svc.getSnapshotVersion() + : "Text-" + this.version.text; }; TextStorage.prototype.hasScriptVersionCache_TestOnly = function () { return this.svc !== undefined; @@ -112617,7 +113813,7 @@ var ts; this.svc = undefined; this.text = newText; this.lineMap = undefined; - this.textVersion++; + this.version.text++; }; TextStorage.prototype.edit = function (start, end, newText) { this.switchToScriptVersionCache().edit(start, end - start, newText); @@ -112684,7 +113880,7 @@ var ts; TextStorage.prototype.switchToScriptVersionCache = function () { if (!this.svc || this.pendingReloadFromDisk) { this.svc = server.ScriptVersionCache.fromString(this.getOrLoadText()); - this.svcVersion++; + this.version.svc++; } return this.svc; }; @@ -112716,7 +113912,7 @@ var ts; } server.isDynamicFileName = isDynamicFileName; var ScriptInfo = (function () { - function ScriptInfo(host, fileName, scriptKind, hasMixedContent, path) { + function ScriptInfo(host, fileName, scriptKind, hasMixedContent, path, initialVersion) { this.host = host; this.fileName = fileName; this.scriptKind = scriptKind; @@ -112724,7 +113920,7 @@ var ts; this.path = path; this.containingProjects = []; this.isDynamic = isDynamicFileName(fileName); - this.textStorage = new TextStorage(host, fileName); + this.textStorage = new TextStorage(host, fileName, initialVersion); if (hasMixedContent || this.isDynamic) { this.textStorage.reload(""); this.realpath = this.path; @@ -112733,6 +113929,9 @@ var ts; ? scriptKind : ts.getScriptKindFromFileName(fileName); } + ScriptInfo.prototype.getVersion = function () { + return this.textStorage.version; + }; ScriptInfo.prototype.isDynamicOrHasMixedContent = function () { return this.hasMixedContent || this.isDynamic; }; @@ -112880,7 +114079,7 @@ var ts; } if (preferences) { if (!this.preferences) { - this.preferences = ts.defaultPreferences; + this.preferences = ts.emptyOptions; } this.preferences = __assign({}, this.preferences, preferences); } @@ -114275,6 +115474,7 @@ var ts; function ProjectService(opts) { var _this = this; this.filenameToScriptInfo = ts.createMap(); + this.filenameToScriptInfoVersion = ts.createMap(); this.allJsFilesForOpenFileTelemetry = ts.createMap(); this.externalProjectToConfiguredProjectMap = ts.createMap(); this.externalProjects = []; @@ -114323,7 +115523,7 @@ var ts; this.typingsCache = new server.TypingsCache(this.typingsInstaller); this.hostConfiguration = { formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), - preferences: ts.defaultPreferences, + preferences: ts.emptyOptions, hostInfo: "Unknown host", extraFileExtensions: [] }; @@ -114494,18 +115694,29 @@ var ts; } return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); }; + ProjectService.prototype.forEachProject = function (cb) { + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var p = _a[_i]; + cb(p); + } + this.configuredProjects.forEach(cb); + this.externalProjects.forEach(cb); + }; ProjectService.prototype.getDefaultProjectForFile = function (fileName, ensureProject) { + return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName); + }; + ProjectService.prototype.tryGetDefaultProjectForFile = function (fileName) { var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - if (ensureProject && (!scriptInfo || scriptInfo.isOrphan())) { - this.ensureProjectStructuresUptoDate(); - scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - if (!scriptInfo) { - return server.Errors.ThrowNoProject(); - } - return scriptInfo.getDefaultProject(); - } return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined; }; + ProjectService.prototype.ensureDefaultProjectForFile = function (fileName) { + return this.tryGetDefaultProjectForFile(fileName) || this.doEnsureDefaultProjectForFile(fileName); + }; + ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) { + this.ensureProjectStructuresUptoDate(); + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); + return scriptInfo ? scriptInfo.getDefaultProject() : server.Errors.ThrowNoProject(); + }; ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) { this.ensureProjectStructuresUptoDate(); return this.getScriptInfo(uncheckedFileName); @@ -114531,6 +115742,12 @@ var ts; var info = this.getScriptInfoForNormalizedPath(file); return info && info.getPreferences() || this.hostConfiguration.preferences; }; + ProjectService.prototype.getHostFormatCodeOptions = function () { + return this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.getHostPreferences = function () { + return this.hostConfiguration.preferences; + }; ProjectService.prototype.onSourceFileChanged = function (fileName, eventKind, path) { var info = this.getScriptInfoForPath(path); if (!info) { @@ -114690,6 +115907,7 @@ var ts; }; ProjectService.prototype.deleteScriptInfo = function (info) { this.filenameToScriptInfo.delete(info.path); + this.filenameToScriptInfoVersion.set(info.path, info.getVersion()); var realpath = info.getRealpathIfDifferent(); if (realpath) { this.realpathToScriptInfos.remove(realpath, info); @@ -115282,8 +116500,9 @@ var ts; if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; } - info = new server.ScriptInfo(this.host, fileName, scriptKind, !!hasMixedContent, path); + info = new server.ScriptInfo(this.host, fileName, scriptKind, !!hasMixedContent, path, this.filenameToScriptInfoVersion.get(path)); this.filenameToScriptInfo.set(info.path, info); + this.filenameToScriptInfoVersion.delete(info.path); if (!openedByClient) { this.watchClosedScriptInfo(info); } @@ -115853,7 +117072,9 @@ var ts; function formatRelatedInformation(info) { if (!info.file) { return { - message: ts.flattenDiagnosticMessageText(info.messageText, "\n") + message: ts.flattenDiagnosticMessageText(info.messageText, "\n"), + category: ts.diagnosticCategoryName(info), + code: info.code }; } return { @@ -115862,7 +117083,9 @@ var ts; end: convertToLocation(ts.getLineAndCharacterOfPosition(info.file, info.start + info.length)), file: info.file.fileName }, - message: ts.flattenDiagnosticMessageText(info.messageText, "\n") + message: ts.flattenDiagnosticMessageText(info.messageText, "\n"), + category: ts.diagnosticCategoryName(info), + code: info.code }; } function convertToLocation(lineAndCharacter) { @@ -115888,13 +117111,7 @@ var ts; ? __assign({}, common, { fileName: diag.file && diag.file.fileName }) : common; } function allEditsBeforePos(edits, pos) { - for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var edit = edits_1[_i]; - if (ts.textSpanEnd(edit.span) >= pos) { - return false; - } - } - return true; + return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } server.CommandNames = server.protocol.CommandTypes; function formatMessage(msg, logger, byteLength, newLine) { @@ -116140,11 +117357,14 @@ var ts; _a[server.CommandNames.FormatRangeFull] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); }, + _a[server.CommandNames.CompletionInfo] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.CompletionInfo)); + }, _a[server.CommandNames.Completions] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, true)); + return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.Completions)); }, _a[server.CommandNames.CompletionsFull] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, false)); + return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.CompletionsFull)); }, _a[server.CommandNames.CompletionDetails] = function (request) { return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, true)); @@ -116940,7 +118160,7 @@ var ts; }; Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) { var file = server.toNormalizedPath(args.file); - var project = this.getProject(args.projectFileName) || this.projectService.getDefaultProjectForFile(file, false); + var project = this.getProject(args.projectFileName) || this.projectService.tryGetDefaultProjectForFile(file); if (!project) { return server.Errors.ThrowNoProject(); } @@ -116951,7 +118171,7 @@ var ts; }; Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName) { var file = server.toNormalizedPath(uncheckedFileName); - var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, true); + var project = this.getProject(projectFileName) || this.projectService.ensureDefaultProjectForFile(file); return { file: file, project: project }; }; Session.prototype.getOutliningSpans = function (args, simplifiedResult) { @@ -117103,25 +118323,28 @@ var ts; }; }); }; - Session.prototype.getCompletions = function (args, simplifiedResult) { + Session.prototype.getCompletions = function (args, kind) { var _this = this; - var prefix = args.prefix || ""; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign({}, this.getPreferences(file), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); - if (simplifiedResult) { - return ts.mapDefined(completions && completions.entries, function (entry) { - if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) { - var name = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, isRecommended = entry.isRecommended; - var convertedSpan = replacementSpan ? _this.toLocationTextSpan(replacementSpan, scriptInfo) : undefined; - return { name: name, kind: kind, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended }; - } - }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); - } - else { + if (completions === undefined) + return undefined; + if (kind === "completions-full") return completions; - } + var prefix = args.prefix || ""; + var entries = ts.mapDefined(completions.entries, function (entry) { + if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) { + var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, isRecommended = entry.isRecommended; + var convertedSpan = replacementSpan ? _this.toLocationTextSpan(replacementSpan, scriptInfo) : undefined; + return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended }; + } + }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); + if (kind === "completions") + return entries; + var res = __assign({}, completions, { entries: entries }); + return res; }; Session.prototype.getCompletionEntryDetails = function (args, simplifiedResult) { var _this = this; @@ -117173,7 +118396,7 @@ var ts; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); - var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); + var helpItems = project.getLanguageService().getSignatureHelpItems(file, position, args); if (!helpItems) { return undefined; } @@ -117198,7 +118421,7 @@ var ts; var _this = this; return ts.mapDefined(fileNames, function (uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); - var project = defaultProject || _this.projectService.getDefaultProjectForFile(fileName, false); + var project = defaultProject || _this.projectService.tryGetDefaultProjectForFile(fileName); return project && { fileName: fileName, project: project }; }); }; @@ -117311,6 +118534,8 @@ var ts; var bakedItem = { name: navItem.name, kind: navItem.kind, + isCaseSensitive: navItem.isCaseSensitive, + matchKind: navItem.matchKind, file: navItem.fileName, start: scriptInfo.positionToLineOffset(navItem.textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)) @@ -117318,9 +118543,6 @@ var ts; if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { bakedItem.kindModifiers = navItem.kindModifiers; } - if (navItem.matchKind !== "none") { - bakedItem.matchKind = navItem.matchKind; - } if (navItem.containerName && (navItem.containerName.length > 0)) { bakedItem.containerName = navItem.containerName; } @@ -117429,9 +118651,26 @@ var ts; } }; Session.prototype.getEditsForFileRename = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var changes = project.getLanguageService().getEditsForFileRename(server.toNormalizedPath(args.oldFilePath), server.toNormalizedPath(args.newFilePath), this.getFormatOptions(file), this.getPreferences(file)); - return simplifiedResult ? this.mapTextChangesToCodeEdits(project, changes) : changes; + var _this = this; + var oldPath = server.toNormalizedPath(args.oldFilePath); + var newPath = server.toNormalizedPath(args.newFilePath); + var formatOptions = this.getHostFormatOptions(); + var preferences = this.getHostPreferences(); + var changes = []; + this.projectService.forEachProject(function (project) { + if (project.isOrphan() || !project.languageServiceEnabled) + return; + var _loop_8 = function (fileTextChanges) { + if (!changes.some(function (f) { return f.fileName === fileTextChanges.fileName; })) { + changes.push(simplifiedResult ? _this.mapTextChangeToCodeEdit(project, fileTextChanges) : fileTextChanges); + } + }; + for (var _i = 0, _a = project.getLanguageService().getEditsForFileRename(oldPath, newPath, formatOptions, preferences); _i < _a.length; _i++) { + var fileTextChanges = _a[_i]; + _loop_8(fileTextChanges); + } + }); + return changes; }; Session.prototype.getCodeFixes = function (args, simplifiedResult) { var _this = this; @@ -117493,10 +118732,12 @@ var ts; }; Session.prototype.mapTextChangesToCodeEdits = function (project, textChanges) { var _this = this; - return textChanges.map(function (change) { - var path = server.normalizedPathToPath(server.toNormalizedPath(change.fileName), _this.host.getCurrentDirectory(), function (fileName) { return _this.getCanonicalFileName(fileName); }); - return mapTextChangesToCodeEdits(change, project.getSourceFileOrConfigFile(path)); - }); + return textChanges.map(function (change) { return _this.mapTextChangeToCodeEdit(project, change); }); + }; + Session.prototype.mapTextChangeToCodeEdit = function (project, change) { + var _this = this; + var path = server.normalizedPathToPath(server.toNormalizedPath(change.fileName), this.host.getCurrentDirectory(), function (fileName) { return _this.getCanonicalFileName(fileName); }); + return mapTextChangesToCodeEdits(change, project.getSourceFileOrConfigFile(path)); }; Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { return { @@ -117534,7 +118775,7 @@ var ts; var lowPriorityFiles = []; var veryLowPriorityFiles = []; var normalizedFileName = server.toNormalizedPath(fileName); - var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); + var project = this.projectService.ensureDefaultProjectForFile(normalizedFileName); for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { var fileNameInProject = fileNamesInProject_1[_i]; if (this.getCanonicalFileName(fileNameInProject) === this.getCanonicalFileName(fileName)) { @@ -117650,6 +118891,12 @@ var ts; Session.prototype.getPreferences = function (file) { return this.projectService.getPreferences(file); }; + Session.prototype.getHostFormatOptions = function () { + return this.projectService.getHostFormatCodeOptions(); + }; + Session.prototype.getHostPreferences = function () { + return this.projectService.getHostPreferences(); + }; return Session; }()); server.Session = Session; @@ -117685,8 +118932,8 @@ var ts; } server.getLocationInNewDocument = getLocationInNewDocument; function applyEdits(text, textFilename, edits) { - for (var _i = 0, edits_2 = edits; _i < edits_2.length; _i++) { - var _a = edits_2[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; if (fileName !== textFilename) { continue; } @@ -118548,7 +119795,7 @@ var ts; }); Logger.prototype.write = function (s) { if (this.fd >= 0) { - var buf = new Buffer(s); + var buf = Buffer.from ? Buffer.from(s) : new Buffer(s); // tslint:disable-next-line no-null-keyword fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null); // TODO: GH#18217 } @@ -119145,7 +120392,7 @@ var ts; sys.watchDirectory = watchDirectorySwallowingException; } // Override sys.write because fs.writeSync is not reliable on Node 4 - sys.write = function (s) { return writeMessage(new Buffer(s, "utf8")); }; + sys.write = function (s) { return writeMessage(Buffer.from ? Buffer.from(s, "utf8") : new Buffer(s, "utf8")); }; sys.watchFile = function (fileName, callback) { var watchedFile = pollingWatchedFileSet.addFile(fileName, callback); return { diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 44036c3fe28c6..ad8fd411384ea 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -148,7 +148,7 @@ declare namespace ts { */ function flatMap(array: ReadonlyArray, mapfn: (x: T, i: number) => U | ReadonlyArray | undefined): U[]; function flatMap(array: ReadonlyArray | undefined, mapfn: (x: T, i: number) => U | ReadonlyArray | undefined): U[] | undefined; - function flatMapIterator(iter: Iterator, mapfn: (x: T) => U[] | Iterator | undefined): Iterator; + function flatMapIterator(iter: Iterator, mapfn: (x: T) => ReadonlyArray | Iterator | undefined): Iterator; /** * Maps an array. If the mapped value is an array, it is spread into the result. * Avoids allocation if all elements map to themselves. @@ -241,7 +241,6 @@ declare namespace ts { * Returns a new sorted array. */ function sort(array: ReadonlyArray, comparer: Comparer): T[]; - function best(iter: Iterator, isBetter: (a: T, b: T) => boolean): T | undefined; function arrayIterator(array: ReadonlyArray): Iterator; /** * Stable sort of an array. Elements equal to each other maintain their relative position in the array. @@ -364,6 +363,7 @@ declare namespace ts { */ function isString(text: any): text is string; function tryCast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined; + function tryCast(value: T, test: (value: T) => boolean): T | undefined; function cast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut; /** Does nothing. */ function noop(_?: {} | null | undefined): void; @@ -531,7 +531,7 @@ declare namespace ts { function findBestPatternMatch(values: ReadonlyArray, getPattern: (value: T) => Pattern, candidate: string): T | undefined; function startsWith(str: string, prefix: string): boolean; function removePrefix(str: string, prefix: string): string; - function tryRemovePrefix(str: string, prefix: string): string | undefined; + function tryRemovePrefix(str: string, prefix: string, getCanonicalFileName?: GetCanonicalFileName): string | undefined; function and(f: (arg: T) => boolean, g: (arg: T) => boolean): (arg: T) => boolean; function or(f: (arg: T) => boolean, g: (arg: T) => boolean): (arg: T) => boolean; function assertTypeIsNever(_: never): void; @@ -763,144 +763,147 @@ declare namespace ts { TypeLiteral = 166, ArrayType = 167, TupleType = 168, - UnionType = 169, - IntersectionType = 170, - ConditionalType = 171, - InferType = 172, - ParenthesizedType = 173, - ThisType = 174, - TypeOperator = 175, - IndexedAccessType = 176, - MappedType = 177, - LiteralType = 178, - ImportType = 179, - ObjectBindingPattern = 180, - ArrayBindingPattern = 181, - BindingElement = 182, - ArrayLiteralExpression = 183, - ObjectLiteralExpression = 184, - PropertyAccessExpression = 185, - ElementAccessExpression = 186, - CallExpression = 187, - NewExpression = 188, - TaggedTemplateExpression = 189, - TypeAssertionExpression = 190, - ParenthesizedExpression = 191, - FunctionExpression = 192, - ArrowFunction = 193, - DeleteExpression = 194, - TypeOfExpression = 195, - VoidExpression = 196, - AwaitExpression = 197, - PrefixUnaryExpression = 198, - PostfixUnaryExpression = 199, - BinaryExpression = 200, - ConditionalExpression = 201, - TemplateExpression = 202, - YieldExpression = 203, - SpreadElement = 204, - ClassExpression = 205, - OmittedExpression = 206, - ExpressionWithTypeArguments = 207, - AsExpression = 208, - NonNullExpression = 209, - MetaProperty = 210, - TemplateSpan = 211, - SemicolonClassElement = 212, - Block = 213, - VariableStatement = 214, - EmptyStatement = 215, - ExpressionStatement = 216, - IfStatement = 217, - DoStatement = 218, - WhileStatement = 219, - ForStatement = 220, - ForInStatement = 221, - ForOfStatement = 222, - ContinueStatement = 223, - BreakStatement = 224, - ReturnStatement = 225, - WithStatement = 226, - SwitchStatement = 227, - LabeledStatement = 228, - ThrowStatement = 229, - TryStatement = 230, - DebuggerStatement = 231, - VariableDeclaration = 232, - VariableDeclarationList = 233, - FunctionDeclaration = 234, - ClassDeclaration = 235, - InterfaceDeclaration = 236, - TypeAliasDeclaration = 237, - EnumDeclaration = 238, - ModuleDeclaration = 239, - ModuleBlock = 240, - CaseBlock = 241, - NamespaceExportDeclaration = 242, - ImportEqualsDeclaration = 243, - ImportDeclaration = 244, - ImportClause = 245, - NamespaceImport = 246, - NamedImports = 247, - ImportSpecifier = 248, - ExportAssignment = 249, - ExportDeclaration = 250, - NamedExports = 251, - ExportSpecifier = 252, - MissingDeclaration = 253, - ExternalModuleReference = 254, - JsxElement = 255, - JsxSelfClosingElement = 256, - JsxOpeningElement = 257, - JsxClosingElement = 258, - JsxFragment = 259, - JsxOpeningFragment = 260, - JsxClosingFragment = 261, - JsxAttribute = 262, - JsxAttributes = 263, - JsxSpreadAttribute = 264, - JsxExpression = 265, - CaseClause = 266, - DefaultClause = 267, - HeritageClause = 268, - CatchClause = 269, - PropertyAssignment = 270, - ShorthandPropertyAssignment = 271, - SpreadAssignment = 272, - EnumMember = 273, - SourceFile = 274, - Bundle = 275, - UnparsedSource = 276, - InputFiles = 277, - JSDocTypeExpression = 278, - JSDocAllType = 279, - JSDocUnknownType = 280, - JSDocNullableType = 281, - JSDocNonNullableType = 282, - JSDocOptionalType = 283, - JSDocFunctionType = 284, - JSDocVariadicType = 285, - JSDocComment = 286, - JSDocTypeLiteral = 287, - JSDocSignature = 288, - JSDocTag = 289, - JSDocAugmentsTag = 290, - JSDocClassTag = 291, - JSDocCallbackTag = 292, - JSDocParameterTag = 293, - JSDocReturnTag = 294, - JSDocThisTag = 295, - JSDocTypeTag = 296, - JSDocTemplateTag = 297, - JSDocTypedefTag = 298, - JSDocPropertyTag = 299, - SyntaxList = 300, - NotEmittedStatement = 301, - PartiallyEmittedExpression = 302, - CommaListExpression = 303, - MergeDeclarationMarker = 304, - EndOfDeclarationMarker = 305, - Count = 306, + OptionalType = 169, + RestType = 170, + UnionType = 171, + IntersectionType = 172, + ConditionalType = 173, + InferType = 174, + ParenthesizedType = 175, + ThisType = 176, + TypeOperator = 177, + IndexedAccessType = 178, + MappedType = 179, + LiteralType = 180, + ImportType = 181, + ObjectBindingPattern = 182, + ArrayBindingPattern = 183, + BindingElement = 184, + ArrayLiteralExpression = 185, + ObjectLiteralExpression = 186, + PropertyAccessExpression = 187, + ElementAccessExpression = 188, + CallExpression = 189, + NewExpression = 190, + TaggedTemplateExpression = 191, + TypeAssertionExpression = 192, + ParenthesizedExpression = 193, + FunctionExpression = 194, + ArrowFunction = 195, + DeleteExpression = 196, + TypeOfExpression = 197, + VoidExpression = 198, + AwaitExpression = 199, + PrefixUnaryExpression = 200, + PostfixUnaryExpression = 201, + BinaryExpression = 202, + ConditionalExpression = 203, + TemplateExpression = 204, + YieldExpression = 205, + SpreadElement = 206, + ClassExpression = 207, + OmittedExpression = 208, + ExpressionWithTypeArguments = 209, + AsExpression = 210, + NonNullExpression = 211, + MetaProperty = 212, + SyntheticExpression = 213, + TemplateSpan = 214, + SemicolonClassElement = 215, + Block = 216, + VariableStatement = 217, + EmptyStatement = 218, + ExpressionStatement = 219, + IfStatement = 220, + DoStatement = 221, + WhileStatement = 222, + ForStatement = 223, + ForInStatement = 224, + ForOfStatement = 225, + ContinueStatement = 226, + BreakStatement = 227, + ReturnStatement = 228, + WithStatement = 229, + SwitchStatement = 230, + LabeledStatement = 231, + ThrowStatement = 232, + TryStatement = 233, + DebuggerStatement = 234, + VariableDeclaration = 235, + VariableDeclarationList = 236, + FunctionDeclaration = 237, + ClassDeclaration = 238, + InterfaceDeclaration = 239, + TypeAliasDeclaration = 240, + EnumDeclaration = 241, + ModuleDeclaration = 242, + ModuleBlock = 243, + CaseBlock = 244, + NamespaceExportDeclaration = 245, + ImportEqualsDeclaration = 246, + ImportDeclaration = 247, + ImportClause = 248, + NamespaceImport = 249, + NamedImports = 250, + ImportSpecifier = 251, + ExportAssignment = 252, + ExportDeclaration = 253, + NamedExports = 254, + ExportSpecifier = 255, + MissingDeclaration = 256, + ExternalModuleReference = 257, + JsxElement = 258, + JsxSelfClosingElement = 259, + JsxOpeningElement = 260, + JsxClosingElement = 261, + JsxFragment = 262, + JsxOpeningFragment = 263, + JsxClosingFragment = 264, + JsxAttribute = 265, + JsxAttributes = 266, + JsxSpreadAttribute = 267, + JsxExpression = 268, + CaseClause = 269, + DefaultClause = 270, + HeritageClause = 271, + CatchClause = 272, + PropertyAssignment = 273, + ShorthandPropertyAssignment = 274, + SpreadAssignment = 275, + EnumMember = 276, + SourceFile = 277, + Bundle = 278, + UnparsedSource = 279, + InputFiles = 280, + JSDocTypeExpression = 281, + JSDocAllType = 282, + JSDocUnknownType = 283, + JSDocNullableType = 284, + JSDocNonNullableType = 285, + JSDocOptionalType = 286, + JSDocFunctionType = 287, + JSDocVariadicType = 288, + JSDocComment = 289, + JSDocTypeLiteral = 290, + JSDocSignature = 291, + JSDocTag = 292, + JSDocAugmentsTag = 293, + JSDocClassTag = 294, + JSDocCallbackTag = 295, + JSDocParameterTag = 296, + JSDocReturnTag = 297, + JSDocThisTag = 298, + JSDocTypeTag = 299, + JSDocTemplateTag = 300, + JSDocTypedefTag = 301, + JSDocPropertyTag = 302, + SyntaxList = 303, + NotEmittedStatement = 304, + PartiallyEmittedExpression = 305, + CommaListExpression = 306, + MergeDeclarationMarker = 307, + EndOfDeclarationMarker = 308, + Count = 309, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -912,7 +915,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 161, - LastTypeNode = 179, + LastTypeNode = 181, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -926,10 +929,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 146, - FirstJSDocNode = 278, - LastJSDocNode = 299, - FirstJSDocTagNode = 289, - LastJSDocTagNode = 299, + FirstJSDocNode = 281, + LastJSDocNode = 302, + FirstJSDocTagNode = 292, + LastJSDocTagNode = 302, FirstContextualKeyword = 117, LastContextualKeyword = 145 } @@ -1352,6 +1355,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } + interface OptionalTypeNode extends TypeNode { + kind: SyntaxKind.OptionalType; + type: TypeNode; + } + interface RestTypeNode extends TypeNode { + kind: SyntaxKind.RestType; + type: TypeNode; + } type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; @@ -1482,6 +1493,11 @@ declare namespace ts { asteriskToken?: AsteriskToken; expression?: Expression; } + interface SyntheticExpression extends Expression { + kind: SyntaxKind.SyntheticExpression; + isSpread: boolean; + type: Type; + } type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; @@ -1714,7 +1730,10 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; } @@ -2541,7 +2560,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -2567,8 +2585,9 @@ declare namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; + getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -2629,11 +2648,6 @@ declare namespace ts { writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string; writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; @@ -2675,7 +2689,7 @@ declare namespace ts { */ tryGetMemberInModuleExportsAndProperties(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined; + getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; @@ -2709,6 +2723,11 @@ declare namespace ts { getSymbolCount(): number; getTypeCount(): number; isArrayLikeType(type: Type): boolean; + /** + * True if `contextualType` should not be considered for completions because + * e.g. it specifies `kind: "a"` and obj has `kind: "b"`. + */ + isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression): boolean; /** * For a union, will include a property if it's defined in *any* of the member types. * So for `{ a } | { b }`, this will include both `a` and `b`. @@ -2821,25 +2840,6 @@ declare namespace ts { visitedSymbols: ReadonlyArray; }; } - /** - * @deprecated - */ - interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ interface SymbolWriter extends SymbolTracker { writeKeyword(text: string): void; writeOperator(text: string): void; @@ -2939,7 +2939,7 @@ declare namespace ts { getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean; isLateBound(node: Declaration): node is LateBoundDeclaration; - collectLinkedAliases(node: Identifier): Node[] | undefined; + collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined; isImplementationOfOverload(node: FunctionLike): boolean | undefined; isRequiredInitializedParameter(node: ParameterDeclaration): boolean; isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean; @@ -3072,6 +3072,7 @@ declare namespace ts { enumKind?: EnumKind; originatingImport?: ImportDeclaration | ImportCall; lateSymbol?: Symbol; + specifierCache?: Map; } enum EnumKind { Numeric = 0, @@ -3090,11 +3091,12 @@ declare namespace ts { ContainsStatic = 512, Late = 1024, ReverseMapped = 2048, + OptionalParameter = 4096, + RestParameter = 8192, Synthetic = 6 } interface TransientSymbol extends Symbol, SymbolLinks { checkFlags: CheckFlags; - isRestParameter?: boolean; } interface ReverseMappedSymbol extends TransientSymbol { propertyType: Type; @@ -3195,6 +3197,7 @@ declare namespace ts { hasSuperCall?: boolean; superCall?: SuperCall; switchTypes?: Type[]; + jsxNamespace?: Symbol | false; } enum TypeFlags { Any = 1, @@ -3270,7 +3273,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: Type[]; + aliasTypeArguments?: ReadonlyArray; wildcardInstantiation?: Type; } interface IntrinsicType extends Type { @@ -3311,6 +3314,12 @@ declare namespace ts { } interface ObjectType extends Type { objectFlags: ObjectFlags; + members?: SymbolTable; + properties?: Symbol[]; + callSignatures?: ReadonlyArray; + constructSignatures?: ReadonlyArray; + stringIndexInfo?: IndexInfo; + numberIndexInfo?: IndexInfo; } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ interface InterfaceType extends ObjectType { @@ -3341,7 +3350,7 @@ declare namespace ts { */ interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: Type[]; + typeArguments?: ReadonlyArray; } enum Variance { Invariant = 0, @@ -3354,6 +3363,14 @@ declare namespace ts { instantiations: Map; variances?: Variance[]; } + interface TupleType extends GenericType { + minLength: number; + hasRestElement: boolean; + associatedNames?: __String[]; + } + interface TupleTypeReference extends TypeReference { + target: TupleType; + } interface UnionOrIntersectionType extends Type { types: Type[]; propertyCache: SymbolTable; @@ -3391,10 +3408,8 @@ declare namespace ts { interface ResolvedType extends ObjectType, UnionOrIntersectionType { members: SymbolTable; properties: Symbol[]; - callSignatures: Signature[]; - constructSignatures: Signature[]; - stringIndexInfo?: IndexInfo; - numberIndexInfo?: IndexInfo; + callSignatures: ReadonlyArray; + constructSignatures: ReadonlyArray; } interface FreshObjectLiteralType extends ResolvedType { regularType: ResolvedType; @@ -3471,8 +3486,8 @@ declare namespace ts { } interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: TypeParameter[]; - parameters: Symbol[]; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; thisParameter?: Symbol; resolvedReturnType?: Type; resolvedTypePredicate?: TypePredicate; @@ -3538,7 +3553,7 @@ declare namespace ts { } type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary; interface InferenceContext extends TypeMapper { - typeParameters: TypeParameter[]; + typeParameters: ReadonlyArray; signature?: Signature; inferences: InferenceInfo[]; flags: InferenceFlags; @@ -3586,14 +3601,14 @@ declare namespace ts { next?: DiagnosticMessageChain; } interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -4268,6 +4283,7 @@ declare namespace ts { } interface EmitHost extends ScriptReferenceHost, ModuleSpecifierResolutionHost { getSourceFiles(): ReadonlyArray; + useCaseSensitiveFileNames(): boolean; getCurrentDirectory(): string; isSourceFileFromExternalLibrary(file: SourceFile): boolean; getCommonSourceDirectory(): string; @@ -4497,14 +4513,13 @@ declare namespace ts { readFile?(path: string): string | undefined; getSourceFiles?(): ReadonlyArray; } - /** @deprecated See comment on SymbolWriter */ interface SymbolTracker { trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError?(): void; reportPrivateInBaseOfClassExpression?(propertyName: string): void; reportInaccessibleUniqueSymbolError?(): void; moduleResolverHost?: ModuleSpecifierResolutionHost; - trackReferencedAmbientModule?(decl: ModuleDeclaration): void; + trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void; } interface TextSpan { start: number; @@ -4516,6 +4531,7 @@ declare namespace ts { } interface DiagnosticCollection { add(diagnostic: Diagnostic): void; + lookup(diagnostic: Diagnostic): Diagnostic | undefined; getGlobalDiagnostics(): Diagnostic[]; getDiagnostics(fileName: string): DiagnosticWithLocation[]; getDiagnostics(): Diagnostic[]; @@ -4921,7 +4937,6 @@ declare namespace ts { An_object_literal_cannot_have_property_and_accessor_with_the_same_name: DiagnosticMessage; An_export_assignment_cannot_have_modifiers: DiagnosticMessage; Octal_literals_are_not_allowed_in_strict_mode: DiagnosticMessage; - A_tuple_type_element_list_cannot_be_empty: DiagnosticMessage; Variable_declaration_list_cannot_be_empty: DiagnosticMessage; Digit_expected: DiagnosticMessage; Hexadecimal_digit_expected: DiagnosticMessage; @@ -5041,6 +5056,8 @@ declare namespace ts { _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: DiagnosticMessage; A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: DiagnosticMessage; A_definite_assignment_assertion_is_not_permitted_in_this_context: DiagnosticMessage; + A_rest_element_must_be_last_in_a_tuple_type: DiagnosticMessage; + A_required_element_cannot_follow_an_optional_element: DiagnosticMessage; with_statements_are_not_allowed_in_an_async_function_block: DiagnosticMessage; await_expression_is_only_allowed_within_an_async_function: DiagnosticMessage; can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: DiagnosticMessage; @@ -5071,7 +5088,7 @@ declare namespace ts { An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: DiagnosticMessage; infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: DiagnosticMessage; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: DiagnosticMessage; - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: DiagnosticMessage; + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: DiagnosticMessage; Type_arguments_cannot_be_used_here: DiagnosticMessage; The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: DiagnosticMessage; Duplicate_identifier_0: DiagnosticMessage; @@ -5141,6 +5158,7 @@ declare namespace ts { The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: DiagnosticMessage; Operator_0_cannot_be_applied_to_types_1_and_2: DiagnosticMessage; Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: DiagnosticMessage; + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: DiagnosticMessage; Type_parameter_name_cannot_be_0: DiagnosticMessage; A_parameter_property_is_only_allowed_in_a_constructor_implementation: DiagnosticMessage; A_rest_parameter_must_be_of_an_array_type: DiagnosticMessage; @@ -5190,6 +5208,7 @@ declare namespace ts { Class_0_incorrectly_extends_base_class_1: DiagnosticMessage; Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: DiagnosticMessage; Class_static_side_0_incorrectly_extends_base_class_static_side_1: DiagnosticMessage; + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: DiagnosticMessage; Class_0_incorrectly_implements_interface_1: DiagnosticMessage; A_class_may_only_implement_another_class_or_interface: DiagnosticMessage; Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: DiagnosticMessage; @@ -5337,6 +5356,9 @@ declare namespace ts { Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: DiagnosticMessage; Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: DiagnosticMessage; Object_is_of_type_unknown: DiagnosticMessage; + Rest_signatures_are_incompatible: DiagnosticMessage; + Property_0_is_incompatible_with_rest_element_type: DiagnosticMessage; + A_rest_element_type_must_be_an_array_type: DiagnosticMessage; JSX_element_attributes_type_0_may_not_be_a_union_type: DiagnosticMessage; The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: DiagnosticMessage; JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: DiagnosticMessage; @@ -5423,6 +5445,8 @@ declare namespace ts { Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: DiagnosticMessage; Cannot_find_lib_definition_for_0: DiagnosticMessage; Cannot_find_lib_definition_for_0_Did_you_mean_1: DiagnosticMessage; + _0_was_declared_here: DiagnosticMessage; + Property_0_is_used_before_its_initialization: DiagnosticMessage; Import_declaration_0_is_using_private_name_1: DiagnosticMessage; Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; @@ -5722,6 +5746,10 @@ declare namespace ts { Include_modules_imported_with_json_extension: DiagnosticMessage; All_destructured_elements_are_unused: DiagnosticMessage; All_variables_are_unused: DiagnosticMessage; + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: DiagnosticMessage; + Conflicts_are_in_this_file: DiagnosticMessage; + _0_was_also_declared_here: DiagnosticMessage; + and_here: DiagnosticMessage; Projects_to_reference: DiagnosticMessage; Enable_project_compilation: DiagnosticMessage; Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: DiagnosticMessage; @@ -5753,6 +5781,8 @@ declare namespace ts { Option_build_must_be_the_first_command_line_argument: DiagnosticMessage; Options_0_and_1_cannot_be_combined: DiagnosticMessage; Skipping_clean_because_not_all_projects_could_be_located: DiagnosticMessage; + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: DiagnosticMessage; + The_expected_type_comes_from_this_index_signature: DiagnosticMessage; Variable_0_implicitly_has_an_1_type: DiagnosticMessage; Parameter_0_implicitly_has_an_1_type: DiagnosticMessage; Member_0_implicitly_has_an_1_type: DiagnosticMessage; @@ -5784,6 +5814,7 @@ declare namespace ts { Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: DiagnosticMessage; Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: DiagnosticMessage; Mapped_object_type_implicitly_has_an_any_template_type: DiagnosticMessage; + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: DiagnosticMessage; You_cannot_rename_this_element: DiagnosticMessage; You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: DiagnosticMessage; import_can_only_be_used_in_a_ts_file: DiagnosticMessage; @@ -5928,6 +5959,10 @@ declare namespace ts { Add_or_remove_braces_in_an_arrow_function: DiagnosticMessage; Add_braces_to_arrow_function: DiagnosticMessage; Remove_braces_from_arrow_function: DiagnosticMessage; + Convert_default_export_to_named_export: DiagnosticMessage; + Convert_named_export_to_default_export: DiagnosticMessage; + Add_missing_enum_member_0: DiagnosticMessage; + Add_all_missing_imports: DiagnosticMessage; }; } declare namespace ts { @@ -6105,11 +6140,6 @@ declare namespace ts { function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile): string; function getTextOfConstantValue(value: string | number): string; function escapeLeadingUnderscores(identifier: string): __String; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier: string): string; function makeIdentifierFromModuleName(moduleName: string): string; function isBlockOrCatchScoped(declaration: Declaration): boolean; function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration): boolean; @@ -6138,7 +6168,7 @@ declare namespace ts { function isLateVisibilityPaintedStatement(node: Node): node is LateVisibilityPaintedStatement; function isAnyImportOrReExport(node: Node): node is AnyImportOrReExport; function getEnclosingBlockScopeContainer(node: Node): Node; - function declarationNameToString(name: DeclarationName | QualifiedName): string; + function declarationNameToString(name: DeclarationName | QualifiedName | undefined): string; function getNameFromIndexInfo(info: IndexInfo): string | undefined; function getTextOfPropertyName(name: PropertyName): __String; function entityNameToString(name: EntityNameOrEntityNameExpression): string; @@ -6150,8 +6180,8 @@ declare namespace ts { function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan; function isExternalOrCommonJsModule(file: SourceFile): boolean; function isJsonSourceFile(file: SourceFile): file is JsonSourceFile; - function isConstEnumDeclaration(node: Node): boolean; - function isConst(node: Node): boolean; + function isEnumConst(node: EnumDeclaration): boolean; + function isVarConst(node: VariableDeclaration | VariableDeclarationList): boolean; function isLet(node: Node): boolean; function isSuperCall(n: Node): n is SuperCall; function isImportCall(n: Node): n is ImportCall; @@ -6275,6 +6305,7 @@ declare namespace ts { function isExportsIdentifier(node: Node): boolean; function isModuleExportsPropertyAccessExpression(node: Node): boolean; function getSpecialPropertyAssignmentKind(expr: BinaryExpression): SpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs: PropertyAccessExpression): SpecialPropertyAssignmentKind; function getInitializerOfBinaryExpression(expr: BinaryExpression): Expression; function isPrototypePropertyAssignment(node: Node): boolean; function isSpecialPropertyDeclaration(expr: PropertyAccessExpression): boolean; @@ -6325,7 +6356,8 @@ declare namespace ts { function isIdentifierName(node: Identifier): boolean; function isAliasSymbolDeclaration(node: Node): boolean; function exportAssignmentIsAlias(node: ExportAssignment | BinaryExpression): boolean; - function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments | undefined; + function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments | undefined; + function getClassExtendsHeritageElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments | undefined; function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray | undefined; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node: Node): ReadonlyArray; @@ -6613,7 +6645,7 @@ declare namespace ts { function getObjectFlags(type: Type): ObjectFlags; function typeHasCallOrConstructSignatures(type: Type, checker: TypeChecker): boolean; function forSomeAncestorDirectory(directory: string, callback: (directory: string) => boolean): boolean; - function isUMDExportSymbol(symbol: Symbol | undefined): boolean | undefined; + function isUMDExportSymbol(symbol: Symbol | undefined): boolean; function showModuleSpecifier({ moduleSpecifier }: ImportDeclaration): string; function getLastChild(node: Node): Node | undefined; /** Add a value to a set, and return true if it wasn't already present. */ @@ -6626,6 +6658,7 @@ declare namespace ts { function textSpanEnd(span: TextSpan): number; function textSpanIsEmpty(span: TextSpan): boolean; function textSpanContainsPosition(span: TextSpan, position: number): boolean; + function textRangeContainsPositionInclusive(span: TextRange, position: number): boolean; function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan | undefined; @@ -6658,7 +6691,8 @@ declare namespace ts { function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; + function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; + function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** * Checks to see if the locale is in the appropriate format, @@ -6704,19 +6738,14 @@ declare namespace ts { function unescapeLeadingUnderscores(identifier: __String): string; function idText(identifier: Identifier): string; function symbolName(symbol: Symbol): string; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; /** @internal */ function isNamedDeclaration(node: Node): node is NamedDeclaration & { name: DeclarationName; }; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -6961,7 +6990,7 @@ declare namespace ts { function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken; function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier; - function isModifierKind(token: SyntaxKind): boolean; + function isModifierKind(token: SyntaxKind): token is Modifier["kind"]; function isParameterPropertyModifier(kind: SyntaxKind): boolean; function isClassMemberModifier(idToken: SyntaxKind): boolean; function isModifier(node: Node): node is Modifier; @@ -7092,6 +7121,7 @@ declare namespace ts { function chainDiagnosticMessages(details: DiagnosticMessageChain | undefined, message: DiagnosticMessage, ...args: (string | undefined)[]): DiagnosticMessageChain; function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison; + function compareDiagnosticsSkipRelatedInformation(d1: Diagnostic, d2: Diagnostic): Comparison; function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; function getEmitModuleKind(compilerOptions: { module?: CompilerOptions["module"]; @@ -7283,7 +7313,7 @@ declare namespace ts { function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; function containsPath(parent: string, child: string, ignoreCase?: boolean): boolean; function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; - function tryRemoveDirectoryPrefix(path: string, dirPath: string): string | undefined; + function tryRemoveDirectoryPrefix(path: string, dirPath: string, getCanonicalFileName: GetCanonicalFileName): string | undefined; function hasExtension(fileName: string): boolean; const commonPackageFolders: ReadonlyArray; function getRegularExpressionForWildcard(specs: ReadonlyArray | undefined, basePath: string, usage: "files" | "directories" | "exclude"): string | undefined; @@ -7381,6 +7411,9 @@ declare namespace ts { * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ function matchPatternOrExact(patternStrings: ReadonlyArray, candidate: string): string | Pattern | undefined; + type Mutable = { + -readonly [K in keyof T]: T[K]; + }; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -7733,8 +7766,8 @@ declare namespace ts { /** Create a unique name based on the supplied text. This does not consider names injected by the transformer. */ function createFileLevelUniqueName(text: string): Identifier; /** Create a unique name generated for a node. */ - function getGeneratedNameForNode(node: Node): Identifier; - function getGeneratedNameForNode(node: Node, flags: GeneratedIdentifierFlags): Identifier; + function getGeneratedNameForNode(node: Node | undefined): Identifier; + function getGeneratedNameForNode(node: Node | undefined, flags: GeneratedIdentifierFlags): Identifier; function createToken(token: TKind): Token; function createSuper(): SuperExpression; function createThis(): ThisExpression & Token; @@ -7790,7 +7823,11 @@ declare namespace ts { function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTypleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; + function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; + function createRestTypeNode(type: TypeNode): RestTypeNode; + function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; @@ -7845,7 +7882,7 @@ declare namespace ts { function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + /** @deprecated */ function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; @@ -7863,7 +7900,7 @@ declare namespace ts { function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): 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; + /** @deprecated */ function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; @@ -7891,13 +7928,16 @@ declare namespace ts { function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function createExpressionStatement(expression: Expression): ExpressionStatement; function updateBlock(node: Block, statements: ReadonlyArray): Block; function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; - function createStatement(expression: Expression): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createExpressionStatement(expression: Expression): ExpressionStatement; + function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + const createStatement: typeof createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + const updateStatement: typeof updateExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; @@ -8346,6 +8386,9 @@ declare namespace ts { function parenthesizeElementTypeMembers(members: ReadonlyArray): NodeArray; function parenthesizeTypeParameters(typeParameters: ReadonlyArray | undefined): MutableNodeArray | undefined; function parenthesizeConciseBody(body: ConciseBody): ConciseBody; + function isCommaSequence(node: Expression): node is (BinaryExpression & { + operatorToken: Token; + }) | CommaListExpression; enum OuterExpressionKinds { Parentheses = 1, Assertions = 2, @@ -8576,17 +8619,6 @@ declare namespace ts.sourcemaps { readonly lastSpan: SourceMapSpan; } function decodeMappings(map: SourceMapData): MappingsDecoder; - function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { - log?(s: string): void; - }): T[]; - interface RawSourceMapPosition { - emittedLine: number; - emittedColumn: number; - sourceLine: number; - sourceColumn: number; - sourceIndex: number; - nameIndex?: number; - } } declare namespace ts { function getOriginalNodeId(node: Node): number; @@ -8918,6 +8950,7 @@ declare namespace ts { } /** @internal */ function formatColorAndReset(text: string, formatStyle: string): string; + function formatLocation(file: SourceFile, start: number, host: FormatDiagnosticsHost, color?: typeof formatColorAndReset): string; function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain | undefined, newLine: string): string; /** @@ -9265,9 +9298,9 @@ declare namespace ts { } declare namespace ts.moduleSpecifiers { interface ModuleSpecifierPreferences { - importModuleSpecifierPreference?: "relative" | "non-relative"; + readonly importModuleSpecifierPreference?: "relative" | "non-relative"; } - function getModuleSpecifier(compilerOptions: CompilerOptions, fromSourceFile: SourceFile, fromSourceFileName: string, toFileName: string, host: ModuleSpecifierResolutionHost, preferences?: ModuleSpecifierPreferences): string; + function getModuleSpecifier(compilerOptions: CompilerOptions, importingSourceFile: SourceFile, importingSourceFileName: Path, toFileName: string, host: ModuleSpecifierResolutionHost, files: ReadonlyArray, preferences?: ModuleSpecifierPreferences): string; function getModuleSpecifiers(moduleSymbol: Symbol, compilerOptions: CompilerOptions, importingSourceFile: SourceFile, host: ModuleSpecifierResolutionHost, files: ReadonlyArray, preferences: ModuleSpecifierPreferences): ReadonlyArray>; } declare namespace ts { @@ -9521,12 +9554,12 @@ declare namespace ts { */ interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** * One or more of the outputs of the project does not exist. @@ -9829,8 +9862,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; + getCallSignatures(): ReadonlyArray; + getConstructSignatures(): ReadonlyArray; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -9859,7 +9892,7 @@ declare namespace ts { version: string; scriptSnapshot: IScriptSnapshot | undefined; nameTable: UnderscoreEscapedMap | undefined; - getNamedDeclarations(): Map; + getNamedDeclarations(): Map>; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; getLineStarts(): ReadonlyArray; @@ -9956,7 +9989,7 @@ declare namespace ts { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; } - const defaultPreferences: UserPreferences; + const emptyOptions: {}; interface LanguageService { cleanupSemanticCache(): void; getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; @@ -9980,7 +10013,7 @@ declare namespace ts { getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; @@ -10041,13 +10074,54 @@ declare namespace ts { type OrganizeImportsScope = CombinedCodeFixScope; type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } interface ApplyCodeActionCommandResult { successMessage: string; } @@ -10238,7 +10312,7 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; @@ -10695,11 +10769,13 @@ declare namespace ts { } function getLineStartPositionForPosition(position: number, sourceFile: SourceFileLike): number; function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; + function rangeContainsRangeExclusive(r1: TextRange, r2: TextRange): boolean; function rangeContainsPosition(r: TextRange, pos: number): boolean; function rangeContainsPositionExclusive(r: TextRange, pos: number): 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 nodeOverlapsWithStartEnd(node: Node, sourceFile: SourceFile, start: number, end: number): boolean; function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; /** * Assumes `candidate.start <= position` holds. @@ -10718,9 +10794,9 @@ declare namespace ts { * Returns the token if position is in [start, end). * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true */ - function getTouchingToken(sourceFile: SourceFile, position: number, includeJsDocComment: boolean, includePrecedingTokenAtEndPosition?: (n: Node) => boolean): Node; + function getTouchingToken(sourceFile: SourceFile, position: number, includePrecedingTokenAtEndPosition?: (n: Node) => boolean): Node; /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment: boolean, includeEndPosition?: boolean): Node; + function getTokenAtPosition(sourceFile: SourceFile, position: number): Node; /** * The token on the left of the position is the token that strictly includes the position * or sits to the left of the cursor if it is on a boundary. For example @@ -10735,7 +10811,7 @@ declare namespace ts { * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, includeJsDoc?: boolean): Node | undefined; + function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, excludeJsdoc?: boolean): Node | undefined; function isInString(sourceFile: SourceFile, position: number, previousToken?: Node | undefined): boolean; /** * returns true if the position is in between the open and close elements of an JSX expression. @@ -10754,8 +10830,8 @@ declare namespace ts { * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - function isInComment(sourceFile: SourceFile, position: number, tokenAtPosition?: Node, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean | undefined; + function isInComment(sourceFile: SourceFile, position: number, tokenAtPosition?: Node): CommentRange | undefined; + function hasDocComment(sourceFile: SourceFile, position: number): boolean; function getNodeModifiers(node: Node): string; function getTypeArgumentOrTypeParameterList(node: Node): NodeArray | undefined; function isComment(kind: SyntaxKind): boolean; @@ -10794,6 +10870,7 @@ declare namespace ts { Single = 0, Double = 1 } + function quotePreferenceFromString(str: StringLiteral, sourceFile: SourceFile): QuotePreference; function getQuotePreference(sourceFile: SourceFile, preferences: UserPreferences): QuotePreference; function symbolNameNoDefault(symbol: Symbol): string | undefined; function symbolEscapedNameNoDefault(symbol: Symbol): __String | undefined; @@ -10810,14 +10887,32 @@ declare namespace ts { */ function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, checker: TypeChecker, cb: (symbol: Symbol) => T | undefined): T | undefined; function isMemberSymbolInBaseType(memberSymbol: Symbol, checker: TypeChecker): boolean; - class NodeSet { + interface ReadonlyNodeSet { + has(node: Node): boolean; + forEach(cb: (node: Node) => void): void; + some(pred: (node: Node) => boolean): boolean; + } + class NodeSet implements ReadonlyNodeSet { private map; add(node: Node): void; has(node: Node): boolean; forEach(cb: (node: Node) => void): void; some(pred: (node: Node) => boolean): boolean; } + interface ReadonlyNodeMap { + get(node: TNode): TValue | undefined; + has(node: TNode): boolean; + } + class NodeMap implements ReadonlyNodeMap { + private map; + get(node: TNode): TValue | undefined; + getOrUpdate(node: TNode, setValue: () => TValue): TValue; + set(node: TNode, value: TValue): void; + has(node: TNode): boolean; + forEach(cb: (value: TValue, node: TNode) => void): void; + } function getParentNodeInSpan(node: Node | undefined, file: SourceFile, span: TextSpan): Node | undefined; + function findModifier(node: Node, kind: Modifier["kind"]): Modifier | undefined; function insertImport(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importDecl: Statement): void; } declare namespace ts { @@ -10906,7 +11001,7 @@ declare namespace ts.Completions { name: string; source?: string; } - function getCompletionEntryDetails(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost, formatContext: formatting.FormatContext, getCanonicalFileName: GetCanonicalFileName, preferences: UserPreferences, cancellationToken: CancellationToken): CompletionEntryDetails | undefined; + function getCompletionEntryDetails(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost, formatContext: formatting.FormatContext, preferences: UserPreferences, cancellationToken: CancellationToken): CompletionEntryDetails | undefined; function getCompletionEntrySymbol(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier): Symbol | undefined; } declare namespace ts.DocumentHighlights { @@ -10995,7 +11090,7 @@ declare namespace ts.FindAllReferences { } type ImportTracker = (exportSymbol: Symbol, exportInfo: ExportInfo, isForRename: boolean) => ImportsResult; /** Creates the imports map and returns an ImportTracker that uses it. Call this lazily to avoid calling `getDirectImportsMap` unnecessarily. */ - function createImportTracker(sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap, checker: TypeChecker, cancellationToken: CancellationToken): ImportTracker; + function createImportTracker(sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap, checker: TypeChecker, cancellationToken: CancellationToken | undefined): ImportTracker; /** Info about an exported symbol to perform recursive search on. */ interface ExportInfo { exportingModuleSymbol: Symbol; @@ -11087,7 +11182,7 @@ declare namespace ts.FindAllReferences { } function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined; function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ImplementationLocation[] | undefined; - function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number, options?: Options): ReferenceEntry[] | undefined; + function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, node: Node, position: number, options: Options | undefined): ReferenceEntry[] | undefined; function getReferenceEntriesForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options?: Options, sourceFilesSet?: ReadonlyMap): Entry[] | undefined; function toHighlightSpan(entry: Entry): { fileName: string; @@ -11098,9 +11193,11 @@ declare namespace ts.FindAllReferences { declare namespace ts.FindAllReferences.Core { /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */ function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options?: Options, sourceFilesSet?: ReadonlyMap): SymbolAndEntries[] | undefined; + function eachExportReference(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken | undefined, exportSymbol: Symbol, exportingModuleSymbol: Symbol, exportName: string, isDefaultExport: boolean, cb: (ref: Identifier) => void): void; /** Used as a quick check for whether a symbol is used at all in a file (besides its definition). */ function isSymbolReferencedInFile(definition: Identifier, checker: TypeChecker, sourceFile: SourceFile): boolean; function eachSymbolReferenceInFile(definition: Identifier, checker: TypeChecker, sourceFile: SourceFile, cb: (token: Identifier) => T): T | undefined; + function eachSignatureCall(signature: SignatureDeclaration, sourceFiles: ReadonlyArray, checker: TypeChecker, cb: (call: CallExpression) => void): void; /** * 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 @@ -11114,6 +11211,9 @@ declare namespace ts.FindAllReferences.Core { } declare namespace ts { function getEditsForFileRename(program: Program, oldFileOrDirPath: string, newFileOrDirPath: string, host: LanguageServiceHost, formatContext: formatting.FormatContext, preferences: UserPreferences): ReadonlyArray; + /** If 'path' refers to an old directory, returns path in the new directory. */ + type PathUpdater = (path: string) => string | undefined; + function getPathUpdater(oldFileOrDirPath: string, newFileOrDirPath: string, getCanonicalFileName: GetCanonicalFileName): PathUpdater; } declare namespace ts.GoToDefinition { function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[] | undefined; @@ -11211,10 +11311,10 @@ declare namespace ts { function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; } declare namespace ts.Rename { - function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: GetCanonicalFileName, sourceFile: SourceFile, position: number): RenameInfo; + function getRenameInfo(program: Program, sourceFile: SourceFile, position: number): RenameInfo; } declare namespace ts.SignatureHelp { - function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems | undefined; + function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, triggerReason: SignatureHelpTriggerReason | undefined, cancellationToken: CancellationToken): SignatureHelpItems | undefined; interface ArgumentInfoForCompletions { readonly invocation: CallLikeExpression; readonly argumentIndex: number; @@ -11362,8 +11462,8 @@ declare namespace ts.formatting { /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, onlyMultiLine: boolean, precedingToken?: Node | null, // tslint:disable-line:no-null-keyword - tokenAtPosition?: Node, predicate?: (c: CommentRange) => boolean): CommentRange | undefined; + function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, precedingToken?: Node | null, // tslint:disable-line:no-null-keyword + tokenAtPosition?: Node): CommentRange | undefined; function getIndentationString(indentation: number, options: EditorSettings): string; } declare namespace ts.formatting { @@ -11474,18 +11574,17 @@ declare namespace ts.textChanges { private readonly formatContext; private readonly changes; private readonly newFiles; - private readonly deletedNodesInLists; private readonly classesWithNodesInsertedAtStart; + private readonly deletedNodes; static fromContext(context: TextChangesContext): ChangeTracker; static with(context: TextChangesContext, cb: (tracker: ChangeTracker) => void): FileTextChanges[]; /** Public for tests only. Other callers should use `ChangeTracker.with`. */ constructor(newLineCharacter: string, formatContext: formatting.FormatContext); deleteRange(sourceFile: SourceFile, range: TextRange): this; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - deleteNode(sourceFile: SourceFile, node: Node, options?: ConfigurableStartEnd): this; + delete(sourceFile: SourceFile, node: Node): void; + deleteModifier(sourceFile: SourceFile, modifier: Modifier): void; deleteNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options?: ConfigurableStartEnd): this; deleteNodeRangeExcludingEnd(sourceFile: SourceFile, startNode: Node, afterEndNode: Node | undefined, options?: ConfigurableStartEnd): void; - deleteNodeInList(sourceFile: SourceFile, node: Node): this; replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options?: InsertNodeOptions): this; replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options?: ChangeNodeOptions): this; replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options?: ChangeNodeOptions): void; @@ -11494,7 +11593,7 @@ declare namespace ts.textChanges { replaceNodeRangeWithNodes(sourceFile: SourceFile, startNode: Node, endNode: Node, newNodes: ReadonlyArray, options?: ReplaceWithMultipleNodesOptions & ConfigurableStartEnd): this; private nextCommaToken; replacePropertyAssignment(sourceFile: SourceFile, oldNode: PropertyAssignment, newNode: PropertyAssignment): this; - private insertNodeAt; + insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options?: InsertNodeOptions): void; private insertNodesAt; insertNodeAtTopOfFile(sourceFile: SourceFile, newNode: Statement, blankLineBetween: boolean): void; insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, blankLineBetween?: boolean): void; @@ -11514,6 +11613,7 @@ declare namespace ts.textChanges { private getInsertNodeAtClassStartPrefixSuffix; insertNodeAfterComma(sourceFile: SourceFile, after: Node, newNode: Node): void; insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node): void; + insertNodeAtEndOfList(sourceFile: SourceFile, list: NodeArray, newNode: Node): void; insertNodesAfter(sourceFile: SourceFile, after: Node, newNodes: ReadonlyArray): void; private insertNodeAfterWorker; private getInsertNodeAfterOptions; @@ -11527,7 +11627,7 @@ declare namespace ts.textChanges { */ insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node, containingList?: NodeArray | undefined): this; private finishClassesWithNodesInsertedAtStart; - private finishTrailingCommaAfterDeletingNodesInList; + private finishDeleteDeclarations; /** * Note: after calling this, the TextChanges object must be discarded! * @param validate only for tests @@ -11538,14 +11638,16 @@ declare namespace ts.textChanges { createNewFile(oldFile: SourceFile, fileName: string, statements: ReadonlyArray): void; } type ValidateNonFormattedText = (node: Node, text: string) => void; - function applyChanges(text: string, changes: TextChange[]): string; + function applyChanges(text: string, changes: ReadonlyArray): string; function isValidLocationToAddComment(sourceFile: SourceFile, position: number): boolean; + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + function deleteNode(changes: ChangeTracker, sourceFile: SourceFile, node: Node, options?: ConfigurableStartEnd): void; } declare namespace ts { interface CodeFixRegistration { - errorCodes: number[]; + errorCodes: ReadonlyArray; getCodeActions(context: CodeFixContext): CodeFixAction[] | undefined; - fixIds?: string[]; + fixIds?: ReadonlyArray; getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions; } interface CodeFixContextBase extends textChanges.TextChangesContext { @@ -11569,8 +11671,10 @@ declare namespace ts { function getSupportedErrorCodes(): string[]; function getFixes(context: CodeFixContext): CodeFixAction[]; function getAllFixes(context: CodeFixAllContext): CombinedCodeActions; + function createCombinedCodeActions(changes: FileTextChanges[], commands?: CodeActionCommand[]): CombinedCodeActions; function createFileTextChanges(fileName: string, textChanges: TextChange[]): FileTextChanges; function codeFixAll(context: CodeFixAllContext, errorCodes: number[], use: (changes: textChanges.ChangeTracker, error: DiagnosticWithLocation, commands: Push) => void): CombinedCodeActions; + function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: ReadonlyArray, cb: (diag: DiagnosticWithLocation) => void): void; } } declare namespace ts { @@ -11611,7 +11715,8 @@ declare namespace ts.codefix { declare namespace ts.codefix { } declare namespace ts.codefix { - function getImportCompletionAction(exportedSymbol: Symbol, moduleSymbol: Symbol, sourceFile: SourceFile, symbolName: string, host: LanguageServiceHost, program: Program, checker: TypeChecker, compilerOptions: CompilerOptions, allSourceFiles: ReadonlyArray, formatContext: formatting.FormatContext, getCanonicalFileName: GetCanonicalFileName, symbolToken: Node | undefined, preferences: UserPreferences): { + const importFixId = "fixMissingImport"; + function getImportCompletionAction(exportedSymbol: Symbol, moduleSymbol: Symbol, sourceFile: SourceFile, symbolName: string, host: LanguageServiceHost, program: Program, checker: TypeChecker, allSourceFiles: ReadonlyArray, formatContext: formatting.FormatContext, symbolToken: Node | undefined, preferences: UserPreferences): { readonly moduleSpecifier: string; readonly codeAction: CodeAction; }; @@ -11655,7 +11760,7 @@ declare namespace ts.codefix { * @returns Empty string iff there are no member insertions. */ function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: ReadonlyArray, checker: TypeChecker, preferences: UserPreferences, out: (node: ClassElement) => void): void; - function createMethodFromCallExpression({ typeArguments, arguments: args, parent: parent }: CallExpression, methodName: string, inJs: boolean, makeStatic: boolean, preferences: UserPreferences): MethodDeclaration; + function createMethodFromCallExpression(context: CodeFixContextBase, { typeArguments, arguments: args, parent: parent }: CallExpression, methodName: string, inJs: boolean, makeStatic: boolean, preferences: UserPreferences): MethodDeclaration; } declare namespace ts.codefix { } @@ -11671,7 +11776,9 @@ declare namespace ts.codefix { } declare namespace ts.codefix { } -declare namespace ts.refactor.generateGetAccessorAndSetAccessor { +declare namespace ts.refactor { +} +declare namespace ts.refactor { } declare namespace ts.refactor.extractSymbol { /** @@ -11867,7 +11974,7 @@ declare namespace ts { */ readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; /** - * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules + * Read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules */ readFile(fileName: string): string | undefined; realpath?(path: string): string; @@ -11905,7 +12012,7 @@ declare namespace ts { 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; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): string; /** * Returns a JSON-encoded value of the type: * { canRename: boolean, localizedErrorMessage: string, displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, triggerSpan: { start; length } } @@ -12204,6 +12311,7 @@ declare namespace ts.server.protocol { Change = "change", Close = "close", Completions = "completions", + CompletionInfo = "completionInfo", CompletionsFull = "completions-full", CompletionDetails = "completionEntryDetails", CompletionDetailsFull = "completionEntryDetails-full", @@ -12467,7 +12575,7 @@ declare namespace ts.server.protocol { command: CommandTypes.GetEditsForFileRename; arguments: GetEditsForFileRenameRequestArgs; } - interface GetEditsForFileRenameRequestArgs extends FileRequestArgs { + interface GetEditsForFileRenameRequestArgs { readonly oldFilePath: string; readonly newFilePath: string; } @@ -12905,6 +13013,15 @@ declare namespace ts.server.protocol { interface CompletionsResponse extends Response { body?: CompletionEntry[]; } + interface CompletionInfoResponse extends Response { + body?: CompletionInfo; + } + interface CompletionInfo { + readonly isGlobalCompletion: boolean; + readonly isMemberCompletion: boolean; + readonly isNewIdentifierLocation: boolean; + readonly entries: ReadonlyArray; + } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } @@ -12930,7 +13047,23 @@ declare namespace ts.server.protocol { argumentIndex: number; argumentCount: number; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + triggerCharacter: SignatureHelpTriggerCharacter; + } + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + triggerCharacter?: SignatureHelpRetriggerCharacter; } interface SignatureHelpRequest extends FileLocationRequest { command: CommandTypes.SignatureHelp; @@ -13003,6 +13136,8 @@ declare namespace ts.server.protocol { fileName: string; } interface DiagnosticRelatedInformation { + category: string; + code: number; message: string; span?: FileSpan; } @@ -13066,15 +13201,12 @@ declare namespace ts.server.protocol { command: CommandTypes.Navto; arguments: NavtoRequestArgs; } - interface NavtoItem { + interface NavtoItem extends FileSpan { name: string; kind: ScriptElementKind; - matchKind?: string; - isCaseSensitive?: boolean; + matchKind: string; + isCaseSensitive: boolean; kindModifiers?: string; - file: string; - start: Location; - end: Location; containerName?: string; containerKind?: ScriptElementKind; } @@ -13312,18 +13444,21 @@ declare namespace ts.server.protocol { } } declare namespace ts.server { + interface ScriptInfoVersion { + svc: number; + text: number; + } class TextStorage { private readonly host; private readonly fileName; + version: ScriptInfoVersion; private svc; - private svcVersion; private text; private lineMap; - private textVersion; isOpen: boolean; private ownFileText; private pendingReloadFromDisk; - constructor(host: ServerHost, fileName: NormalizedPath); + constructor(host: ServerHost, fileName: NormalizedPath, initialVersion?: ScriptInfoVersion); getVersion(): string; hasScriptVersionCache_TestOnly(): boolean; useScriptVersionCache_TestOnly(): void; @@ -13363,7 +13498,8 @@ declare namespace ts.server { readonly isDynamic: boolean; private realpath; cacheSourceFile: DocumentRegistrySourceFileCache; - constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path); + constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path, initialVersion?: ScriptInfoVersion); + getVersion(): ScriptInfoVersion; isDynamicOrHasMixedContent(): boolean; isScriptOpen(): boolean; open(newText: string): void; @@ -13773,6 +13909,7 @@ declare namespace ts.server { readonly typingsCache: TypingsCache; readonly documentRegistry: DocumentRegistry; private readonly filenameToScriptInfo; + private readonly filenameToScriptInfoVersion; private readonly allJsFilesForOpenFileTelemetry; readonly realpathToScriptInfos: MultiMap | undefined; private readonly externalProjectToConfiguredProjectMap; @@ -13830,11 +13967,17 @@ declare namespace ts.server { private delayUpdateProjectGraphs; setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void; findProject(projectName: string): Project | undefined; + forEachProject(cb: (project: Project) => void): void; getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined; + tryGetDefaultProjectForFile(fileName: NormalizedPath): Project | undefined; + ensureDefaultProjectForFile(fileName: NormalizedPath): Project; + private doEnsureDefaultProjectForFile; getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo | undefined; private ensureProjectStructuresUptoDate; getFormatCodeOptions(file: NormalizedPath): FormatCodeSettings; getPreferences(file: NormalizedPath): UserPreferences; + getHostFormatCodeOptions(): FormatCodeSettings; + getHostPreferences(): UserPreferences; private onSourceFileChanged; private handleDeletedFile; watchWildcardDirectory(directory: Path, flags: WatchDirectoryFlags, project: ConfiguredProject): FileWatcher; @@ -14065,6 +14208,7 @@ declare namespace ts.server { private mapCodeAction; private mapCodeFixAction; private mapTextChangesToCodeEdits; + private mapTextChangeToCodeEdit; private convertTextChangeToCodeEdit; private getBraceMatching; private getDiagnosticsForProject; @@ -14081,6 +14225,8 @@ declare namespace ts.server { onMessage(message: string): void; private getFormatOptions; private getPreferences; + private getHostFormatOptions; + private getHostPreferences; } interface HandlerResponse { response?: {}; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index d9addcbcdbf68..440e7824b6001 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -242,144 +242,147 @@ declare namespace ts { TypeLiteral = 166, ArrayType = 167, TupleType = 168, - UnionType = 169, - IntersectionType = 170, - ConditionalType = 171, - InferType = 172, - ParenthesizedType = 173, - ThisType = 174, - TypeOperator = 175, - IndexedAccessType = 176, - MappedType = 177, - LiteralType = 178, - ImportType = 179, - ObjectBindingPattern = 180, - ArrayBindingPattern = 181, - BindingElement = 182, - ArrayLiteralExpression = 183, - ObjectLiteralExpression = 184, - PropertyAccessExpression = 185, - ElementAccessExpression = 186, - CallExpression = 187, - NewExpression = 188, - TaggedTemplateExpression = 189, - TypeAssertionExpression = 190, - ParenthesizedExpression = 191, - FunctionExpression = 192, - ArrowFunction = 193, - DeleteExpression = 194, - TypeOfExpression = 195, - VoidExpression = 196, - AwaitExpression = 197, - PrefixUnaryExpression = 198, - PostfixUnaryExpression = 199, - BinaryExpression = 200, - ConditionalExpression = 201, - TemplateExpression = 202, - YieldExpression = 203, - SpreadElement = 204, - ClassExpression = 205, - OmittedExpression = 206, - ExpressionWithTypeArguments = 207, - AsExpression = 208, - NonNullExpression = 209, - MetaProperty = 210, - TemplateSpan = 211, - SemicolonClassElement = 212, - Block = 213, - VariableStatement = 214, - EmptyStatement = 215, - ExpressionStatement = 216, - IfStatement = 217, - DoStatement = 218, - WhileStatement = 219, - ForStatement = 220, - ForInStatement = 221, - ForOfStatement = 222, - ContinueStatement = 223, - BreakStatement = 224, - ReturnStatement = 225, - WithStatement = 226, - SwitchStatement = 227, - LabeledStatement = 228, - ThrowStatement = 229, - TryStatement = 230, - DebuggerStatement = 231, - VariableDeclaration = 232, - VariableDeclarationList = 233, - FunctionDeclaration = 234, - ClassDeclaration = 235, - InterfaceDeclaration = 236, - TypeAliasDeclaration = 237, - EnumDeclaration = 238, - ModuleDeclaration = 239, - ModuleBlock = 240, - CaseBlock = 241, - NamespaceExportDeclaration = 242, - ImportEqualsDeclaration = 243, - ImportDeclaration = 244, - ImportClause = 245, - NamespaceImport = 246, - NamedImports = 247, - ImportSpecifier = 248, - ExportAssignment = 249, - ExportDeclaration = 250, - NamedExports = 251, - ExportSpecifier = 252, - MissingDeclaration = 253, - ExternalModuleReference = 254, - JsxElement = 255, - JsxSelfClosingElement = 256, - JsxOpeningElement = 257, - JsxClosingElement = 258, - JsxFragment = 259, - JsxOpeningFragment = 260, - JsxClosingFragment = 261, - JsxAttribute = 262, - JsxAttributes = 263, - JsxSpreadAttribute = 264, - JsxExpression = 265, - CaseClause = 266, - DefaultClause = 267, - HeritageClause = 268, - CatchClause = 269, - PropertyAssignment = 270, - ShorthandPropertyAssignment = 271, - SpreadAssignment = 272, - EnumMember = 273, - SourceFile = 274, - Bundle = 275, - UnparsedSource = 276, - InputFiles = 277, - JSDocTypeExpression = 278, - JSDocAllType = 279, - JSDocUnknownType = 280, - JSDocNullableType = 281, - JSDocNonNullableType = 282, - JSDocOptionalType = 283, - JSDocFunctionType = 284, - JSDocVariadicType = 285, - JSDocComment = 286, - JSDocTypeLiteral = 287, - JSDocSignature = 288, - JSDocTag = 289, - JSDocAugmentsTag = 290, - JSDocClassTag = 291, - JSDocCallbackTag = 292, - JSDocParameterTag = 293, - JSDocReturnTag = 294, - JSDocThisTag = 295, - JSDocTypeTag = 296, - JSDocTemplateTag = 297, - JSDocTypedefTag = 298, - JSDocPropertyTag = 299, - SyntaxList = 300, - NotEmittedStatement = 301, - PartiallyEmittedExpression = 302, - CommaListExpression = 303, - MergeDeclarationMarker = 304, - EndOfDeclarationMarker = 305, - Count = 306, + OptionalType = 169, + RestType = 170, + UnionType = 171, + IntersectionType = 172, + ConditionalType = 173, + InferType = 174, + ParenthesizedType = 175, + ThisType = 176, + TypeOperator = 177, + IndexedAccessType = 178, + MappedType = 179, + LiteralType = 180, + ImportType = 181, + ObjectBindingPattern = 182, + ArrayBindingPattern = 183, + BindingElement = 184, + ArrayLiteralExpression = 185, + ObjectLiteralExpression = 186, + PropertyAccessExpression = 187, + ElementAccessExpression = 188, + CallExpression = 189, + NewExpression = 190, + TaggedTemplateExpression = 191, + TypeAssertionExpression = 192, + ParenthesizedExpression = 193, + FunctionExpression = 194, + ArrowFunction = 195, + DeleteExpression = 196, + TypeOfExpression = 197, + VoidExpression = 198, + AwaitExpression = 199, + PrefixUnaryExpression = 200, + PostfixUnaryExpression = 201, + BinaryExpression = 202, + ConditionalExpression = 203, + TemplateExpression = 204, + YieldExpression = 205, + SpreadElement = 206, + ClassExpression = 207, + OmittedExpression = 208, + ExpressionWithTypeArguments = 209, + AsExpression = 210, + NonNullExpression = 211, + MetaProperty = 212, + SyntheticExpression = 213, + TemplateSpan = 214, + SemicolonClassElement = 215, + Block = 216, + VariableStatement = 217, + EmptyStatement = 218, + ExpressionStatement = 219, + IfStatement = 220, + DoStatement = 221, + WhileStatement = 222, + ForStatement = 223, + ForInStatement = 224, + ForOfStatement = 225, + ContinueStatement = 226, + BreakStatement = 227, + ReturnStatement = 228, + WithStatement = 229, + SwitchStatement = 230, + LabeledStatement = 231, + ThrowStatement = 232, + TryStatement = 233, + DebuggerStatement = 234, + VariableDeclaration = 235, + VariableDeclarationList = 236, + FunctionDeclaration = 237, + ClassDeclaration = 238, + InterfaceDeclaration = 239, + TypeAliasDeclaration = 240, + EnumDeclaration = 241, + ModuleDeclaration = 242, + ModuleBlock = 243, + CaseBlock = 244, + NamespaceExportDeclaration = 245, + ImportEqualsDeclaration = 246, + ImportDeclaration = 247, + ImportClause = 248, + NamespaceImport = 249, + NamedImports = 250, + ImportSpecifier = 251, + ExportAssignment = 252, + ExportDeclaration = 253, + NamedExports = 254, + ExportSpecifier = 255, + MissingDeclaration = 256, + ExternalModuleReference = 257, + JsxElement = 258, + JsxSelfClosingElement = 259, + JsxOpeningElement = 260, + JsxClosingElement = 261, + JsxFragment = 262, + JsxOpeningFragment = 263, + JsxClosingFragment = 264, + JsxAttribute = 265, + JsxAttributes = 266, + JsxSpreadAttribute = 267, + JsxExpression = 268, + CaseClause = 269, + DefaultClause = 270, + HeritageClause = 271, + CatchClause = 272, + PropertyAssignment = 273, + ShorthandPropertyAssignment = 274, + SpreadAssignment = 275, + EnumMember = 276, + SourceFile = 277, + Bundle = 278, + UnparsedSource = 279, + InputFiles = 280, + JSDocTypeExpression = 281, + JSDocAllType = 282, + JSDocUnknownType = 283, + JSDocNullableType = 284, + JSDocNonNullableType = 285, + JSDocOptionalType = 286, + JSDocFunctionType = 287, + JSDocVariadicType = 288, + JSDocComment = 289, + JSDocTypeLiteral = 290, + JSDocSignature = 291, + JSDocTag = 292, + JSDocAugmentsTag = 293, + JSDocClassTag = 294, + JSDocCallbackTag = 295, + JSDocParameterTag = 296, + JSDocReturnTag = 297, + JSDocThisTag = 298, + JSDocTypeTag = 299, + JSDocTemplateTag = 300, + JSDocTypedefTag = 301, + JSDocPropertyTag = 302, + SyntaxList = 303, + NotEmittedStatement = 304, + PartiallyEmittedExpression = 305, + CommaListExpression = 306, + MergeDeclarationMarker = 307, + EndOfDeclarationMarker = 308, + Count = 309, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -391,7 +394,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 161, - LastTypeNode = 179, + LastTypeNode = 181, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -405,10 +408,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 146, - FirstJSDocNode = 278, - LastJSDocNode = 299, - FirstJSDocTagNode = 289, - LastJSDocTagNode = 299 + FirstJSDocNode = 281, + LastJSDocNode = 302, + FirstJSDocTagNode = 292, + LastJSDocTagNode = 302 } enum NodeFlags { None = 0, @@ -767,6 +770,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } + interface OptionalTypeNode extends TypeNode { + kind: SyntaxKind.OptionalType; + type: TypeNode; + } + interface RestTypeNode extends TypeNode { + kind: SyntaxKind.RestType; + type: TypeNode; + } type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; @@ -891,6 +902,11 @@ declare namespace ts { asteriskToken?: AsteriskToken; expression?: Expression; } + interface SyntheticExpression extends Expression { + kind: SyntaxKind.SyntheticExpression; + isSpread: boolean; + type: Type; + } type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; @@ -1105,7 +1121,10 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; } @@ -1780,6 +1799,7 @@ declare namespace ts { */ getTypeChecker(): TypeChecker; isSourceFileFromExternalLibrary(file: SourceFile): boolean; + isSourceFileDefaultLibrary(file: SourceFile): boolean; getProjectReferences(): (ResolvedProjectReference | undefined)[] | undefined; } interface ResolvedProjectReference { @@ -1818,7 +1838,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -1838,7 +1857,7 @@ declare namespace ts { getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1889,11 +1908,6 @@ declare namespace ts { typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): string; typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; @@ -1920,7 +1934,7 @@ declare namespace ts { getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined; + getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; @@ -1992,39 +2006,6 @@ declare namespace ts { AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8 } - /** - * @deprecated - */ - interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ - interface SymbolWriter extends SymbolTracker { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeProperty(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - } enum TypePredicateKind { This = 0, Identifier = 1 @@ -2214,7 +2195,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: Type[]; + aliasTypeArguments?: ReadonlyArray; } interface LiteralType extends Type { value: string | number; @@ -2279,10 +2260,18 @@ declare namespace ts { */ interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: Type[]; + typeArguments?: ReadonlyArray; } interface GenericType extends InterfaceType, TypeReference { } + interface TupleType extends GenericType { + minLength: number; + hasRestElement: boolean; + associatedNames?: __String[]; + } + interface TupleTypeReference extends TypeReference { + target: TupleType; + } interface UnionOrIntersectionType extends Type { types: Type[]; } @@ -2339,8 +2328,8 @@ declare namespace ts { } interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: TypeParameter[]; - parameters: Symbol[]; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; } enum IndexKind { String = 0, @@ -2388,14 +2377,14 @@ declare namespace ts { next?: DiagnosticMessageChain; } interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -2929,13 +2918,6 @@ declare namespace ts { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - /** @deprecated See comment on SymbolWriter */ - interface SymbolTracker { - trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError?(): void; - reportPrivateInBaseOfClassExpression?(propertyName: string): void; - reportInaccessibleUniqueSymbolError?(): void; - } interface TextSpan { start: number; length: number; @@ -3166,7 +3148,8 @@ declare namespace ts { function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; + function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; + function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** * Checks to see if the locale is in the appropriate format, @@ -3212,15 +3195,8 @@ declare namespace ts { function unescapeLeadingUnderscores(identifier: __String): string; function idText(identifier: Identifier): string; function symbolName(symbol: Symbol): string; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -3655,7 +3631,7 @@ declare namespace ts { /** Create a unique name based on the supplied text. This does not consider names injected by the transformer. */ function createFileLevelUniqueName(text: string): Identifier; /** Create a unique name generated for a node. */ - function getGeneratedNameForNode(node: Node): Identifier; + function getGeneratedNameForNode(node: Node | undefined): Identifier; function createToken(token: TKind): Token; function createSuper(): SuperExpression; function createThis(): ThisExpression & Token; @@ -3710,7 +3686,11 @@ declare namespace ts { function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTypleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; + function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; + function createRestTypeNode(type: TypeNode): RestTypeNode; + function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; @@ -3763,7 +3743,7 @@ declare namespace ts { function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + /** @deprecated */ function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; @@ -3781,7 +3761,7 @@ declare namespace ts { function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): 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; + /** @deprecated */ function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; @@ -3813,8 +3793,12 @@ declare namespace ts { function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; - function createStatement(expression: Expression): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createExpressionStatement(expression: Expression): ExpressionStatement; + function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + const createStatement: typeof createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + const updateStatement: typeof updateExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; @@ -4504,12 +4488,12 @@ declare namespace ts { */ interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** * One or more of the outputs of the project does not exist. @@ -4629,8 +4613,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; + getCallSignatures(): ReadonlyArray; + getConstructSignatures(): ReadonlyArray; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4771,7 +4755,7 @@ declare namespace ts { getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; @@ -4831,13 +4815,54 @@ declare namespace ts { type OrganizeImportsScope = CombinedCodeFixScope; type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } interface ApplyCodeActionCommandResult { successMessage: string; } @@ -5025,7 +5050,7 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; diff --git a/lib/typescript.js b/lib/typescript.js index c1ead6a1fac3f..4785ced00f304 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -26,6 +26,33 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +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 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, 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 __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; @@ -889,23 +916,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1866,8 +1876,9 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; - function tryRemovePrefix(str, prefix) { - return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2207,160 +2218,163 @@ var ts; SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType"; + SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 213] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 295] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 296] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 297] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 298] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 299] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 296] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 297] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 298] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 299] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 300] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 301] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 302] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 300] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 303] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 301] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 302] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 303] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 304] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 305] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 304] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 305] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 306] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 307] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 308] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 306] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 309] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -2373,7 +2387,7 @@ var ts; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; @@ -2387,10 +2401,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 299] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 299] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 302] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 302] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -2564,6 +2578,7 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; @@ -2783,6 +2798,8 @@ var ts; CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; CheckFlags[CheckFlags["Late"] = 1024] = "Late"; CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped"; + CheckFlags[CheckFlags["OptionalParameter"] = 4096] = "OptionalParameter"; + CheckFlags[CheckFlags["RestParameter"] = 8192] = "RestParameter"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var InternalSymbolName; @@ -4417,6 +4434,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -4575,7 +4595,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -4695,6 +4714,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -4725,7 +4746,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -4795,6 +4816,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -4844,6 +4866,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -4991,6 +5014,9 @@ var ts; Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -5077,6 +5103,8 @@ var ts; Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -5376,6 +5404,10 @@ var ts; Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true), All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5407,6 +5439,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -5438,6 +5472,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -5582,6 +5617,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -7730,7 +7769,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274 /* SourceFile */) { + while (node && node.kind !== 277 /* SourceFile */) { node = node.parent; } return node; @@ -7738,11 +7777,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return true; } return false; @@ -7880,7 +7919,7 @@ 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 === 300 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 303 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7973,14 +8012,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; // 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) { @@ -7994,7 +8025,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; + return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -8026,11 +8057,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 && node.kind === 239 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 /* SourceFile */ || - node.kind === 239 /* ModuleDeclaration */ || + return node.kind === 277 /* SourceFile */ || + node.kind === 242 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8047,9 +8078,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node.parent); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8061,22 +8092,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 269 /* CatchClause */: - case 239 /* ModuleDeclaration */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 272 /* CatchClause */: + case 242 /* ModuleDeclaration */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; - case 213 /* Block */: + case 216 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8092,22 +8123,22 @@ var ts; case 160 /* IndexSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: - case 288 /* JSDocSignature */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 291 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -8117,8 +8148,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8127,15 +8158,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 214 /* VariableStatement */: - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 217 /* VariableStatement */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -8156,7 +8187,7 @@ var ts; // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -8183,7 +8214,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8228,7 +8259,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213 /* Block */) { + if (node.body && node.body.kind === 216 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8242,7 +8273,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* 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 @@ -8251,25 +8282,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: errorNode = node.name; break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8301,35 +8332,34 @@ var ts; return file.scriptKind === 6 /* JSON */; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */ && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */) - || !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 /* ImportType */ && - n.argument.kind === 178 /* LiteralType */ && + return n.kind === 181 /* ImportType */ && + n.argument.kind === 180 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 /* ExpressionStatement */ + return node.kind === 219 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -8340,9 +8370,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 /* Parameter */ || node.kind === 148 /* TypeParameter */ || - node.kind === 192 /* FunctionExpression */ || - node.kind === 193 /* ArrowFunction */ || - node.kind === 191 /* ParenthesizedExpression */) ? + node.kind === 194 /* FunctionExpression */ || + node.kind === 195 /* ArrowFunction */ || + node.kind === 193 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -8358,7 +8388,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -8372,11 +8402,11 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 196 /* VoidExpression */; - case 207 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 198 /* VoidExpression */; + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148 /* TypeParameter */: - return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; + return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: @@ -8384,20 +8414,20 @@ var ts; if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 187 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 185 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through case 146 /* QualifiedName */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: { var parent = node.parent; if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 179 /* ImportType */) { + if (parent.kind === 181 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8406,22 +8436,22 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148 /* TypeParameter */: return node === parent.constraint; case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return node === parent.type; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -8432,12 +8462,12 @@ var ts; case 159 /* ConstructSignature */: case 160 /* IndexSignature */: return node === parent.type; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return node === parent.type; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8462,23 +8492,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitor(node); - case 241 /* CaseBlock */: - case 213 /* Block */: - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 226 /* WithStatement */: - case 227 /* SwitchStatement */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 228 /* LabeledStatement */: - case 230 /* TryStatement */: - case 269 /* CatchClause */: + case 244 /* CaseBlock */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8488,19 +8518,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -8543,12 +8573,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 166 /* TypeLiteral */: return node.members; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.properties; } } @@ -8556,14 +8586,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182 /* BindingElement */: - case 273 /* EnumMember */: + case 184 /* BindingElement */: + case 276 /* EnumMember */: case 149 /* Parameter */: - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 271 /* ShorthandPropertyAssignment */: - case 232 /* VariableDeclaration */: + case 274 /* ShorthandPropertyAssignment */: + case 235 /* VariableDeclaration */: return true; } } @@ -8575,12 +8605,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 /* VariableDeclarationList */ - && node.parent.parent.kind === 214 /* VariableStatement */; + return node.parent.kind === 236 /* VariableDeclarationList */ + && node.parent.parent.kind === 217 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -8592,8 +8622,8 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return true; } return false; @@ -8604,7 +8634,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228 /* LabeledStatement */) { + if (node.statement.kind !== 231 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -8612,17 +8642,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 184 /* ObjectLiteralExpression */ || - node.parent.kind === 205 /* ClassExpression */); + (node.parent.kind === 186 /* ObjectLiteralExpression */ || + node.parent.kind === 207 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8635,7 +8665,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270 /* PropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -8672,7 +8702,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274 /* SourceFile */); + ts.Debug.assert(node.kind !== 277 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -8707,14 +8737,14 @@ var ts; node = node.parent; } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 239 /* ModuleDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 242 /* ModuleDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 154 /* MethodDeclaration */: @@ -8725,8 +8755,8 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 238 /* EnumDeclaration */: - case 274 /* SourceFile */: + case 241 /* EnumDeclaration */: + case 277 /* SourceFile */: return node; } } @@ -8737,8 +8767,8 @@ var ts; if (container) { switch (container.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return container; } } @@ -8763,9 +8793,9 @@ var ts; case 147 /* ComputedPropertyName */: node = node.parent; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!stopOnFunctions) { continue; } @@ -8796,14 +8826,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { + if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 191 /* ParenthesizedExpression */) { + while (parent.kind === 193 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -8814,7 +8844,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -8823,7 +8853,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -8831,7 +8861,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -8844,10 +8874,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return node.tag; - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -8856,25 +8886,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // classes are valid targets return true; case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 235 /* ClassDeclaration */; + return parent.kind === 238 /* ClassDeclaration */; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 154 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 235 /* ClassDeclaration */; + && parent.kind === 238 /* ClassDeclaration */; case 149 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined && (parent.kind === 155 /* Constructor */ || parent.kind === 154 /* MethodDeclaration */ || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 235 /* ClassDeclaration */; + && grandparent.kind === 238 /* ClassDeclaration */; } return false; } @@ -8890,7 +8920,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 case 154 /* MethodDeclaration */: case 157 /* SetAccessor */: @@ -8902,9 +8932,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 /* JsxOpeningElement */ || - parent.kind === 256 /* JsxSelfClosingElement */ || - parent.kind === 258 /* JsxClosingElement */) { + if (parent.kind === 260 /* JsxOpeningElement */ || + parent.kind === 259 /* JsxSelfClosingElement */ || + parent.kind === 261 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -8917,37 +8947,37 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: - case 208 /* AsExpression */: - case 190 /* TypeAssertionExpression */: - case 209 /* NonNullExpression */: - case 191 /* ParenthesizedExpression */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: - case 193 /* ArrowFunction */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 204 /* SpreadElement */: - case 202 /* TemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: + case 210 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 211 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 206 /* SpreadElement */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 206 /* OmittedExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 203 /* YieldExpression */: - case 197 /* AwaitExpression */: - case 210 /* MetaProperty */: + case 208 /* OmittedExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 205 /* YieldExpression */: + case 199 /* AwaitExpression */: + case 212 /* MetaProperty */: return true; case 146 /* QualifiedName */: while (node.parent.kind === 146 /* QualifiedName */) { @@ -8971,47 +9001,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 182 /* BindingElement */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 184 /* BindingElement */: return parent.initializer === node; - case 216 /* ExpressionStatement */: - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 225 /* ReturnStatement */: - case 226 /* WithStatement */: - case 227 /* SwitchStatement */: - case 266 /* CaseClause */: - case 229 /* ThrowStatement */: + case 219 /* ExpressionStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 228 /* ReturnStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 232 /* ThrowStatement */: return parent.expression === node; - case 220 /* ForStatement */: + case 223 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forInStatement.expression === node; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return node === parent.expression; - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return node === parent.expression; case 147 /* ComputedPropertyName */: return node === parent.expression; case 150 /* Decorator */: - case 265 /* JsxExpression */: - case 264 /* JsxSpreadAttribute */: - case 272 /* SpreadAssignment */: + case 268 /* JsxExpression */: + case 267 /* JsxSpreadAttribute */: + case 275 /* SpreadAssignment */: return true; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -9019,7 +9049,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9028,7 +9058,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -9060,7 +9090,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187 /* CallExpression */) { + if (callExpression.kind !== 189 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -9156,11 +9186,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 192 /* FunctionExpression */ || - initializer.kind === 205 /* ClassExpression */ || - initializer.kind === 193 /* ArrowFunction */) { + if (initializer.kind === 194 /* FunctionExpression */ || + initializer.kind === 207 /* ClassExpression */ || + initializer.kind === 195 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9229,7 +9259,7 @@ var ts; return false; } function getRightMostAssignedExpression(node) { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -9252,6 +9282,14 @@ var ts; return 0 /* None */; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + // F.prototype = { ... } + return 6 /* Prototype */; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } @@ -9260,11 +9298,7 @@ var ts; return 2 /* ModuleExports */; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - // F.prototype = { ... } - return 6 /* Prototype */; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } @@ -9284,7 +9318,7 @@ var ts; } return 0 /* None */; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -9298,7 +9332,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9308,14 +9342,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.parent; - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return node.parent.parent; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return node.parent; - case 178 /* LiteralType */: + case 180 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9325,12 +9359,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.moduleSpecifier; - case 243 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 179 /* ImportType */: + case 246 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 181 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9339,11 +9373,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9351,7 +9385,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -9360,8 +9394,8 @@ var ts; case 149 /* Parameter */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 271 /* ShorthandPropertyAssignment */: - case 270 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return node.questionToken !== undefined; @@ -9371,14 +9405,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 /* JSDocFunctionType */ && + return node.kind === 287 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 301 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9403,12 +9437,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152 /* PropertyDeclaration */: return node.initializer; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return node.initializer; } } @@ -9418,59 +9452,57 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 /* ModuleDeclaration */ + node.body.kind === 242 /* ModuleDeclaration */ ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - if (parent.kind === 270 /* PropertyAssignment */ || parent.kind === 152 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { - getJSDocCommentsAndTagsWorker(parent); - } - // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } + // Pull parameter comments from declaring function as well + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); } - // Pull parameter comments from declaring function as well if (node.kind === 149 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; } - if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { - result = ts.addRange(result, node.initializer.jsDoc); - } - if (ts.hasJSDocNodes(node)) { - result = ts.addRange(result, node.jsDoc); - } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 /* PropertyAssignment */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + return parent; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -9519,7 +9551,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9532,31 +9564,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 191 /* ParenthesizedExpression */: - case 183 /* ArrayLiteralExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 185 /* ArrayLiteralExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: node = parent; break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -9583,22 +9615,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 213 /* Block */: - case 214 /* VariableStatement */: - case 226 /* WithStatement */: - case 217 /* IfStatement */: - case 227 /* SwitchStatement */: - case 241 /* CaseBlock */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 228 /* LabeledStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 230 /* TryStatement */: - case 269 /* CatchClause */: + case 216 /* Block */: + case 217 /* VariableStatement */: + case 229 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return true; } return false; @@ -9615,15 +9647,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173 /* ParenthesizedType */); + return walkUp(node, 175 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191 /* ParenthesizedExpression */); + return walkUp(node, 193 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */) { + while (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -9631,11 +9663,11 @@ var ts; ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194 /* DeleteExpression */; + return node && node.kind === 196 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9692,9 +9724,9 @@ var ts; case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 185 /* PropertyAccessExpression */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 187 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; case 146 /* QualifiedName */: @@ -9706,12 +9738,12 @@ var ts; return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 182 /* BindingElement */: - case 248 /* ImportSpecifier */: + case 184 /* BindingElement */: + case 251 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 252 /* ExportSpecifier */: - case 262 /* JsxAttribute */: + case 255 /* ExportSpecifier */: + case 265 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -9727,13 +9759,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ || - node.kind === 242 /* NamespaceExportDeclaration */ || - node.kind === 245 /* ImportClause */ && !!node.name || - node.kind === 246 /* NamespaceImport */ || - node.kind === 248 /* ImportSpecifier */ || - node.kind === 252 /* ExportSpecifier */ || - node.kind === 249 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 245 /* NamespaceExportDeclaration */ || + node.kind === 248 /* ImportClause */ && !!node.name || + node.kind === 249 /* NamespaceImport */ || + node.kind === 251 /* ImportSpecifier */ || + node.kind === 255 /* ExportSpecifier */ || + node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9742,11 +9774,22 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + // Prefer an @augments tag because it may have type parameters. + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; @@ -9755,7 +9798,7 @@ var ts; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -9828,14 +9871,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -9849,9 +9892,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined @@ -9957,7 +10000,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182 /* BindingElement */) { + while (node.kind === 184 /* BindingElement */) { node = node.parent.parent; } return node; @@ -9966,14 +10009,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 /* Constructor */ - || kind === 192 /* FunctionExpression */ - || kind === 234 /* FunctionDeclaration */ - || kind === 193 /* ArrowFunction */ + || kind === 194 /* FunctionExpression */ + || kind === 237 /* FunctionDeclaration */ + || kind === 195 /* ArrowFunction */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ - || kind === 239 /* ModuleDeclaration */ - || kind === 274 /* SourceFile */; + || kind === 242 /* ModuleDeclaration */ + || kind === 277 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9992,23 +10035,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: return 1 /* Right */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -10032,15 +10075,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200 /* BinaryExpression */) { + if (expression.kind === 202 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { + else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10050,15 +10093,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return 0; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return 1; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return 2; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return 4; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -10079,21 +10122,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: return 16; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return 17; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return 18; - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 19 : 18; - case 189 /* TaggedTemplateExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 191 /* TaggedTemplateExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -10103,19 +10146,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 191 /* ParenthesizedExpression */: - case 206 /* OmittedExpression */: + case 204 /* TemplateExpression */: + case 193 /* ParenthesizedExpression */: + case 208 /* OmittedExpression */: return 20; default: return -1; @@ -10174,6 +10217,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -10181,6 +10225,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -10603,7 +10664,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); @@ -10615,7 +10676,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -10908,8 +10969,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 184 /* ObjectLiteralExpression */ - || kind === 183 /* ArrayLiteralExpression */; + return kind === 186 /* ObjectLiteralExpression */ + || kind === 185 /* ArrayLiteralExpression */; } return false; } @@ -10919,7 +10980,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */ + return node.kind === 209 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -10941,16 +11002,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); + (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 /* ObjectLiteralExpression */ && + return expression.kind === 186 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 /* ArrayLiteralExpression */ && + return expression.kind === 185 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11291,8 +11352,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11369,21 +11430,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && parent.parent.kind === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -11486,7 +11547,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -11556,6 +11617,11 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + /* @internal */ + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; // Returns true if 'span' contains 'other'. function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -11749,7 +11815,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { return current; } } @@ -11774,27 +11840,34 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232 /* VariableDeclaration */) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236 /* VariableDeclarationList */) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217 /* VariableStatement */) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags @@ -11804,19 +11877,7 @@ var ts; // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** @@ -11924,16 +11985,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -11950,17 +12001,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return expr.name; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11969,10 +12020,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 228 /* LabeledStatement */: { + case 231 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11984,7 +12035,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -11995,29 +12046,20 @@ var ts; return !!node.name; // A 'name' property should always be a DeclarationName. } ts.isNamedDeclaration = isNamedDeclaration; - // TODO: GH#18217 This is often used as if it returns a defined result - function getNameOfDeclaration(declaration) { - if (!declaration) { - return undefined; - } + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71 /* Identifier */: return declaration; - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: { + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -12029,17 +12071,22 @@ var ts; return undefined; } } - case 292 /* JSDocCallbackTag */: - return declaration.name; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -12328,545 +12375,545 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169 /* UnionType */; + return node.kind === 171 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170 /* IntersectionType */; + return node.kind === 172 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171 /* ConditionalType */; + return node.kind === 173 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172 /* InferType */; + return node.kind === 174 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173 /* ParenthesizedType */; + return node.kind === 175 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174 /* ThisType */; + return node.kind === 176 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175 /* TypeOperator */; + return node.kind === 177 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176 /* IndexedAccessType */; + return node.kind === 178 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177 /* MappedType */; + return node.kind === 179 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178 /* LiteralType */; + return node.kind === 180 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179 /* ImportType */; + return node.kind === 181 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 180 /* ObjectBindingPattern */; + return node.kind === 182 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181 /* ArrayBindingPattern */; + return node.kind === 183 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182 /* BindingElement */; + return node.kind === 184 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 183 /* ArrayLiteralExpression */; + return node.kind === 185 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184 /* ObjectLiteralExpression */; + return node.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185 /* PropertyAccessExpression */; + return node.kind === 187 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186 /* ElementAccessExpression */; + return node.kind === 188 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187 /* CallExpression */; + return node.kind === 189 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188 /* NewExpression */; + return node.kind === 190 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189 /* TaggedTemplateExpression */; + return node.kind === 191 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190 /* TypeAssertionExpression */; + return node.kind === 192 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191 /* ParenthesizedExpression */; + return node.kind === 193 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302 /* PartiallyEmittedExpression */) { + while (node.kind === 305 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192 /* FunctionExpression */; + return node.kind === 194 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193 /* ArrowFunction */; + return node.kind === 195 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194 /* DeleteExpression */; + return node.kind === 196 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195 /* TypeOfExpression */; + return node.kind === 197 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196 /* VoidExpression */; + return node.kind === 198 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197 /* AwaitExpression */; + return node.kind === 199 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198 /* PrefixUnaryExpression */; + return node.kind === 200 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199 /* PostfixUnaryExpression */; + return node.kind === 201 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200 /* BinaryExpression */; + return node.kind === 202 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201 /* ConditionalExpression */; + return node.kind === 203 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202 /* TemplateExpression */; + return node.kind === 204 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203 /* YieldExpression */; + return node.kind === 205 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204 /* SpreadElement */; + return node.kind === 206 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205 /* ClassExpression */; + return node.kind === 207 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206 /* OmittedExpression */; + return node.kind === 208 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208 /* AsExpression */; + return node.kind === 210 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209 /* NonNullExpression */; + return node.kind === 211 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210 /* MetaProperty */; + return node.kind === 212 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 211 /* TemplateSpan */; + return node.kind === 214 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212 /* SemicolonClassElement */; + return node.kind === 215 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 213 /* Block */; + return node.kind === 216 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214 /* VariableStatement */; + return node.kind === 217 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215 /* EmptyStatement */; + return node.kind === 218 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216 /* ExpressionStatement */; + return node.kind === 219 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217 /* IfStatement */; + return node.kind === 220 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218 /* DoStatement */; + return node.kind === 221 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219 /* WhileStatement */; + return node.kind === 222 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220 /* ForStatement */; + return node.kind === 223 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221 /* ForInStatement */; + return node.kind === 224 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222 /* ForOfStatement */; + return node.kind === 225 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223 /* ContinueStatement */; + return node.kind === 226 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224 /* BreakStatement */; + return node.kind === 227 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; + return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225 /* ReturnStatement */; + return node.kind === 228 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226 /* WithStatement */; + return node.kind === 229 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227 /* SwitchStatement */; + return node.kind === 230 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228 /* LabeledStatement */; + return node.kind === 231 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229 /* ThrowStatement */; + return node.kind === 232 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230 /* TryStatement */; + return node.kind === 233 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231 /* DebuggerStatement */; + return node.kind === 234 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232 /* VariableDeclaration */; + return node.kind === 235 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233 /* VariableDeclarationList */; + return node.kind === 236 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234 /* FunctionDeclaration */; + return node.kind === 237 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235 /* ClassDeclaration */; + return node.kind === 238 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236 /* InterfaceDeclaration */; + return node.kind === 239 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237 /* TypeAliasDeclaration */; + return node.kind === 240 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */; + return node.kind === 241 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */; + return node.kind === 242 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240 /* ModuleBlock */; + return node.kind === 243 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241 /* CaseBlock */; + return node.kind === 244 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242 /* NamespaceExportDeclaration */; + return node.kind === 245 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */; + return node.kind === 246 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244 /* ImportDeclaration */; + return node.kind === 247 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245 /* ImportClause */; + return node.kind === 248 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246 /* NamespaceImport */; + return node.kind === 249 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247 /* NamedImports */; + return node.kind === 250 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248 /* ImportSpecifier */; + return node.kind === 251 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249 /* ExportAssignment */; + return node.kind === 252 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250 /* ExportDeclaration */; + return node.kind === 253 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251 /* NamedExports */; + return node.kind === 254 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252 /* ExportSpecifier */; + return node.kind === 255 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253 /* MissingDeclaration */; + return node.kind === 256 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 254 /* ExternalModuleReference */; + return node.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 255 /* JsxElement */; + return node.kind === 258 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256 /* JsxSelfClosingElement */; + return node.kind === 259 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257 /* JsxOpeningElement */; + return node.kind === 260 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258 /* JsxClosingElement */; + return node.kind === 261 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259 /* JsxFragment */; + return node.kind === 262 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260 /* JsxOpeningFragment */; + return node.kind === 263 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261 /* JsxClosingFragment */; + return node.kind === 264 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262 /* JsxAttribute */; + return node.kind === 265 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263 /* JsxAttributes */; + return node.kind === 266 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264 /* JsxSpreadAttribute */; + return node.kind === 267 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265 /* JsxExpression */; + return node.kind === 268 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 266 /* CaseClause */; + return node.kind === 269 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267 /* DefaultClause */; + return node.kind === 270 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268 /* HeritageClause */; + return node.kind === 271 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269 /* CatchClause */; + return node.kind === 272 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 270 /* PropertyAssignment */; + return node.kind === 273 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271 /* ShorthandPropertyAssignment */; + return node.kind === 274 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272 /* SpreadAssignment */; + return node.kind === 275 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 274 /* SourceFile */; + return node.kind === 277 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275 /* Bundle */; + return node.kind === 278 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276 /* UnparsedSource */; + return node.kind === 279 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 278 /* JSDocTypeExpression */; + return node.kind === 281 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279 /* JSDocAllType */; + return node.kind === 282 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280 /* JSDocUnknownType */; + return node.kind === 283 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281 /* JSDocNullableType */; + return node.kind === 284 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282 /* JSDocNonNullableType */; + return node.kind === 285 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283 /* JSDocOptionalType */; + return node.kind === 286 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284 /* JSDocFunctionType */; + return node.kind === 287 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285 /* JSDocVariadicType */; + return node.kind === 288 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286 /* JSDocComment */; + return node.kind === 289 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290 /* JSDocAugmentsTag */; + return node.kind === 293 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291 /* JSDocClassTag */; + return node.kind === 294 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295 /* JSDocThisTag */; + return node.kind === 298 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293 /* JSDocParameterTag */; + return node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294 /* JSDocReturnTag */; + return node.kind === 297 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296 /* JSDocTypeTag */; + return node.kind === 299 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297 /* JSDocTemplateTag */; + return node.kind === 300 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298 /* JSDocTypedefTag */; + return node.kind === 301 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299 /* JSDocPropertyTag */; + return node.kind === 302 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; + return node.kind === 302 /* JSDocPropertyTag */ || node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287 /* JSDocTypeLiteral */; + return node.kind === 290 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288 /* JSDocSignature */; + return node.kind === 291 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -12877,7 +12924,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 300 /* SyntaxList */; + return n.kind === 303 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -12992,8 +13039,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 180 /* ObjectBindingPattern */ - || kind === 181 /* ArrayBindingPattern */; + || kind === 182 /* ObjectBindingPattern */ + || kind === 183 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13008,13 +13055,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; default: return false; @@ -13025,11 +13072,11 @@ var ts; switch (kind) { case 153 /* MethodSignature */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: case 164 /* ConstructorType */: return true; default: @@ -13051,11 +13098,11 @@ var ts; || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ || kind === 160 /* IndexSignature */ - || kind === 212 /* SemicolonClassElement */; + || kind === 215 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); + return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -13090,9 +13137,9 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 /* PropertyAssignment */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 272 /* SpreadAssignment */ + return kind === 273 /* PropertyAssignment */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 275 /* SpreadAssignment */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */; @@ -13100,7 +13147,7 @@ var ts; ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ @@ -13113,14 +13160,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 207 /* ExpressionWithTypeArguments */ - || kind === 279 /* JSDocAllType */ - || kind === 280 /* JSDocUnknownType */ - || kind === 281 /* JSDocNullableType */ - || kind === 282 /* JSDocNonNullableType */ - || kind === 283 /* JSDocOptionalType */ - || kind === 284 /* JSDocFunctionType */ - || kind === 285 /* JSDocVariadicType */; + || kind === 209 /* ExpressionWithTypeArguments */ + || kind === 282 /* JSDocAllType */ + || kind === 283 /* JSDocUnknownType */ + || kind === 284 /* JSDocNullableType */ + || kind === 285 /* JSDocNonNullableType */ + || kind === 286 /* JSDocOptionalType */ + || kind === 287 /* JSDocFunctionType */ + || kind === 288 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13145,8 +13192,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 /* ArrayBindingPattern */ - || kind === 180 /* ObjectBindingPattern */; + return kind === 183 /* ArrayBindingPattern */ + || kind === 182 /* ObjectBindingPattern */; } return false; } @@ -13154,15 +13201,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 /* ArrayLiteralExpression */ - || kind === 184 /* ObjectLiteralExpression */; + return kind === 185 /* ArrayLiteralExpression */ + || kind === 186 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 /* BindingElement */ - || kind === 206 /* OmittedExpression */; + return kind === 184 /* BindingElement */ + || kind === 208 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13171,9 +13218,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return true; } return false; @@ -13194,8 +13241,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return true; } return false; @@ -13207,8 +13254,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return true; } return false; @@ -13217,25 +13264,25 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */ - || kind === 179 /* ImportType */; + || kind === 181 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: case 150 /* Decorator */: return true; default: @@ -13244,12 +13291,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; + return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 /* TemplateExpression */ + return kind === 204 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13260,32 +13307,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: - case 188 /* NewExpression */: - case 187 /* CallExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 189 /* TaggedTemplateExpression */: - case 183 /* ArrayLiteralExpression */: - case 191 /* ParenthesizedExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 190 /* NewExpression */: + case 189 /* CallExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 191 /* TaggedTemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 193 /* ParenthesizedExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 209 /* NonNullExpression */: - case 210 /* MetaProperty */: + case 211 /* NonNullExpression */: + case 212 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13299,13 +13346,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 190 /* TypeAssertionExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 192 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13314,9 +13361,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -13335,15 +13382,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: - case 193 /* ArrowFunction */: - case 200 /* BinaryExpression */: - case 204 /* SpreadElement */: - case 208 /* AsExpression */: - case 206 /* OmittedExpression */: - case 303 /* CommaListExpression */: - case 302 /* PartiallyEmittedExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: + case 195 /* ArrowFunction */: + case 202 /* BinaryExpression */: + case 206 /* SpreadElement */: + case 210 /* AsExpression */: + case 208 /* OmittedExpression */: + case 306 /* CommaListExpression */: + case 305 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13351,18 +13398,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 /* TypeAssertionExpression */ - || kind === 208 /* AsExpression */; + return kind === 192 /* TypeAssertionExpression */ + || kind === 210 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 302 /* PartiallyEmittedExpression */; + return node.kind === 305 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 301 /* NotEmittedStatement */; + return node.kind === 304 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -13373,13 +13420,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return true; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13387,7 +13434,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; + return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13411,113 +13458,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */ + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */; + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 239 /* ModuleDeclaration */; + || kind === 242 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 /* NamedImports */ - || kind === 246 /* NamespaceImport */; + return kind === 250 /* NamedImports */ + || kind === 249 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; + return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 /* ArrowFunction */ - || kind === 182 /* BindingElement */ - || kind === 235 /* ClassDeclaration */ - || kind === 205 /* ClassExpression */ + return kind === 195 /* ArrowFunction */ + || kind === 184 /* BindingElement */ + || kind === 238 /* ClassDeclaration */ + || kind === 207 /* ClassExpression */ || kind === 155 /* Constructor */ - || kind === 238 /* EnumDeclaration */ - || kind === 273 /* EnumMember */ - || kind === 252 /* ExportSpecifier */ - || kind === 234 /* FunctionDeclaration */ - || kind === 192 /* FunctionExpression */ + || kind === 241 /* EnumDeclaration */ + || kind === 276 /* EnumMember */ + || kind === 255 /* ExportSpecifier */ + || kind === 237 /* FunctionDeclaration */ + || kind === 194 /* FunctionExpression */ || kind === 156 /* GetAccessor */ - || kind === 245 /* ImportClause */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 248 /* ImportSpecifier */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 262 /* JsxAttribute */ + || kind === 248 /* ImportClause */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 251 /* ImportSpecifier */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 265 /* JsxAttribute */ || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ - || kind === 239 /* ModuleDeclaration */ - || kind === 242 /* NamespaceExportDeclaration */ - || kind === 246 /* NamespaceImport */ + || kind === 242 /* ModuleDeclaration */ + || kind === 245 /* NamespaceExportDeclaration */ + || kind === 249 /* NamespaceImport */ || kind === 149 /* Parameter */ - || kind === 270 /* PropertyAssignment */ + || kind === 273 /* PropertyAssignment */ || kind === 152 /* PropertyDeclaration */ || kind === 151 /* PropertySignature */ || kind === 157 /* SetAccessor */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 237 /* TypeAliasDeclaration */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 240 /* TypeAliasDeclaration */ || kind === 148 /* TypeParameter */ - || kind === 232 /* VariableDeclaration */ - || kind === 298 /* JSDocTypedefTag */ - || kind === 292 /* JSDocCallbackTag */ - || kind === 299 /* JSDocPropertyTag */; + || kind === 235 /* VariableDeclaration */ + || kind === 301 /* JSDocTypedefTag */ + || kind === 295 /* JSDocCallbackTag */ + || kind === 302 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 234 /* FunctionDeclaration */ - || kind === 253 /* MissingDeclaration */ - || kind === 235 /* ClassDeclaration */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 237 /* TypeAliasDeclaration */ - || kind === 238 /* EnumDeclaration */ - || kind === 239 /* ModuleDeclaration */ - || kind === 244 /* ImportDeclaration */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 250 /* ExportDeclaration */ - || kind === 249 /* ExportAssignment */ - || kind === 242 /* NamespaceExportDeclaration */; + return kind === 237 /* FunctionDeclaration */ + || kind === 256 /* MissingDeclaration */ + || kind === 238 /* ClassDeclaration */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 240 /* TypeAliasDeclaration */ + || kind === 241 /* EnumDeclaration */ + || kind === 242 /* ModuleDeclaration */ + || kind === 247 /* ImportDeclaration */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 253 /* ExportDeclaration */ + || kind === 252 /* ExportAssignment */ + || kind === 245 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 224 /* BreakStatement */ - || kind === 223 /* ContinueStatement */ - || kind === 231 /* DebuggerStatement */ - || kind === 218 /* DoStatement */ - || kind === 216 /* ExpressionStatement */ - || kind === 215 /* EmptyStatement */ - || kind === 221 /* ForInStatement */ - || kind === 222 /* ForOfStatement */ - || kind === 220 /* ForStatement */ - || kind === 217 /* IfStatement */ - || kind === 228 /* LabeledStatement */ - || kind === 225 /* ReturnStatement */ - || kind === 227 /* SwitchStatement */ - || kind === 229 /* ThrowStatement */ - || kind === 230 /* TryStatement */ - || kind === 214 /* VariableStatement */ - || kind === 219 /* WhileStatement */ - || kind === 226 /* WithStatement */ - || kind === 301 /* NotEmittedStatement */ - || kind === 305 /* EndOfDeclarationMarker */ - || kind === 304 /* MergeDeclarationMarker */; + return kind === 227 /* BreakStatement */ + || kind === 226 /* ContinueStatement */ + || kind === 234 /* DebuggerStatement */ + || kind === 221 /* DoStatement */ + || kind === 219 /* ExpressionStatement */ + || kind === 218 /* EmptyStatement */ + || kind === 224 /* ForInStatement */ + || kind === 225 /* ForOfStatement */ + || kind === 223 /* ForStatement */ + || kind === 220 /* IfStatement */ + || kind === 231 /* LabeledStatement */ + || kind === 228 /* ReturnStatement */ + || kind === 230 /* SwitchStatement */ + || kind === 232 /* ThrowStatement */ + || kind === 233 /* TryStatement */ + || kind === 217 /* VariableStatement */ + || kind === 222 /* WhileStatement */ + || kind === 229 /* WithStatement */ + || kind === 304 /* NotEmittedStatement */ + || kind === 308 /* EndOfDeclarationMarker */ + || kind === 307 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 297 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -13544,10 +13591,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213 /* Block */) + if (node.kind !== 216 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { + if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { return false; } } @@ -13557,7 +13604,7 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 254 /* ExternalModuleReference */ + return kind === 257 /* ExternalModuleReference */ || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } @@ -13568,62 +13615,62 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 185 /* PropertyAccessExpression */; + || kind === 187 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 255 /* JsxElement */ - || kind === 265 /* JsxExpression */ - || kind === 256 /* JsxSelfClosingElement */ + return kind === 258 /* JsxElement */ + || kind === 268 /* JsxExpression */ + || kind === 259 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 259 /* JsxFragment */; + || kind === 262 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 /* JsxAttribute */ - || kind === 264 /* JsxSpreadAttribute */; + return kind === 265 /* JsxAttribute */ + || kind === 267 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 265 /* JsxExpression */; + || kind === 268 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 /* JsxOpeningElement */ - || kind === 256 /* JsxSelfClosingElement */; + return kind === 260 /* JsxOpeningElement */ + || kind === 259 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 /* CaseClause */ - || kind === 267 /* DefaultClause */; + return kind === 269 /* CaseClause */ + || kind === 270 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 299 /* LastJSDocNode */; + return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 302 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 289 /* FirstJSDocTagNode */ && node.kind <= 299 /* LastJSDocTagNode */; + return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 302 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -13666,22 +13713,22 @@ var ts; case 161 /* TypePredicate */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: - case 177 /* MappedType */: - case 190 /* TypeAssertionExpression */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 208 /* AsExpression */: - case 232 /* VariableDeclaration */: - case 234 /* FunctionDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 278 /* JSDocTypeExpression */: - case 281 /* JSDocNullableType */: - case 282 /* JSDocNonNullableType */: - case 283 /* JSDocOptionalType */: - case 284 /* JSDocFunctionType */: - case 285 /* JSDocVariadicType */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: + case 179 /* MappedType */: + case 192 /* TypeAssertionExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 210 /* AsExpression */: + case 235 /* VariableDeclaration */: + case 237 /* FunctionDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 281 /* JSDocTypeExpression */: + case 284 /* JSDocNullableType */: + case 285 /* JSDocNonNullableType */: + case 286 /* JSDocOptionalType */: + case 287 /* JSDocFunctionType */: + case 288 /* JSDocVariadicType */: return true; } return false; @@ -13701,10 +13748,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -13716,7 +13763,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13753,7 +13800,7 @@ var ts; (function (ts) { /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; + return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -13894,6 +13941,13 @@ var ts; } /* @internal */ function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + /* @internal */ + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -13901,7 +13955,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; + } + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -14444,17 +14510,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.tryRemovePrefix(path, dirPath); - if (a === undefined) - return undefined; - switch (a.charCodeAt(0)) { - case 47 /* slash */: - case 92 /* backslash */: - return a.slice(1); - default: - return undefined; - } + function isDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; // Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. @@ -15007,7 +15071,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 274 /* SourceFile */) { + if (kind === 277 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -15071,14 +15135,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -15103,20 +15167,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15138,9 +15202,9 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15165,290 +15229,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172 /* InferType */: + case 174 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 179 /* ImportType */: + case 181 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: return visitNode(cbNode, node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177 /* MappedType */: + case 179 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return visitNode(cbNode, node.literal); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitNode(cbNode, node.name); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return visitNode(cbNode, node.label); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 278 /* JSDocTypeExpression */: - return visitNode(cbNode, node.type); - case 282 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 281 /* JSDocNullableType */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 281 /* JSDocTypeExpression */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 286 /* JSDocOptionalType */: + case 288 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 283 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 286 /* JSDocComment */: + case 289 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15457,17 +15519,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 278 /* JSDocTypeExpression */) { + node.typeExpression.kind === 281 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15475,18 +15537,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292 /* JSDocCallbackTag */: + case 295 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295 /* JSDocThisTag */: + case 298 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 287 /* JSDocTypeLiteral */: + case 290 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15494,7 +15556,7 @@ var ts; } } return; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15708,7 +15770,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216 /* ExpressionStatement */); + var statement = createNode(219 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15825,13 +15887,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); // Should only be called once per node + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -15867,7 +15926,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // 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(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16674,7 +16733,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 152 /* PropertyDeclaration */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return true; case 154 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -16691,8 +16750,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: return true; } } @@ -16701,42 +16760,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 214 /* VariableStatement */: - case 213 /* Block */: - case 217 /* IfStatement */: - case 216 /* ExpressionStatement */: - case 229 /* ThrowStatement */: - case 225 /* ReturnStatement */: - case 227 /* SwitchStatement */: - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 215 /* EmptyStatement */: - case 230 /* TryStatement */: - case 228 /* LabeledStatement */: - case 218 /* DoStatement */: - case 231 /* DebuggerStatement */: - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 217 /* VariableStatement */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 219 /* ExpressionStatement */: + case 232 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 230 /* SwitchStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 218 /* EmptyStatement */: + case 233 /* TryStatement */: + case 231 /* LabeledStatement */: + case 221 /* DoStatement */: + case 234 /* DebuggerStatement */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -16752,7 +16811,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232 /* VariableDeclaration */) { + if (node.kind !== 235 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16878,7 +16937,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -16940,7 +17004,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202 /* TemplateExpression */); + var template = createNode(204 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -16952,7 +17016,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211 /* TemplateSpan */); + var span = createNode(214 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -17018,10 +17082,9 @@ var ts; case 163 /* FunctionType */: case 164 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17035,14 +17098,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174 /* ThisType */); + var node = createNode(176 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279 /* JSDocAllType */); + var result = createNode(282 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, result); + return createPostfixType(286 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17050,7 +17113,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282 /* JSDocNonNullableType */); + var result = createNode(285 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17074,18 +17137,18 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(280 /* JSDocUnknownType */, pos); + var result = createNode(283 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(281 /* JSDocNullableType */, pos); + var result = createNode(284 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -17107,12 +17170,12 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, type); + return createPostfixType(286 /* JSDocOptionalType */, type); } return type; } @@ -17452,7 +17515,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177 /* MappedType */); + var node = createNode(179 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17474,13 +17537,26 @@ var ts; parseExpected(18 /* CloseBraceToken */); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24 /* DotDotDotToken */)) { + var node = createNode(170 /* RestType */, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 169 /* OptionalType */; + } + return type; + } function parseTupleType() { var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173 /* ParenthesizedType */); + var node = createNode(175 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); parseExpected(20 /* CloseParenToken */); @@ -17498,10 +17574,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178 /* LiteralType */); + var node = createNode(180 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17522,7 +17598,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(179 /* ImportType */); + var node = createNode(181 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17648,19 +17724,19 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); + type = createPostfixType(285 /* JSDocNonNullableType */, type); break; case 55 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(281 /* JSDocNullableType */, type); + type = createPostfixType(284 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(176 /* IndexedAccessType */, type.pos); + var node = createNode(178 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); @@ -17679,21 +17755,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175 /* TypeOperator */); + var node = createNode(177 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172 /* InferType */); + var node = createNode(174 /* InferType */); parseExpected(126 /* InferKeyword */); var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); @@ -17726,10 +17802,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17813,7 +17889,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(171 /* ConditionalType */, type.pos); + var node = createNode(173 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -18006,7 +18082,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203 /* YieldExpression */); + var node = createNode(205 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -18028,11 +18104,11 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193 /* ArrowFunction */, asyncModifier.pos); + node = createNode(195 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193 /* ArrowFunction */, identifier.pos); + node = createNode(195 /* ArrowFunction */, identifier.pos); } var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; @@ -18230,7 +18306,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193 /* ArrowFunction */); + var node = createNodeWithJSDoc(195 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18294,7 +18370,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(201 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18374,39 +18450,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200 /* BinaryExpression */, left.pos); + var node = createNode(202 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208 /* AsExpression */, left.pos); + var node = createNode(210 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194 /* DeleteExpression */); + var node = createNode(196 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195 /* TypeOfExpression */); + var node = createNode(197 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196 /* VoidExpression */); + var node = createNode(198 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18422,7 +18498,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197 /* AwaitExpression */); + var node = createNode(199 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18466,7 +18542,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { parseErrorAt(pos, end, 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 { @@ -18563,7 +18639,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18576,7 +18652,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18632,7 +18708,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(210 /* MetaProperty */, fullStart); + var node = createNode(212 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18707,7 +18783,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(185 /* PropertyAccessExpression */, expression.pos); + var node = createNode(187 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -18716,8 +18792,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257 /* JsxOpeningElement */) { - var node = createNode(255 /* JsxElement */, opening.pos); + if (opening.kind === 260 /* JsxOpeningElement */) { + var node = createNode(258 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18726,15 +18802,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260 /* JsxOpeningFragment */) { - var node = createNode(259 /* JsxFragment */, opening.pos); + else if (opening.kind === 263 /* JsxOpeningFragment */) { + var node = createNode(262 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18749,7 +18825,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(200 /* BinaryExpression */, result.pos); + var badNode = createNode(202 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -18807,7 +18883,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263 /* JsxAttributes */); + var jsxAttributes = createNode(266 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18816,7 +18892,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18828,7 +18904,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(257 /* JsxOpeningElement */, fullStart); + node = createNode(260 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18840,7 +18916,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(256 /* JsxSelfClosingElement */, fullStart); + node = createNode(259 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18857,7 +18933,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18865,7 +18941,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265 /* JsxExpression */); + var node = createNode(268 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18887,7 +18963,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262 /* JsxAttribute */); + var node = createNode(265 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18902,7 +18978,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264 /* JsxSpreadAttribute */); + var node = createNode(267 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18910,7 +18986,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258 /* JsxClosingElement */); + var node = createNode(261 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18923,7 +18999,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261 /* JsxClosingFragment */); + var node = createNode(264 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18938,7 +19014,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190 /* TypeAssertionExpression */); + var node = createNode(192 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18949,7 +19025,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18957,14 +19033,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(211 /* 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(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(186 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -18991,7 +19067,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -19015,7 +19091,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -19023,7 +19099,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19135,28 +19211,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204 /* SpreadElement */); + var node = createNode(206 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183 /* ArrayLiteralExpression */); + var node = createNode(185 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19168,7 +19244,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 272 /* SpreadAssignment */; + node.kind = 275 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19195,7 +19271,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - node.kind = 271 /* ShorthandPropertyAssignment */; + node.kind = 274 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -19203,14 +19279,14 @@ var ts; } } else { - node.kind = 270 /* PropertyAssignment */; + node.kind = 273 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184 /* ObjectLiteralExpression */); + var node = createNode(186 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19229,7 +19305,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(192 /* FunctionExpression */); + var node = createNodeWithJSDoc(194 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19254,7 +19330,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(210 /* MetaProperty */, fullStart); + var node_2 = createNode(212 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19271,7 +19347,7 @@ var ts; } break; } - var node = createNode(188 /* NewExpression */, fullStart); + var node = createNode(190 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19281,7 +19357,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213 /* Block */); + var node = createNode(216 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19314,12 +19390,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215 /* EmptyStatement */); + var node = createNode(218 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(217 /* IfStatement */); + var node = createNode(220 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19329,7 +19405,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218 /* DoStatement */); + var node = createNode(221 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19344,7 +19420,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219 /* WhileStatement */); + var node = createNode(222 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19368,7 +19444,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(222 /* ForOfStatement */, pos); + var forOfStatement = createNode(225 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19376,14 +19452,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(221 /* ForInStatement */, pos); + var forInStatement = createNode(224 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220 /* ForStatement */, pos); + var forStatement = createNode(223 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19401,7 +19477,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19409,7 +19485,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225 /* ReturnStatement */); + var node = createNode(228 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19418,7 +19494,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226 /* WithStatement */); + var node = createNode(229 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19427,7 +19503,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266 /* CaseClause */); + var node = createNode(269 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19435,7 +19511,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267 /* DefaultClause */); + var node = createNode(270 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19445,12 +19521,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227 /* SwitchStatement */); + var node = createNode(230 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(241 /* CaseBlock */); + var caseBlock = createNode(244 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19465,7 +19541,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(229 /* ThrowStatement */); + var node = createNode(232 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19473,7 +19549,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(230 /* TryStatement */); + var node = createNode(233 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19486,7 +19562,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269 /* CatchClause */); + var result = createNode(272 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19500,7 +19576,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231 /* DebuggerStatement */); + var node = createNode(234 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19512,12 +19588,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 228 /* LabeledStatement */; + node.kind = 231 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216 /* ExpressionStatement */; + node.kind = 219 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19684,16 +19760,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19703,9 +19779,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(223 /* ContinueStatement */); + return parseBreakOrContinueStatement(226 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(224 /* BreakStatement */); + return parseBreakOrContinueStatement(227 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19802,7 +19878,7 @@ var ts; if (node.decorators || node.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 missing = createMissingNode(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -19825,16 +19901,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(206 /* OmittedExpression */); + return createNode(208 /* OmittedExpression */); } - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19850,14 +19926,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180 /* ObjectBindingPattern */); + var node = createNode(182 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181 /* ArrayBindingPattern */); + var node = createNode(183 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19879,7 +19955,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232 /* VariableDeclaration */); + var node = createNode(235 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19892,7 +19968,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233 /* VariableDeclarationList */); + var node = createNode(236 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19930,13 +20006,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 214 /* VariableStatement */; + node.kind = 217 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234 /* FunctionDeclaration */; + node.kind = 237 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -20118,7 +20194,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(212 /* SemicolonClassElement */); + var result = createNode(215 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -20155,10 +20231,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -20201,14 +20277,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(268 /* HeritageClause */); + var node = createNode(271 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -20225,7 +20301,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236 /* InterfaceDeclaration */; + node.kind = 239 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20234,7 +20310,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237 /* TypeAliasDeclaration */; + node.kind = 240 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20248,13 +20324,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 = createNodeWithJSDoc(273 /* EnumMember */); + var node = createNodeWithJSDoc(276 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238 /* EnumDeclaration */; + node.kind = 241 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20267,7 +20343,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240 /* ModuleBlock */); + var node = createNode(243 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20278,7 +20354,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; // 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 */; @@ -20290,7 +20366,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -20336,7 +20412,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 242 /* NamespaceExportDeclaration */; + node.kind = 245 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20354,7 +20430,7 @@ var ts; } } // Import statement - node.kind = 244 /* ImportDeclaration */; + node.kind = 247 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20369,7 +20445,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243 /* ImportEqualsDeclaration */; + node.kind = 246 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20383,7 +20459,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(245 /* ImportClause */, fullStart); + var importClause = createNode(248 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20393,7 +20469,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); } return finishNode(importClause); } @@ -20403,7 +20479,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(254 /* ExternalModuleReference */); + var node = createNode(257 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20426,7 +20502,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(246 /* NamespaceImport */); + var namespaceImport = createNode(249 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20441,14 +20517,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252 /* ExportSpecifier */); + return parseImportOrExportSpecifier(255 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248 /* ImportSpecifier */); + return parseImportOrExportSpecifier(251 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20473,19 +20549,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250 /* ExportDeclaration */; + node.kind = 253 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(254 /* 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. @@ -20498,7 +20574,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249 /* ExportAssignment */; + node.kind = 252 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20518,10 +20594,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ - || node.kind === 244 /* ImportDeclaration */ - || node.kind === 249 /* ExportAssignment */ - || node.kind === 250 /* ExportDeclaration */ + || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ + || node.kind === 247 /* ImportDeclaration */ + || node.kind === 252 /* ExportAssignment */ + || node.kind === 253 /* ExportDeclaration */ ? node : undefined; } @@ -20584,7 +20660,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20644,17 +20720,16 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var state = 1 /* SawAsterisk */; @@ -20740,9 +20815,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -20754,7 +20828,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286 /* JSDocComment */, start); + var result = createNode(289 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20871,6 +20945,16 @@ var ts; indent += whitespace.length; } break; + case 17 /* OpenBraceToken */: + state = 2 /* SavingComments */; + if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token @@ -20892,7 +20976,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289 /* JSDocTag */, atToken.pos); + var result = createNode(292 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20952,8 +21036,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(299 /* JSDocPropertyTag */, atToken.pos) : - createNode(293 /* JSDocParameterTag */, atToken.pos); + createNode(302 /* JSDocPropertyTag */, atToken.pos) : + createNode(296 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -20973,18 +21057,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 293 /* JSDocParameterTag */ || child.kind === 299 /* JSDocPropertyTag */) { + if (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -20995,27 +21079,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocReturnTag */, atToken.pos); + var result = createNode(297 /* 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 === 296 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296 /* JSDocTypeTag */, atToken.pos); + var result = createNode(299 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -21023,7 +21107,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -21035,7 +21119,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(185 /* PropertyAccessExpression */, node.pos); + var prop = createNode(187 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -21043,13 +21127,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291 /* JSDocClassTag */, atToken.pos); + var tag = createNode(294 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295 /* JSDocThisTag */, atToken.pos); + var tag = createNode(298 /* JSDocThisTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); @@ -21059,7 +21143,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(301 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21075,9 +21159,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 296 /* JSDocTypeTag */) { + if (child.kind === 299 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21109,7 +21193,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21123,7 +21207,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21132,7 +21216,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288 /* JSDocSignature */, start); + var jsdocSignature = createNode(291 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -21140,7 +21224,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 294 /* JSDocReturnTag */) { + if (tag && tag.kind === 297 /* JSDocReturnTag */) { return tag; } } @@ -21185,9 +21269,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 /* JSDocParameterTag */ && + if (child && (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -21261,7 +21345,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(300 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22065,6 +22149,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -23234,7 +23319,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 270 /* PropertyAssignment */) { + if (element.kind !== 273 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -23311,13 +23396,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -23334,7 +23419,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25422,24 +25507,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 238 /* EnumDeclaration */: - if (ts.isConst(node)) { + case 241 /* EnumDeclaration */: + if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 240 /* ModuleBlock */: { + case 243 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -25461,7 +25546,7 @@ var ts; }); return state_1; } - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -25620,7 +25705,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -25645,32 +25730,32 @@ var ts; return "__constructor" /* Constructor */; case 163 /* FunctionType */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return "__call" /* Call */; case 164 /* ConstructorType */: case 159 /* ConstructSignature */: return "__new" /* New */; case 160 /* IndexSignature */: return "__index" /* Index */; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 149 /* 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 === 284 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -25764,7 +25849,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 && - (node.kind === 249 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 252 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -25789,7 +25874,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -25856,7 +25941,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -25901,7 +25986,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -25950,8 +26035,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -25983,77 +26068,78 @@ var ts; return; } switch (node.kind) { - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: bindWhileStatement(node); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: bindDoStatement(node); break; - case 220 /* ForStatement */: + case 223 /* ForStatement */: bindForStatement(node); break; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: bindIfStatement(node); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: bindTryStatement(node); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: bindSwitchStatement(node); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: bindCaseBlock(node); break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: bindCaseClause(node); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: bindLabeledStatement(node); break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: bindCallExpressionFlow(node); break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 274 /* SourceFile */: + case 277 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213 /* Block */: - case 240 /* ModuleBlock */: + } + case 216 /* Block */: + case 243 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -26066,15 +26152,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return hasNarrowableArgument(expr); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -26083,7 +26169,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -26094,7 +26180,7 @@ var ts; } } } - if (expr.expression.kind === 185 /* PropertyAccessExpression */ && + if (expr.expression.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -26127,9 +26213,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -26207,33 +26293,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return parent.expression === node; - case 220 /* ForStatement */: - case 201 /* ConditionalExpression */: + case 223 /* ForStatement */: + case 203 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191 /* ParenthesizedExpression */) { + if (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 /* ParenthesizedExpression */ || - node.parent.kind === 198 /* PrefixUnaryExpression */ && + while (node.parent.kind === 193 /* ParenthesizedExpression */ || + node.parent.kind === 200 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -26275,7 +26361,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -26309,13 +26395,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222 /* ForOfStatement */) { + if (node.kind === 225 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233 /* VariableDeclarationList */) { + if (node.initializer.kind !== 236 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -26337,7 +26423,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225 /* ReturnStatement */) { + if (node.kind === 228 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -26357,7 +26443,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -26453,7 +26539,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* 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; @@ -26521,14 +26607,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -26539,10 +26625,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183 /* ArrayLiteralExpression */) { + else if (node.kind === 185 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204 /* SpreadElement */) { + if (e.kind === 206 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -26550,16 +26636,16 @@ var ts; } } } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270 /* PropertyAssignment */) { + if (p.kind === 273 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271 /* ShorthandPropertyAssignment */) { + else if (p.kind === 274 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272 /* SpreadAssignment */) { + else if (p.kind === 275 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -26615,7 +26701,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26626,7 +26712,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -26673,10 +26759,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 === 191 /* ParenthesizedExpression */) { + while (expr.kind === 193 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { + if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -26684,7 +26770,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26693,21 +26779,21 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 266 /* JsxAttributes */: return 1 /* IsContainer */; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 179 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -26715,32 +26801,32 @@ var ts; } // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: - case 284 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: case 163 /* FunctionType */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 269 /* CatchClause */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 241 /* CaseBlock */: + case 272 /* CatchClause */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 244 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 213 /* Block */: + case 216 /* 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 @@ -26773,20 +26859,20 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 184 /* ObjectLiteralExpression */: - case 236 /* InterfaceDeclaration */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 186 /* ObjectLiteralExpression */: + case 239 /* InterfaceDeclaration */: + case 266 /* 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 @@ -26797,21 +26883,21 @@ var ts; case 164 /* ConstructorType */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 160 /* IndexSignature */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 284 /* JSDocFunctionType */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 287 /* JSDocFunctionType */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 240 /* TypeAliasDeclaration */: + case 179 /* 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 @@ -26832,11 +26918,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { + var body = node.kind === 277 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { + if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { return true; } } @@ -26920,7 +27006,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -26932,7 +27018,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -26964,10 +27050,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -27108,8 +27194,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 274 /* SourceFile */ && - blockScopeContainer.kind !== 239 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 277 /* SourceFile */ && + blockScopeContainer.kind !== 242 /* 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. @@ -27205,7 +27291,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1 /* EndOfFileToken */) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -27263,11 +27353,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -27275,7 +27365,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -27303,19 +27393,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return checkStrictModeCatchClause(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkStrictModeWithStatement(node); - case 174 /* ThisType */: + case 176 /* ThisType */: seenThisKeyword = true; return; case 161 /* TypePredicate */: @@ -27324,18 +27414,18 @@ var ts; return bindTypeParameter(node); case 149 /* Parameter */: return bindParameter(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); case 158 /* CallSignature */: case 159 /* ConstructSignature */: @@ -27348,7 +27438,7 @@ var ts; // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 67208127 /* MethodExcludes */); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -27357,83 +27447,83 @@ var ts; case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 177 /* MappedType */: + case 290 /* JSDocTypeLiteral */: + case 179 /* MappedType */: return bindAnonymousTypeWorker(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return bindFunctionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return bindJsxAttributes(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return bindImportClause(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return bindExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return bindExportAssignment(node); - case 274 /* SourceFile */: + case 277 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213 /* Block */: + case 216 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 293 /* JSDocParameterTag */: - if (node.parent.kind === 288 /* JSDocSignature */) { + case 296 /* JSDocParameterTag */: + if (node.parent.kind === 291 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { break; } // falls through - case 299 /* JSDocPropertyTag */: + case 302 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -27465,7 +27555,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; ? 2097152 /* Alias */ // An export default clause with any other expression exports a value @@ -27479,7 +27569,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274 /* SourceFile */) { + if (node.parent.kind !== 277 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -27564,8 +27654,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -27592,7 +27682,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -27604,7 +27694,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -27661,9 +27751,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + : propertyAccess.parent.parent.kind === 277 /* SourceFile */; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; @@ -27757,7 +27847,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -27790,7 +27880,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); } @@ -27820,7 +27910,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { + if (node.kind === 296 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -27897,7 +27987,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 172 /* InferType */) { + else if (node.parent.kind === 174 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -27925,13 +28015,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || // report error on class declarations - node.kind === 235 /* ClassDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -27988,43 +28078,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); @@ -28035,11 +28125,11 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -28091,12 +28181,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* 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 === 58 /* EqualsToken */ && leftKind === 183 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -28145,8 +28235,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 === 208 /* AsExpression */ - || expressionKind === 190 /* TypeAssertionExpression */) { + if (expressionKind === 210 /* AsExpression */ + || expressionKind === 192 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -28523,13 +28613,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -28540,25 +28630,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 209 /* NonNullExpression */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 211 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: case 10 /* JsxText */: - case 258 /* JsxClosingElement */: - case 259 /* JsxFragment */: - case 260 /* JsxOpeningFragment */: - case 261 /* JsxClosingFragment */: - case 262 /* JsxAttribute */: - case 263 /* JsxAttributes */: - case 264 /* JsxSpreadAttribute */: - case 265 /* JsxExpression */: + case 261 /* JsxClosingElement */: + case 262 /* JsxFragment */: + case 263 /* JsxOpeningFragment */: + case 264 /* JsxClosingFragment */: + case 265 /* JsxAttribute */: + case 266 /* JsxAttributes */: + case 267 /* JsxSpreadAttribute */: + case 268 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -28566,11 +28656,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: - case 271 /* ShorthandPropertyAssignment */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 274 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -28584,14 +28674,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -28618,19 +28708,21 @@ var ts; case 166 /* TypeLiteral */: case 167 /* ArrayType */: case 168 /* TupleType */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 171 /* ConditionalType */: - case 172 /* InferType */: - case 173 /* ParenthesizedType */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 174 /* ThisType */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: - case 178 /* LiteralType */: - case 242 /* NamespaceExportDeclaration */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 174 /* InferType */: + case 175 /* ParenthesizedType */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: + case 245 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; @@ -28652,10 +28744,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -28667,18 +28759,18 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; @@ -28688,7 +28780,7 @@ var ts; // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -28706,8 +28798,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 183 /* ArrayLiteralExpression */: - case 188 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: + case 190 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -28715,26 +28807,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -28750,27 +28842,27 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 183 /* ArrayLiteralExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return 942011713 /* ClassExcludes */; case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; @@ -28792,24 +28884,24 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 269 /* CatchClause */: + case 272 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: - case 191 /* ParenthesizedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: + case 193 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -29098,6 +29190,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -29171,7 +29264,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -29269,6 +29361,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -29327,7 +29420,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -29384,6 +29477,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; /** @@ -29597,143 +29691,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); - }, - buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } - symbolToString(symbol, enclosingDeclaration, meaning, flags | 4 /* AllowAnyNodeKind */, emitTextWriterWrapper(writer)); - }, - buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildParameterDisplay: function (symbol, writer, enclosing, flags) { - var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { - var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 8192 /* OmitParameterModifiers */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896 /* TypeParameters */, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { - var printer = ts.createPrinter({ removeComments: true }); - var flags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */ | toNodeBuilderFlags(originalFlags); - var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; // TODO: GH#18217 - var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); // TODO: GH#18217 - printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForTypeParametersAndDelimiters: function (typeParameters, writer, enclosing, flags) { - var printer = ts.createPrinter({ removeComments: true }); - var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); // TODO: GH#18217 - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -29771,6 +29728,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -29896,22 +29878,57 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), 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 & 384 /* Enum */ || source.flags & 384 /* Enum */ + var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); + var isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 /* LessThan */ ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -29986,7 +30003,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -30044,17 +30061,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 182 /* BindingElement */) { + if (declaration.kind === 184 /* 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, 182 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 184 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || 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, 232 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235 /* VariableDeclaration */), usage); } - else if (declaration.kind === 232 /* VariableDeclaration */) { + else if (declaration.kind === 235 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -30072,12 +30089,12 @@ var ts; // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 249 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 252 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -30085,9 +30102,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214 /* VariableStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 217 /* VariableStatement */: + case 223 /* ForStatement */: + case 225 /* 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)) { @@ -30159,7 +30176,7 @@ 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 & 67901928 /* Type */ && lastLocation.kind !== 286 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -30179,7 +30196,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171 /* ConditionalType */) { + else if (location.kind === 173 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -30193,14 +30210,14 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 277 /* 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.get("default" /* Default */)) { @@ -30224,7 +30241,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { break; } } @@ -30238,7 +30255,7 @@ var ts; } } break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -30261,9 +30278,9 @@ var ts; } } break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -30279,7 +30296,7 @@ var ts; } break loop; } - if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -30287,7 +30304,7 @@ var ts; } } break; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -30309,7 +30326,7 @@ var ts; // case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -30322,14 +30339,14 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -30364,8 +30381,8 @@ var ts; location = location.parent; } break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -30384,7 +30401,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -30458,7 +30475,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67216319 /* Value */) === 67216319 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 242 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -30467,12 +30484,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 239 /* ModuleDeclaration */: // For `namespace N { N; }` + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -30540,9 +30557,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -30606,18 +30623,26 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238 /* EnumDeclaration */) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32 /* Class */) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256 /* RegularEnum */) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -30630,13 +30655,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 245 /* ImportClause */: + case 248 /* ImportClause */: return node.parent; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return node.parent.parent; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -30646,7 +30671,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -30834,20 +30859,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 249 /* ExportAssignment */: - case 200 /* BinaryExpression */: + case 252 /* ExportAssignment */: + case 202 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -30908,11 +30933,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 252 /* ExportSpecifier */) { + else if (node.kind === 255 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -30940,7 +30965,7 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -30964,7 +30989,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -31129,10 +31154,19 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages( + /*details*/ undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)) + : undefined; errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -31158,7 +31192,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -31391,6 +31425,12 @@ var ts; var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -31409,25 +31449,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -31443,12 +31477,12 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -31545,7 +31579,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -31657,10 +31691,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -31713,8 +31747,8 @@ var ts; // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || - entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || + entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -31796,64 +31830,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; // TODO: GH#18217 + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -31861,6 +31864,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -31978,7 +31983,7 @@ var ts; var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -32047,7 +32052,7 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -32085,7 +32090,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; + return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -32133,8 +32138,15 @@ var ts; } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -32348,7 +32360,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -32402,7 +32414,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -32410,7 +32422,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; - var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -32419,7 +32431,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; + var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -32429,7 +32442,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 182 /* BindingElement */) { + if (clone.kind === 184 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -32513,17 +32526,49 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + if (context.tracker.trackReferencedAmbientModule) { + var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); + if (ts.length(ambientDecls)) { + for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { + var decl = ambientDecls_1[_i]; + context.tracker.trackReferencedAmbientModule(decl, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= 16777216 /* InInitialEntityName */; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216 /* InInitialEntityName */; var isTypeOf = meaning === 67216319 /* Value */; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -32697,8 +32742,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173 /* ParenthesizedType */; }); - if (node.kind === 237 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); + if (node.kind === 240 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -32706,11 +32751,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 /* ModuleBlock */ && + node.parent.kind === 243 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -32730,42 +32775,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 - var file = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); - if (!file || !context.tracker.moduleResolverHost) { - if (context.tracker.trackReferencedAmbientModule) { - var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); - if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; - context.tracker.trackReferencedAmbientModule(decl); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205 /* ClassExpression */: - return "(Anonymous class)"; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - return "(Anonymous function)"; + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + context.encounteredError = true; + } + return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -32790,27 +32815,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 234 /* FunctionDeclaration */: - case 238 /* EnumDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 241 /* EnumDeclaration */: + case 246 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -32818,7 +32843,7 @@ var ts; 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 !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -32840,31 +32865,31 @@ var ts; case 158 /* CallSignature */: case 160 /* IndexSignature */: case 149 /* Parameter */: - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: case 162 /* TypeReference */: case 167 /* ArrayType */: case 168 /* TupleType */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 173 /* ParenthesizedType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 175 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: return false; // Type parameters are always visible case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 274 /* SourceFile */: - case 242 /* NamespaceExportDeclaration */: + case 277 /* SourceFile */: + case 245 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return false; default: return false; @@ -32873,10 +32898,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 252 /* ExportSpecifier */) { + else if (node.parent.kind === 255 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -32972,12 +32997,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232 /* VariableDeclaration */: - case 233 /* VariableDeclarationList */: - case 248 /* ImportSpecifier */: - case 247 /* NamedImports */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 235 /* VariableDeclaration */: + case 236 /* VariableDeclarationList */: + case 251 /* ImportSpecifier */: + case 250 /* NamedImports */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: return false; default: return true; @@ -33054,7 +33079,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180 /* ObjectBindingPattern */) { + if (pattern.kind === 182 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -33124,22 +33149,27 @@ var ts; // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); + // If the parent is a tuple type, the rest element has an array type with a union of the + // remaining tuple element types. Otherwise, the rest element has an array type with same + // element type as the parent type. + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -33150,7 +33180,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2 /* Subtype */) : type; } @@ -33167,7 +33197,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -33177,11 +33207,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* 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, @@ -33200,7 +33230,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // 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 @@ -33272,20 +33302,20 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : - declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : ts.getSpecialPropertyAssignmentKind(expression); if (special === 4 /* ThisProperty */) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. declarationInConstructor = thisContainer.kind === 155 /* Constructor */ || - thisContainer.kind === 234 /* FunctionDeclaration */ || - (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 /* FunctionDeclaration */ || + (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -33306,7 +33336,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { // If we don't have an explicit JSDoc type, get the type from the expression. var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 /* Anonymous */ && @@ -33388,7 +33418,7 @@ var ts; // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -33433,12 +33463,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } - // If the pattern has at least one element, and no rest element, then it should imply a tuple type. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -33455,7 +33486,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 /* ObjectBindingPattern */ + return pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -33524,7 +33555,7 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 249 /* ExportAssignment */) { + if (declaration.kind === 252 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -33728,8 +33759,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 202 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 187 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 202 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -33866,35 +33897,35 @@ var ts; return undefined; } switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 153 /* MethodSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 177 /* MappedType */: - case 171 /* ConditionalType */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 179 /* MappedType */: + case 173 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177 /* MappedType */) { + if (node.kind === 179 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171 /* ConditionalType */) { + else if (node.kind === 173 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && + (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -33902,7 +33933,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, 236 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -33911,9 +33942,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 235 /* ClassDeclaration */ || - node.kind === 205 /* ClassExpression */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || + node.kind === 207 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -33947,15 +33978,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - // Prefer an @augments tag because it may have type parameters. - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -33978,7 +34001,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -34011,7 +34034,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { if (type.symbol.flags & 32 /* Class */) { @@ -34074,7 +34097,7 @@ var ts; // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a // partial instantiation of the members without the base types fully resolved - type.members = undefined; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -34099,7 +34122,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -34135,7 +34158,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */) { + if (declaration.kind === 239 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -34193,7 +34216,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -34220,7 +34243,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 200 /* BinaryExpression */) { + else if (expr.kind === 202 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -34234,12 +34257,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 71 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -34253,7 +34276,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -34280,7 +34303,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 @@ -34370,7 +34393,7 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 178 /* LiteralType */: + case 180 /* LiteralType */: return true; case 167 /* ArrayType */: return isThislessType(node.elementType); @@ -34750,6 +34773,28 @@ var ts; return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 /* RestParameter */ : + i >= minLength_1 ? 4096 /* OptionalParameter */ : 0; + var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); @@ -34927,6 +34972,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); @@ -34935,6 +34981,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); @@ -35093,7 +35140,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 175 /* TypeOperator */ && + return constraintDeclaration.kind === 177 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -35213,6 +35260,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144 /* Union */)) { @@ -35670,10 +35728,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJavaScriptFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 283 /* JSDocOptionalType */ + node.type && node.type.kind === 286 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -35692,7 +35750,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -35707,7 +35765,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -35802,7 +35860,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178 /* LiteralType */) { + if (type && type.kind === 180 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -35850,9 +35908,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 8192 /* RestParameter */); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { // Replace the last parameter with a rest parameter. parameters.pop(); @@ -35958,9 +36015,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -36003,16 +36060,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1 /* Number */) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -36114,32 +36168,40 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - // When an 'infer T' declaration is immediately contained in a type reference node - // (such as 'Foo'), T's constraint is inferred from the constraint of the - // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are - // present, we form an intersection of the inferred constraint types. - if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - // Type parameter constraints can reference other type parameters so - // constraints need to be instantiated. If instantiation produces the - // type parameter itself, we discard that inference. For example, in - // type Foo = [T, U]; - // type Bar = T extends Foo ? Foo : T; - // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174 /* InferType */) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162 /* TypeReference */) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + // When an 'infer T' declaration is immediately contained in a rest parameter + // declaration, we infer an 'unknown[]' constraint. + else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -36234,7 +36296,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 290 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 293 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -36293,7 +36355,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -36386,9 +36448,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -36500,9 +36562,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return declaration; } } @@ -36623,18 +36685,26 @@ var ts; // // Note that the generic type created by this function has no symbol associated with it. The same // is true for each of the synthesized type parameters. - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536 /* TypeParameter */); - typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + if (i < maxLength) { + var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4 /* Property */, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; @@ -36652,21 +36722,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -37060,7 +37156,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -37125,7 +37221,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -37145,6 +37241,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { @@ -37155,7 +37257,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -37172,14 +37274,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } @@ -37285,7 +37395,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to 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 (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -37425,7 +37535,7 @@ var ts; return true; } while (node) { - if (node.kind === 171 /* ConditionalType */) { + if (node.kind === 173 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -37523,7 +37633,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } else { - error(node, targetMeaning === 67216319 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + var errorMessage = targetMeaning === 67216319 /* Value */ + ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here + : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -37729,7 +37842,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -37748,8 +37861,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return anyType; case 142 /* UnknownKeyword */: return unknownType; @@ -37771,16 +37884,16 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 162 /* TypeReference */: return getTypeFromTypeReference(node); case 161 /* TypePredicate */: return booleanType; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); @@ -37788,38 +37901,41 @@ var ts; return getTypeFromArrayTypeNode(node); case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return getTypeFromOptionalTypeNode(node); + case 171 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 173 /* ParenthesizedType */: - case 282 /* JSDocNonNullableType */: - case 278 /* JSDocTypeExpression */: + case 175 /* ParenthesizedType */: + case 170 /* RestType */: + case 285 /* JSDocNonNullableType */: + case 281 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 172 /* InferType */: + case 174 /* InferType */: return getTypeFromInferTypeNode(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode @@ -37968,7 +38084,7 @@ 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(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | (ts.getCheckFlags(symbol) & 1024 /* Late */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (1024 /* Late */ | 4096 /* OptionalParameter */ | 8192 /* RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -37979,11 +38095,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -38048,14 +38159,14 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 213 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -38193,32 +38304,32 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive); - case 262 /* JsxAttribute */: { + case 265 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265 /* JsxExpression */: { + case 268 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -38235,7 +38346,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -38245,7 +38356,7 @@ var ts; } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 213 /* Block */ ? false : isContextSensitive(body); + return body.kind === 216 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -38315,8 +38426,206 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268 /* JsxExpression */: + case 193 /* ParenthesizedExpression */: + return elaborateError(node.expression, source, target); + case 202 /* BinaryExpression */: + switch (node.operatorToken.kind) { + case 58 /* EqualsToken */: + case 26 /* CommaToken */: + return elaborateError(node.right, source, target); + } + break; + case 186 /* ObjectLiteralExpression */: + return elaborateObjectLiteral(node, source, target); + case 185 /* ArrayLiteralExpression */: + return elaborateArrayLiteral(node, source, target); + case 266 /* JsxAttributes */: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator, source, target) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + var resultObj = {}; + // Use the expression type, if available + var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + getIndexInfoOfType(target, 0 /* String */) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3 /*break*/, 3]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2 /*return*/]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3 /*break*/, 4]; + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3 /*break*/, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3 /*break*/, 3]; + nameType = getLiteralType(i); + return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3 /*break*/, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 32768 /* Never */)) { + return [3 /*break*/, 7]; + } + _b = prop.kind; + switch (_b) { + case 157 /* SetAccessor */: return [3 /*break*/, 2]; + case 156 /* GetAccessor */: return [3 /*break*/, 2]; + case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + } + return [3 /*break*/, 6]; + case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3 /*break*/, 7]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3 /*break*/, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** * This is *not* a bi-directional relationship. @@ -38337,13 +38646,20 @@ var ts; if (source === target) { return -1 /* True */; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0 /* False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0 /* False */; + } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; @@ -38364,14 +38680,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -38390,7 +38703,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0 /* False */; } @@ -38465,30 +38778,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - // If both have rest parameters, get the max and add 1 to - // compensate for the rest parameter. - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - // Return the count for whichever signature doesn't have rest parameters. - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -38509,11 +38798,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { + return relation === 1 /* Succeeded */; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, false); + enumRelation.set(id, 3 /* FailedAndReported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -38524,13 +38813,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); + enumRelation.set(id, 3 /* FailedAndReported */); + } + else { + enumRelation.set(id, 2 /* Failed */); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1 /* Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -38621,7 +38913,7 @@ var ts; * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -38651,12 +38943,16 @@ var ts; var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); // Cause the error to appear with the error that triggered it + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); // Cause the error to appear with the error that triggered it } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); // TODO: GH#18217 + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { @@ -38738,6 +39034,22 @@ var ts; if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); + if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + target = nullStrippedTarget; + } + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; @@ -38989,11 +39301,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } return 0 /* False */; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072 /* Object */) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4 /* Reference */) { + return source.target === target.target; + } + if (overlapObjFlags & 16 /* Anonymous */) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { var match; @@ -39125,9 +39455,8 @@ var ts; 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.set(id, 3 /* FailedAndReported */); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -39414,7 +39743,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -39437,6 +39766,33 @@ var ts; } } var result = -1 /* True */; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0 /* False */; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0 /* False */; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0 /* False */; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -39958,20 +40314,26 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); // A source signature matches a target signature if the two signatures have the same number of required, // optional, and rest parameters. - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } // A source signature partially matches a target signature if the target signature has no fewer required // parameters and no more overall parameters than the source signature (where a signature with a rest // parameter is always considered to have more overall parameters than one without). - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -40013,10 +40375,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0 /* False */; @@ -40036,9 +40398,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -40088,7 +40447,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); @@ -40135,6 +40499,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -40194,7 +40564,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -40407,7 +40777,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -40417,23 +40787,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 177 /* MappedType */: + case 179 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -40450,24 +40820,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -40606,10 +40974,14 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - // Two tuple types with different arity are definitely unrelated. + // Two tuple types with incompatible arities are definitely unrelated. // Two object types that each have a property that is unmatched in the other are definitely unrelated. - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) && !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false); } function getTypeFromInference(inference) { @@ -40892,12 +41264,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -41012,17 +41405,14 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + // If we have contravariant inferences we find the best common subtype and treat + // that as a single covariant candidate. + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { inferredType = getCovariantInference(inference, context, signature); - // If we have inferred 'never' but have contravariant candidates. To get a more specific type we - // infer from the contravariant candidates instead. - if (inferredType.flags & 32768 /* Never */ && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - // We only have contravariant inferences, infer the best common subtype of those - inferredType = getContravariantInference(inference); } else if (context.flags & 2 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -41099,13 +41489,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 185 /* PropertyAccessExpression */) { + if (node.kind === 187 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182 /* BindingElement */) { + if (node.kind === 184 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -41114,7 +41504,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180 /* ObjectBindingPattern */) { + if (parent.kind === 182 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: @@ -41137,26 +41527,26 @@ var ts; switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && + (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 185 /* PropertyAccessExpression */: - return target.kind === 185 /* PropertyAccessExpression */ && + case 187 /* PropertyAccessExpression */: + return target.kind === 187 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182 /* BindingElement */: - if (target.kind !== 185 /* PropertyAccessExpression */) + case 184 /* BindingElement */: + if (target.kind !== 187 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232 /* VariableDeclaration */) { + if (source.parent.parent.kind === 235 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -41164,7 +41554,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185 /* PropertyAccessExpression */) { + while (source.kind === 187 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -41177,7 +41567,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 === 185 /* PropertyAccessExpression */ && + return target.kind === 187 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -41185,7 +41575,7 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185 /* PropertyAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -41229,7 +41619,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -41355,7 +41745,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; } @@ -41363,15 +41753,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -41388,21 +41778,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return stringType; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return undefinedType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -41410,7 +41800,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 /* ObjectBindingPattern */ ? + var type = pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -41428,35 +41818,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221 /* ForInStatement */) { + if (node.parent.parent.kind === 224 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.parent.kind === 225 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 /* VariableDeclaration */ ? + return node.kind === 235 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? + return node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 /* VariableDeclaration */ && node.initializer && + return node.kind === 235 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && + node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -41468,13 +41858,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 191 /* ParenthesizedExpression */ || - parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 193 /* ParenthesizedExpression */ || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -41637,11 +42027,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 185 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 187 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 186 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 200 /* BinaryExpression */ && + parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -41689,7 +42079,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 = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -41760,7 +42150,7 @@ var ts; else if (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 !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 187 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -41816,7 +42206,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 /* CallExpression */ ? + var expr = node.kind === 189 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -41824,7 +42214,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -41989,7 +42379,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 /* PropertyAccessExpression */ && + return expr.kind === 187 /* PropertyAccessExpression */ && computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -42040,10 +42430,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 === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -42258,7 +42648,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -42278,15 +42668,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -42322,8 +42712,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 /* ModuleBlock */ || - node.kind === 274 /* SourceFile */ || + node.kind === 243 /* ModuleBlock */ || + node.kind === 277 /* SourceFile */ || node.kind === 152 /* PropertyDeclaration */; }); } @@ -42369,10 +42759,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 185 /* PropertyAccessExpression */ || - parent.kind === 187 /* CallExpression */ && parent.expression === node || - parent.kind === 186 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 182 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 187 /* PropertyAccessExpression */ || + parent.kind === 189 /* CallExpression */ && parent.expression === node || + parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); @@ -42406,7 +42796,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 */)) { @@ -42427,7 +42817,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.kind === 235 /* ClassDeclaration */ + if (declaration.kind === 238 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -42439,12 +42829,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205 /* ClassExpression */) { + else if (declaration.kind === 207 /* 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.kind !== 274 /* SourceFile */) { + while (container.kind !== 277 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; @@ -42494,23 +42884,23 @@ var ts; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - var isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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 === 192 /* FunctionExpression */ || - flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 /* FunctionExpression */ || + flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). - var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 252 /* ExportSpecifier */) || - node.parent.kind === 209 /* NonNullExpression */ || - declaration.kind === 232 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || + node.parent.kind === 211 /* NonNullExpression */ || + declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -42541,7 +42931,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -42566,8 +42956,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 === 220 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && + if (container.kind === 223 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -42581,7 +42971,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 191 /* ParenthesizedExpression */) { + while (current.parent.kind === 193 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -42589,7 +42979,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -42647,7 +43037,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); // If a containing class does not have extends clause or the class extends null // skip checking whether super statement is called before "this" accessing. if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -42674,17 +43064,17 @@ var ts; 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 === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 238 /* EnumDeclaration */: + case 241 /* 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; @@ -42722,8 +43112,8 @@ 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 === 192 /* FunctionExpression */ && - container.parent.kind === 200 /* BinaryExpression */ && + if (container.kind === 194 /* FunctionExpression */ && + container.parent.kind === 202 /* BinaryExpression */ && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.prototype.y = f @@ -42754,7 +43144,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -42771,12 +43161,12 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 /* 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 === 193 /* ArrowFunction */) { + while (container && container.kind === 195 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -42796,7 +43186,7 @@ var ts; 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 === 184 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -42884,7 +43274,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184 /* ObjectLiteralExpression */) { + if (container.parent.kind === 186 /* 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 errorType; @@ -42896,7 +43286,7 @@ var ts; } // at this point the only legal case for parent is ClassLikeDeclaration var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -42928,7 +43318,7 @@ 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 === 184 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 154 /* MethodDeclaration */ || container.kind === 153 /* MethodSignature */ || @@ -42952,8 +43342,8 @@ var ts; function getContainingObjectLiteral(func) { return (func.kind === 154 /* MethodDeclaration */ || func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 184 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 192 /* FunctionExpression */ && func.parent.kind === 270 /* PropertyAssignment */ ? func.parent.parent : + func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -42965,7 +43355,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193 /* ArrowFunction */) { + if (func.kind === 195 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -42992,7 +43382,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270 /* PropertyAssignment */) { + if (literal.parent.kind !== 273 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -43006,9 +43396,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { + if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -43031,27 +43421,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. @@ -43061,10 +43448,8 @@ var ts; return getTypeAtPosition(contextualSignature, indexOfParameter); } // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -43095,7 +43480,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182 /* BindingElement */) { + if (parentDeclaration.kind !== 184 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -43177,7 +43562,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189 /* TaggedTemplateExpression */) { + if (template.parent.kind === 191 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -43225,8 +43610,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504 /* StructuredType */) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, /*noReductions*/ true); } function getIndexTypeOfContextualType(type, kind) { @@ -43255,8 +43651,8 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -43322,8 +43718,8 @@ var ts; case 95 /* NullKeyword */: case 71 /* Identifier */: return true; - case 185 /* PropertyAccessExpression */: - case 191 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 193 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -43342,14 +43738,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270 /* PropertyAssignment */) + if (prop.kind !== 273 /* PropertyAssignment */) continue; if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine @@ -43390,52 +43786,52 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 193 /* ArrowFunction */: - case 225 /* ReturnStatement */: + case 195 /* ArrowFunction */: + case 228 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 183 /* ArrayLiteralExpression */: { + case 185 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 211 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); + case 214 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -43509,6 +43905,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -43519,8 +43916,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) @@ -43536,7 +43949,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -43581,11 +43995,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; + return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -43657,18 +44070,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 182 /* BindingElement */ && !!node.initializer) || - (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 184 /* BindingElement */ && !!node.initializer) || + (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -43693,13 +44107,17 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; + if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } @@ -43707,28 +44125,30 @@ 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 === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - if (patternElement.kind !== 206 /* OmittedExpression */) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { + if (e.kind !== 208 /* OmittedExpression */) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2 /* Subtype */); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2 /* Subtype */) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -43813,7 +44233,7 @@ var ts; var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -43827,11 +44247,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 /* PropertyAssignment */ || - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 273 /* PropertyAssignment */ || + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -43852,8 +44272,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -43878,7 +44298,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272 /* SpreadAssignment */) { + else if (memberDecl.kind === 275 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -43972,13 +44392,16 @@ var ts; type.flags & 131072 /* Object */ && !isGenericMappedType(type) || type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { + function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -43986,6 +44409,9 @@ var ts; else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -44008,16 +44434,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - // TODO (yuisu): comment - switch (tagName.kind) { - case 185 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: - return false; - case 71 /* Identifier */: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -44060,7 +44477,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -44083,7 +44500,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 255 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -44244,12 +44661,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -44286,6 +44715,10 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928 /* Type */); + } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -44692,7 +45125,7 @@ var ts; // 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, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. @@ -44713,31 +45146,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -44784,9 +45193,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? + var errorNode = node.kind === 187 /* PropertyAccessExpression */ || node.kind === 235 /* VariableDeclaration */ ? node.name : - node.kind === 179 /* ImportType */ ? + node.kind === 181 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -44956,7 +45365,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 !== 185 /* PropertyAccessExpression */ || + if (node.kind !== 187 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; @@ -44988,16 +45397,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && node.parent.kind !== 162 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -45005,7 +45419,7 @@ var ts; switch (node.kind) { case 152 /* PropertyDeclaration */: return true; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -45061,13 +45475,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319 /* Value */); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319 /* Value */); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -45126,16 +45546,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179 /* ImportType */: + case 181 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -45169,7 +45589,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer.kind === 236 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -45198,7 +45618,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 /* ForInStatement */ && + if (node.kind === 224 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -45216,7 +45636,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 190 /* 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); @@ -45283,7 +45703,7 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (node.kind !== 150 /* Decorator */) { @@ -45349,14 +45769,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204 /* SpreadElement */) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -45368,12 +45785,12 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { // 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 = node.typeArguments; - if (node.template.kind === 202 /* TemplateExpression */) { + if (node.template.kind === 204 /* 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 lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -45395,8 +45812,8 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 188 /* NewExpression */); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190 /* NewExpression */); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. @@ -45409,15 +45826,14 @@ var ts; } // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -45442,9 +45858,10 @@ var ts; // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1 /* InferUnionTypes */, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8 /* ReturnType */); @@ -45494,7 +45911,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -45509,11 +45926,13 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; 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 !== 206 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -45527,6 +45946,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) @@ -45544,6 +45967,35 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + // We are inferring from a spread expression in the last argument position, i.e. both the parameter + // and the argument are ...x forms. + return arg.kind === 213 /* SyntheticExpression */ ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -45603,7 +46055,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 190 /* 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. @@ -45617,24 +46069,32 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; 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 !== 206 /* OmittedExpression */) { - // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) - var paramType = getTypeAtPosition(signature, i); - // If the effective argument type is undefined, there is no synthetic type for the argument. - // In that case, we should check the argument. - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { + if (i === restIndex && (restType.flags & 65536 /* TypeParameter */ || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, /*context*/ undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) + var paramType = getTypeAtPosition(signature, i); + // If the effective argument type is undefined, there is no synthetic type for the argument. + // In that case, we should check the argument. + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } @@ -45644,9 +46104,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { + if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { return callee.expression; } } @@ -45661,10 +46121,10 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [undefined]; // TODO: GH#18217 - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -45681,7 +46141,28 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + // We have a spread argument in the last position and no other spread arguments. If the type + // of the argument is a tuple type, spread the tuple elements into the argument list. We can + // call checkExpressionCached because spread expressions never have a contextual type. + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213 /* SyntheticExpression */, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } /** @@ -45700,8 +46181,8 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; case 152 /* PropertyDeclaration */: @@ -45746,7 +46227,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* 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); @@ -45791,7 +46272,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -45846,7 +46327,7 @@ 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 === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -45895,7 +46376,7 @@ var ts; if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -45908,7 +46389,7 @@ 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 === 150 /* Decorator */ || - (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { + (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -45921,7 +46402,7 @@ var ts; // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -45941,7 +46422,7 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 189 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -46016,7 +46497,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 === 187 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 /* 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 @@ -46063,10 +46544,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -46181,11 +46662,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -46201,7 +46683,7 @@ var ts; if (superType !== errorType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -46380,8 +46862,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -46407,8 +46888,8 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -46484,16 +46965,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -46569,7 +47050,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -46583,7 +47065,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185 /* PropertyAccessExpression */) { + while (parent && parent.kind === 187 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -46615,7 +47097,7 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 188 /* NewExpression */) { + if (node.kind === 190 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 /* Constructor */ && @@ -46689,7 +47171,7 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -46746,9 +47228,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 234 /* FunctionDeclaration */ + ? 237 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 232 /* VariableDeclaration */ + ? 235 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -46826,10 +47308,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1 /* Number */) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536 /* TypeParameter */) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -46868,11 +47447,11 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -46937,7 +47516,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213 /* Block */) { + if (func.body.kind !== 216 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -47026,7 +47605,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -47051,7 +47630,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -47094,11 +47673,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; case 154 /* MethodDeclaration */: - return func.parent.kind === 184 /* ObjectLiteralExpression */; + return func.parent.kind === 186 /* ObjectLiteralExpression */; default: return false; } @@ -47122,7 +47701,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 (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -47162,7 +47741,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -47223,7 +47802,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213 /* Block */) { + if (node.body.kind === 216 /* Block */) { checkSourceElement(node.body); } else { @@ -47236,10 +47815,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -47269,7 +47848,7 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && + (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); @@ -47286,13 +47865,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 246 /* NamespaceImport */; + return !!declaration && declaration.kind === 249 /* NamespaceImport */; } } } @@ -47301,7 +47880,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -47310,7 +47889,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { + if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -47487,7 +48066,7 @@ 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 === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { var name = property.name; if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); @@ -47502,7 +48081,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 274 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -47514,7 +48093,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 272 /* SpreadAssignment */) { + else if (property.kind === 275 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -47549,27 +48128,23 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206 /* OmittedExpression */) { - if (element.kind !== 204 /* SpreadElement */) { + if (element.kind !== 208 /* OmittedExpression */) { + if (element.kind !== 206 /* SpreadElement */) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - // We still need to check element expression here because we may need to set appropriate flag on the expression - // such as NodeCheckFlags.LexicalThis on "this"expression. - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -47578,12 +48153,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -47592,7 +48170,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -47608,25 +48186,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184 /* ObjectLiteralExpression */) { + if (target.kind === 186 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183 /* ArrayLiteralExpression */) { + if (target.kind === 185 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 272 /* SpreadAssignment */ ? + var error = target.parent.kind === 275 /* 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)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -47644,35 +48222,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 189 /* TaggedTemplateExpression */: - case 202 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: - case 193 /* ArrowFunction */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 195 /* TypeOfExpression */: - case 209 /* NonNullExpression */: - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 197 /* TypeOfExpression */: + case 211 /* NonNullExpression */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: return true; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -47684,9 +48262,9 @@ var ts; } return false; // Some forms listed here for clarity - case 196 /* VoidExpression */: // Explicit opt-out - case 190 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 208 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 198 /* VoidExpression */: // Explicit opt-out + case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -47702,7 +48280,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -47901,7 +48479,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -47922,7 +48500,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34 /* EqualsEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -47979,7 +48573,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' return anyType; @@ -48004,7 +48598,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263 /* JsxAttributes */) { + if (node.kind === 266 /* JsxAttributes */) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -48040,7 +48634,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; + return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -48142,7 +48736,7 @@ var ts; function getTypeOfExpression(node, cache) { // 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 === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -48192,8 +48786,8 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { @@ -48229,74 +48823,76 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checkCallExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return checkClassExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return checkAssertion(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return checkNonNullAssertion(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return checkMetaProperty(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkDeleteExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return checkVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return checkAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return undefinedWideningType; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return checkYieldExpression(node); - case 265 /* JsxExpression */: + case 213 /* SyntheticExpression */: + return node.type; + case 268 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return checkJsxElement(node, checkMode); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -48325,6 +48921,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 /* Instantiable */ && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -48351,7 +48950,7 @@ var ts; } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -48412,10 +49011,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 158 /* CallSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 163 /* FunctionType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -48436,7 +49035,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { + else if (name.kind === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -48449,7 +49048,7 @@ var ts; checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + else if (node.kind === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -48514,7 +49113,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -48643,7 +49242,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* 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 @@ -48731,7 +49330,7 @@ var ts; // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -48753,7 +49352,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -48904,11 +49503,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170 /* RestType */) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169 /* OptionalType */) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -48922,7 +49538,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 186 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -48959,7 +49575,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -48975,9 +49591,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 !== 236 /* InterfaceDeclaration */ && - n.parent.kind !== 235 /* ClassDeclaration */ && - n.parent.kind !== 205 /* ClassExpression */ && + if (n.parent.kind !== 239 /* InterfaceDeclaration */ && + n.parent.kind !== 238 /* ClassDeclaration */ && + n.parent.kind !== 207 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported @@ -49107,7 +49723,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -49118,7 +49734,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 === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -49247,22 +49863,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -49270,17 +49886,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 234 /* FunctionDeclaration */: - case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 237 /* FunctionDeclaration */: + case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -49551,7 +50167,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -49614,12 +50230,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -49651,7 +50267,7 @@ var ts; } } return commonEntityName; - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); case 162 /* TypeReference */: return node.typeName; @@ -49684,7 +50300,7 @@ var ts; 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -49773,7 +50389,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -49785,7 +50401,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -49868,27 +50484,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274 /* SourceFile */: - case 239 /* ModuleDeclaration */: - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 242 /* ModuleDeclaration */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -49902,7 +50518,7 @@ var ts; case 159 /* ConstructSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -49915,10 +50531,7 @@ var ts; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -49948,7 +50561,7 @@ var ts; } break; case 160 /* IndexSignature */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: // Can't be private break; default: @@ -49964,7 +50577,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -49999,7 +50612,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -50017,9 +50630,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -50034,7 +50647,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0 /* Local */, unuseds.length === 1 @@ -50052,7 +50665,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -50073,7 +50686,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -50087,22 +50700,22 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; + return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 213 /* Block */) { + if (node.kind === 216 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -50197,7 +50810,7 @@ var ts; } // 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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 /* 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)); } @@ -50212,7 +50825,7 @@ var ts; } // 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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 277 /* 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)); } @@ -50247,7 +50860,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 === 232 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -50259,17 +50872,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 214 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 217 /* 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 === 213 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 240 /* ModuleBlock */ || - container.kind === 239 /* ModuleDeclaration */ || - container.kind === 274 /* SourceFile */); + (container.kind === 216 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 243 /* ModuleBlock */ || + container.kind === 242 /* ModuleDeclaration */ || + container.kind === 277 /* 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 @@ -50295,7 +50908,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 185 /* PropertyAccessExpression */) { + if (n.kind === 187 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -50315,7 +50928,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 182 /* BindingElement */) { + symbol.valueDeclaration.kind === 184 /* 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) { @@ -50368,8 +50981,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182 /* BindingElement */) { - if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 184 /* BindingElement */) { + if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -50390,7 +51003,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -50403,13 +51016,13 @@ var ts; // 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 !== 221 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -50426,8 +51039,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221 /* ForInStatement */) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -50442,7 +51055,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -50452,7 +51065,7 @@ var ts; if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -50467,8 +51080,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || - (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || + (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -50507,7 +51120,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215 /* EmptyStatement */) { + if (node.thenStatement.kind === 218 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -50527,12 +51140,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -50566,14 +51179,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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. @@ -50587,7 +51200,7 @@ var ts; // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -50605,7 +51218,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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); @@ -50619,7 +51232,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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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)) { @@ -50983,7 +51596,7 @@ var ts; } } else if (func.kind === 155 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -50999,7 +51612,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -51032,7 +51645,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 === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -51044,7 +51657,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -51073,7 +51686,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -51171,16 +51784,17 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } // perform property check if property or indexer is declared in 'type' // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || + if (propDeclaration && name && + (propDeclaration.kind === 202 /* BinaryExpression */ || + name.kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -51354,7 +51968,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); @@ -51366,6 +51980,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -51432,7 +52050,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -51451,7 +52069,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -51477,7 +52095,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; + return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -51516,7 +52134,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.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 205 /* ClassExpression */) { + if (derivedClassDecl.kind === 207 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -51630,7 +52248,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -51693,7 +52311,7 @@ var ts; } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -51708,7 +52326,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -51735,7 +52353,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -51745,7 +52363,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -51773,7 +52391,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: var identifier = expr; @@ -51781,14 +52399,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 185 /* PropertyAccessExpression */) { + if (ex.kind === 187 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -51820,8 +52438,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -51835,7 +52453,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304 /* Ambient */) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -51851,7 +52469,7 @@ var ts; if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -51859,7 +52477,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 !== 238 /* EnumDeclaration */) { + if (declaration.kind !== 241 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -51882,8 +52500,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 235 /* ClassDeclaration */ || - (declaration.kind === 234 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 238 /* ClassDeclaration */ || + (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -51946,7 +52564,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, 235 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -51996,23 +52614,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* 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 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -52023,12 +52641,12 @@ var ts; break; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 234 /* FunctionDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -52056,7 +52674,7 @@ var ts; node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -52073,9 +52691,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 250 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -52108,14 +52726,14 @@ var ts; (symbol.flags & 67901928 /* Type */ ? 67901928 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 252 /* ExportSpecifier */ ? + var message = node.kind === 255 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 252 /* ExportSpecifier */ + && node.kind === 255 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -52142,7 +52760,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -52166,7 +52784,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -52202,10 +52820,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -52222,7 +52840,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -52251,8 +52869,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -52340,7 +52958,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -52358,10 +52976,10 @@ 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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -52399,111 +53017,113 @@ var ts; return checkArrayType(node); case 168 /* TupleType */: return checkTupleType(node); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: + case 169 /* OptionalType */: + case 170 /* RestType */: return checkSourceElement(node.type); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return checkTypeOperator(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return checkConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return checkInferType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return checkImportType(node); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 282 /* JSDocNonNullableType */: - case 281 /* JSDocNullableType */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: - case 287 /* JSDocTypeLiteral */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: + case 290 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 278 /* JSDocTypeExpression */: + case 281 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return checkMappedType(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return checkBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return checkVariableStatement(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return checkExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return checkIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return checkDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return checkWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return checkForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return checkForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkForOfStatement(node); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return checkReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return checkSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return checkLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return checkThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return checkTryStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return checkBindingElement(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return checkClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return checkImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return checkExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return checkExportAssignment(node); - case 215 /* EmptyStatement */: - case 231 /* DebuggerStatement */: + case 218 /* EmptyStatement */: + case 234 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -52580,15 +53200,15 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -52597,11 +53217,17 @@ var ts; case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: checkClassExpressionDeferred(node); break; + case 259 /* JsxSelfClosingElement */: + checkJsxSelfClosingElementDeferred(node); + break; + case 258 /* JsxElement */: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -52636,7 +53262,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -52730,13 +53356,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -52744,8 +53370,8 @@ var ts; // falls 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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* 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. @@ -52754,7 +53380,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -52803,10 +53429,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148 /* TypeParameter */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -52820,10 +53446,10 @@ var ts; return node.parent.kind === 162 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185 /* PropertyAccessExpression */) { + while (node.parent.kind === 187 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 207 /* ExpressionWithTypeArguments */; + return node.parent.kind === 209 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -52854,10 +53480,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -52883,7 +53509,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -52893,7 +53519,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 /* PropertyAccessExpression */ && + entityName.parent.kind === 187 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -52901,7 +53527,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -52911,7 +53537,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 243 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -52929,7 +53555,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 === 207 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -52945,10 +53571,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293 /* JSDocParameterTag */) { + if (entityName.parent.kind === 296 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 297 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 300 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -52965,12 +53591,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185 /* PropertyAccessExpression */) { + if (entityName.kind === 187 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -52983,7 +53609,7 @@ var ts; var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 262 /* JsxAttribute */) { + else if (entityName.parent.kind === 265 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161 /* TypePredicate */) { @@ -52993,7 +53619,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -53013,8 +53639,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 /* BindingElement */ && - grandParent.kind === 180 /* ObjectBindingPattern */ && + else if (parent.kind === 184 /* BindingElement */ && + grandParent.kind === 182 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -53025,7 +53651,7 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: @@ -53040,7 +53666,7 @@ var ts; return checkExpression(node).symbol; } // falls through - case 174 /* ThisType */: + case 176 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; @@ -53058,7 +53684,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -53076,14 +53702,14 @@ var ts; case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -53156,28 +53782,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 222 /* ForOfStatement */) { + if (expr.parent.kind === 225 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 200 /* BinaryExpression */) { + if (expr.parent.kind === 202 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 270 /* PropertyAssignment */) { + if (expr.parent.kind === 273 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -53256,7 +53882,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -53312,7 +53938,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { var symbolFile = parentSymbol_1.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. @@ -53367,7 +53993,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 === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -53408,16 +54034,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -53427,7 +54053,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -53508,22 +54134,23 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273 /* EnumMember */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 276 /* EnumMember */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273 /* EnumMember */) { + if (node.kind === 276 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8 /* EnumMember */)) { // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -53661,7 +54288,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } @@ -53758,7 +54385,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; + return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -53770,7 +54397,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67901928 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -53821,7 +54448,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -53836,12 +54463,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 274 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 277 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -53849,10 +54476,14 @@ var ts; var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); // Initialize global symbol table var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -53926,6 +54557,32 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -54019,7 +54676,7 @@ var ts; } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { + if (node.kind !== 241 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -54039,7 +54696,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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -54062,7 +54719,7 @@ 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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149 /* Parameter */) { @@ -54098,7 +54755,7 @@ 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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149 /* Parameter */) { @@ -54107,8 +54764,8 @@ var ts; flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -54120,13 +54777,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 240 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -54136,14 +54793,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 238 /* ClassDeclaration */) { if (node.kind !== 154 /* MethodDeclaration */ && node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 156 /* GetAccessor */ && node.kind !== 157 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -54185,7 +54842,7 @@ var ts; } return false; } - else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -54220,29 +54877,29 @@ var ts; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 160 /* IndexSignature */: - case 239 /* ModuleDeclaration */: - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 242 /* ModuleDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 149 /* Parameter */: return false; default: - if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return false; } switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 236 /* InterfaceDeclaration */: - case 214 /* VariableStatement */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 217 /* VariableStatement */: + case 240 /* TypeAliasDeclaration */: return true; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -54256,9 +54913,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -54391,7 +55048,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206 /* OmittedExpression */) { + if (arg.kind === 208 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -54472,15 +55129,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 234 /* FunctionDeclaration */ || - node.kind === 192 /* FunctionExpression */ || + ts.Debug.assert(node.kind === 237 /* FunctionDeclaration */ || + node.kind === 194 /* FunctionExpression */ || node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -54504,7 +55161,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 /* SpreadAssignment */) { + if (prop.kind === 275 /* SpreadAssignment */) { continue; } var name = prop.name; @@ -54512,7 +55169,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 /* 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); @@ -54536,8 +55193,8 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -54587,7 +55244,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 264 /* JsxSpreadAttribute */) { + if (attr.kind === 267 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -54597,7 +55254,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -54606,12 +55263,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 233 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -54626,20 +55283,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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); @@ -54708,7 +55365,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 71 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -54746,7 +55403,7 @@ var ts; return true; } if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 184 /* ObjectLiteralExpression */) { + if (node.parent.kind === 186 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -54775,7 +55432,7 @@ var ts; return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (node.parent.kind === 166 /* TypeLiteral */) { @@ -54789,11 +55446,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 223 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 226 /* 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); @@ -54801,8 +55458,8 @@ var ts; return false; } break; - case 227 /* SwitchStatement */: - if (node.kind === 224 /* BreakStatement */ && !node.label) { + case 230 /* SwitchStatement */: + if (node.kind === 227 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -54817,13 +55474,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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 === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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); @@ -54836,7 +55493,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { + if (node.name.kind === 183 /* ArrayBindingPattern */ || node.name.kind === 182 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -54850,14 +55507,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { + if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -54868,7 +55525,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -54878,19 +55535,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -54945,15 +55602,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return false; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -54963,7 +55620,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -55030,7 +55687,7 @@ var ts; return true; } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -55067,13 +55724,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 237 /* TypeAliasDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 243 /* ImportEqualsDeclaration */ || - node.kind === 250 /* ExportDeclaration */ || - node.kind === 249 /* ExportAssignment */ || - node.kind === 242 /* NamespaceExportDeclaration */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 240 /* TypeAliasDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 253 /* ExportDeclaration */ || + node.kind === 252 /* ExportAssignment */ || + node.kind === 245 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -55082,7 +55739,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 === 214 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 217 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -55109,7 +55766,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 === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -55131,10 +55788,10 @@ var ts; 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, 178 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -55189,8 +55846,8 @@ var ts; /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -55198,14 +55855,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245 /* ImportClause */: // For default import - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: // For rename import `x as y` + case 248 /* ImportClause */: // For default import + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: // For rename import `x as y` return true; case 71 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 248 /* ImportSpecifier */; + return decl.parent.kind === 251 /* ImportSpecifier */; default: return false; } @@ -55221,8 +55878,12 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448 /* Literal */); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -55388,7 +56049,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 /* Node */ | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -55481,10 +56142,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 303 /* CommaListExpression */ ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147 /* ComputedPropertyName */); @@ -55847,14 +56507,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169 /* OptionalType */); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170 /* RestType */); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -55862,7 +56546,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -55881,7 +56565,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171 /* ConditionalType */); + var node = createSynthesizedNode(173 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -55899,7 +56583,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172 /* InferType */); + var node = createSynthesizedNode(174 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -55911,7 +56595,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179 /* ImportType */); + var node = createSynthesizedNode(181 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -55929,7 +56613,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173 /* ParenthesizedType */); + var node = createSynthesizedNode(175 /* ParenthesizedType */); node.type = type; return node; } @@ -55941,11 +56625,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174 /* ThisType */); + return createSynthesizedNode(176 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175 /* TypeOperator */); + var node = createSynthesizedNode(177 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -55956,7 +56640,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176 /* IndexedAccessType */); + var node = createSynthesizedNode(178 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -55970,7 +56654,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177 /* MappedType */); + var node = createSynthesizedNode(179 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -55988,7 +56672,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178 /* LiteralType */); + var node = createSynthesizedNode(180 /* LiteralType */); node.literal = literal; return node; } @@ -56001,7 +56685,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ObjectBindingPattern */); + var node = createSynthesizedNode(182 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56013,7 +56697,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181 /* ArrayBindingPattern */); + var node = createSynthesizedNode(183 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56025,7 +56709,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182 /* BindingElement */); + var node = createSynthesizedNode(184 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -56044,7 +56728,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -56058,7 +56742,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -56072,7 +56756,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185 /* PropertyAccessExpression */); + var node = createSynthesizedNode(187 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -56089,7 +56773,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186 /* ElementAccessExpression */); + var node = createSynthesizedNode(188 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -56103,7 +56787,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* CallExpression */); + var node = createSynthesizedNode(189 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -56119,7 +56803,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188 /* NewExpression */); + var node = createSynthesizedNode(190 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -56135,7 +56819,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -56158,7 +56842,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190 /* TypeAssertionExpression */); + var node = createSynthesizedNode(192 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -56172,7 +56856,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191 /* ParenthesizedExpression */); + var node = createSynthesizedNode(193 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -56184,7 +56868,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192 /* FunctionExpression */); + var node = createSynthesizedNode(194 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -56208,7 +56892,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193 /* ArrowFunction */); + var node = createSynthesizedNode(195 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -56242,7 +56926,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194 /* DeleteExpression */); + var node = createSynthesizedNode(196 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56254,7 +56938,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195 /* TypeOfExpression */); + var node = createSynthesizedNode(197 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56266,7 +56950,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196 /* VoidExpression */); + var node = createSynthesizedNode(198 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56278,7 +56962,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197 /* AwaitExpression */); + var node = createSynthesizedNode(199 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56290,7 +56974,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -56303,7 +56987,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -56316,7 +57000,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200 /* BinaryExpression */); + var node = createSynthesizedNode(202 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -56333,7 +57017,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201 /* ConditionalExpression */); + var node = createSynthesizedNode(203 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -56363,7 +57047,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202 /* TemplateExpression */); + var node = createSynthesizedNode(204 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -56401,7 +57085,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203 /* YieldExpression */); + var node = createSynthesizedNode(205 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -56415,7 +57099,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204 /* SpreadElement */); + var node = createSynthesizedNode(206 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -56427,7 +57111,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205 /* ClassExpression */); + var node = createSynthesizedNode(207 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56448,11 +57132,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206 /* OmittedExpression */); + return createSynthesizedNode(208 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -56466,7 +57150,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208 /* AsExpression */); + var node = createSynthesizedNode(210 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -56480,7 +57164,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209 /* NonNullExpression */); + var node = createSynthesizedNode(211 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -56492,7 +57176,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210 /* MetaProperty */); + var node = createSynthesizedNode(212 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -56506,7 +57190,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211 /* TemplateSpan */); + var node = createSynthesizedNode(214 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -56520,25 +57204,18 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212 /* SemicolonClassElement */); + return createSynthesizedNode(215 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213 /* Block */); + var block = createSynthesizedNode(216 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - /* @internal */ - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216 /* ExpressionStatement */); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -56546,7 +57223,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214 /* VariableStatement */); + var node = createSynthesizedNode(217 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -56561,21 +57238,27 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215 /* EmptyStatement */); + return createSynthesizedNode(218 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + ts.createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217 /* IfStatement */); + var node = createSynthesizedNode(220 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -56591,7 +57274,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218 /* DoStatement */); + var node = createSynthesizedNode(221 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -56605,7 +57288,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219 /* WhileStatement */); + var node = createSynthesizedNode(222 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -56619,7 +57302,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220 /* ForStatement */); + var node = createSynthesizedNode(223 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -56637,7 +57320,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForInStatement */); + var node = createSynthesizedNode(224 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -56653,7 +57336,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222 /* ForOfStatement */); + var node = createSynthesizedNode(225 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -56671,7 +57354,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223 /* ContinueStatement */); + var node = createSynthesizedNode(226 /* ContinueStatement */); node.label = asName(label); return node; } @@ -56683,7 +57366,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224 /* BreakStatement */); + var node = createSynthesizedNode(227 /* BreakStatement */); node.label = asName(label); return node; } @@ -56695,7 +57378,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225 /* ReturnStatement */); + var node = createSynthesizedNode(228 /* ReturnStatement */); node.expression = expression; return node; } @@ -56707,7 +57390,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226 /* WithStatement */); + var node = createSynthesizedNode(229 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -56721,7 +57404,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227 /* SwitchStatement */); + var node = createSynthesizedNode(230 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -56735,7 +57418,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228 /* LabeledStatement */); + var node = createSynthesizedNode(231 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -56749,7 +57432,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229 /* ThrowStatement */); + var node = createSynthesizedNode(232 /* ThrowStatement */); node.expression = expression; return node; } @@ -56761,7 +57444,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230 /* TryStatement */); + var node = createSynthesizedNode(233 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -56777,11 +57460,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231 /* DebuggerStatement */); + return createSynthesizedNode(234 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232 /* VariableDeclaration */); + var node = createSynthesizedNode(235 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -56798,7 +57481,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(233 /* VariableDeclarationList */); + var node = createSynthesizedNode(236 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -56811,7 +57494,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234 /* FunctionDeclaration */); + var node = createSynthesizedNode(237 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -56837,7 +57520,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* ClassDeclaration */); + var node = createSynthesizedNode(238 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56859,7 +57542,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236 /* InterfaceDeclaration */); + var node = createSynthesizedNode(239 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56881,7 +57564,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56901,7 +57584,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238 /* EnumDeclaration */); + var node = createSynthesizedNode(241 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56920,7 +57603,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* ModuleDeclaration */); + var node = createSynthesizedNode(242 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -56939,7 +57622,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240 /* ModuleBlock */); + var node = createSynthesizedNode(243 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -56951,7 +57634,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241 /* CaseBlock */); + var node = createSynthesizedNode(244 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -56963,7 +57646,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -56975,7 +57658,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56993,7 +57676,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244 /* ImportDeclaration */); + var node = createSynthesizedNode(247 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -57011,7 +57694,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245 /* ImportClause */); + var node = createSynthesizedNode(248 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -57025,7 +57708,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246 /* NamespaceImport */); + var node = createSynthesizedNode(249 /* NamespaceImport */); node.name = name; return node; } @@ -57037,7 +57720,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247 /* NamedImports */); + var node = createSynthesizedNode(250 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -57049,7 +57732,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248 /* ImportSpecifier */); + var node = createSynthesizedNode(251 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -57063,7 +57746,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249 /* ExportAssignment */); + var node = createSynthesizedNode(252 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -57080,7 +57763,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ExportDeclaration */); + var node = createSynthesizedNode(253 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -57098,7 +57781,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251 /* NamedExports */); + var node = createSynthesizedNode(254 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -57110,7 +57793,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252 /* ExportSpecifier */); + var node = createSynthesizedNode(255 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -57125,7 +57808,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254 /* ExternalModuleReference */); + var node = createSynthesizedNode(257 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -57138,7 +57821,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255 /* JsxElement */); + var node = createSynthesizedNode(258 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -57154,7 +57837,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57170,7 +57853,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257 /* JsxOpeningElement */); + var node = createSynthesizedNode(260 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57186,7 +57869,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258 /* JsxClosingElement */); + var node = createSynthesizedNode(261 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -57198,7 +57881,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259 /* JsxFragment */); + var node = createSynthesizedNode(262 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -57214,7 +57897,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262 /* JsxAttribute */); + var node = createSynthesizedNode(265 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -57228,7 +57911,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263 /* JsxAttributes */); + var node = createSynthesizedNode(266 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -57240,7 +57923,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -57252,7 +57935,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265 /* JsxExpression */); + var node = createSynthesizedNode(268 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -57266,7 +57949,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266 /* CaseClause */); + var node = createSynthesizedNode(269 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -57280,7 +57963,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267 /* DefaultClause */); + var node = createSynthesizedNode(270 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -57292,7 +57975,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268 /* HeritageClause */); + var node = createSynthesizedNode(271 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -57305,7 +57988,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269 /* CatchClause */); + var node = createSynthesizedNode(272 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -57320,7 +58003,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270 /* PropertyAssignment */); + var node = createSynthesizedNode(273 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -57335,7 +58018,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -57349,7 +58032,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272 /* SpreadAssignment */); + var node = createSynthesizedNode(275 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -57362,7 +58045,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273 /* EnumMember */); + var node = createSynthesizedNode(276 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -57383,7 +58066,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274 /* SourceFile */); + var updated = createSynthesizedNode(277 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -57467,7 +58150,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301 /* NotEmittedStatement */); + var node = createSynthesizedNode(304 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -57479,7 +58162,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(308 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57491,7 +58174,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(307 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57506,7 +58189,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(302 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(305 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -57522,7 +58205,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 303 /* CommaListExpression */) { + if (node.kind === 306 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -57532,7 +58215,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303 /* CommaListExpression */); + var node = createSynthesizedNode(306 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -57545,14 +58228,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275 /* Bundle */); + var node = ts.createNode(278 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276 /* UnparsedSource */); + var node = ts.createNode(279 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -57560,7 +58243,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277 /* InputFiles */); + var node = ts.createNode(280 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -57703,7 +58386,7 @@ var ts; // 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 === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -58214,7 +58897,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -58232,13 +58915,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -58265,7 +58948,7 @@ var ts; } else { switch (callee.kind) { - case 185 /* PropertyAccessExpression */: { + case 187 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58278,7 +58961,7 @@ var ts; } break; } - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58338,9 +59021,9 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -58665,7 +59348,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 191 /* ParenthesizedExpression */) { + if (skipped.kind === 193 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -58699,8 +59382,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(200 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -58709,7 +59392,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 203 /* YieldExpression */) { + && operand.kind === 205 /* YieldExpression */) { return false; } return true; @@ -58797,7 +59480,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -58812,7 +59495,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -58826,8 +59509,7 @@ var ts; // 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 var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 303 /* CommaListExpression */ + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } @@ -58845,10 +59527,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 /* ClassExpression */ || - check.kind === 192 /* FunctionExpression */ || - check.kind === 303 /* CommaListExpression */ || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) + return check.kind === 207 /* ClassExpression */ || + check.kind === 194 /* FunctionExpression */ || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -58862,9 +59543,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.createParen(expression); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -58887,7 +59568,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -58925,7 +59606,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -58936,27 +59617,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { + if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { + if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: return ts.createParenthesizedType(member); @@ -58967,8 +59648,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 172 /* InferType */: + case 177 /* TypeOperator */: + case 174 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -58994,25 +59675,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: node = node.operand; continue; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: node = node.left; continue; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: node = node.condition; continue; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: - node = node.expression; - continue; - case 302 /* PartiallyEmittedExpression */: + case 210 /* AsExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 211 /* NonNullExpression */: + case 305 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -59020,12 +59701,17 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || + node.kind === 306 /* CommaListExpression */; + } + ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; @@ -59036,13 +59722,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 209 /* NonNullExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 211 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -59067,7 +59753,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { node = node.expression; } return node; @@ -59075,11 +59761,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 191 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 208 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 209 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 302 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -59097,7 +59783,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 191 /* ParenthesizedExpression */ + return node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -59162,10 +59848,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -59284,7 +59970,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -59296,11 +59982,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -59333,11 +60019,11 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 204 /* SpreadElement */: - case 272 /* SpreadAssignment */: + case 206 /* SpreadElement */: + case 275 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -59349,7 +60035,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -59361,7 +60047,7 @@ var ts; : propertyName; } break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -59373,7 +60059,7 @@ var ts; : propertyName; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -59391,13 +60077,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -59437,11 +60123,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -59565,7 +60251,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -59602,7 +60288,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { return node; } switch (kind) { @@ -59657,217 +60343,221 @@ var ts; case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168 /* TupleType */: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* UnionType */: + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 169 /* OptionalType */: + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* RestType */: + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 172 /* InferType */: + case 174 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177 /* MappedType */: + case 179 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 213 /* Block */: + case 216 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 216 /* ExpressionStatement */: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* IfStatement */: + case 219 /* ExpressionStatement */: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForStatement */: + case 223 /* 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, ts.liftToBlock)); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -59913,17 +60603,17 @@ var ts; return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 212 /* SemicolonClassElement */: - case 215 /* EmptyStatement */: - case 206 /* OmittedExpression */: - case 231 /* DebuggerStatement */: - case 301 /* NotEmittedStatement */: + case 215 /* SemicolonClassElement */: + case 218 /* EmptyStatement */: + case 208 /* OmittedExpression */: + case 234 /* DebuggerStatement */: + case 304 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -59990,49 +60680,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* NewExpression */: + case 190 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -60040,123 +60730,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ArrowFunction */: + case 195 /* 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 191 /* ParenthesizedExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208 /* AsExpression */: + case 210 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 213 /* Block */: + case 216 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219 /* WhileStatement */: - case 226 /* WithStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60165,7 +60855,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60173,139 +60863,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -60378,7 +61068,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) && node.kind !== 207 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -60622,7 +61312,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -60769,7 +61458,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -60815,7 +61504,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -60823,13 +61512,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + case 246 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -60859,13 +61548,13 @@ var ts; } } break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -60873,7 +61562,7 @@ var ts; } } break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -60893,7 +61582,7 @@ var ts; } } break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -61509,13 +62198,14 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -61539,14 +62229,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -61574,16 +62264,18 @@ var ts; */ function saveStateAndInvoke(node, f) { // Save state - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } /** @@ -61593,15 +62285,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 240 /* ModuleBlock */: - case 213 /* Block */: - currentScope = node; + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 243 /* ModuleBlock */: + case 216 /* Block */: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -61613,7 +62306,11 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } + if (ts.isClassDeclaration(node)) { + // XXX: should probably also cover interfaces and type aliases that can have type variables? + currentNameScope = node; } break; } @@ -61657,10 +62354,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -61681,13 +62378,13 @@ var ts; return node; } switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -61707,11 +62404,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 250 /* ExportDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 245 /* ImportClause */ || - (node.kind === 243 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 254 /* ExternalModuleReference */)) { + if (node.kind === 253 /* ExportDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 248 /* ImportClause */ || + (node.kind === 246 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 257 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -61753,7 +62450,7 @@ var ts; case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -61794,6 +62491,8 @@ var ts; // TypeScript accessibility and readonly modifiers are elided. case 167 /* ArrayType */: case 168 /* TupleType */: + case 169 /* OptionalType */: + case 170 /* RestType */: case 166 /* TypeLiteral */: case 161 /* TypePredicate */: case 148 /* TypeParameter */: @@ -61809,36 +62508,36 @@ var ts; case 163 /* FunctionType */: case 165 /* TypeQuery */: case 162 /* TypeReference */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 171 /* ConditionalType */: - case 173 /* ParenthesizedType */: - case 174 /* ThisType */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: - case 178 /* LiteralType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 175 /* ParenthesizedType */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: // TypeScript type nodes are elided. case 160 /* IndexSignature */: // TypeScript index signatures are elided. case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; case 152 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; case 155 /* Constructor */: return visitConstructor(node); - case 236 /* InterfaceDeclaration */: + case 239 /* 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61849,7 +62548,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61860,13 +62559,13 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); case 154 /* MethodDeclaration */: @@ -61879,13 +62578,13 @@ var ts; case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case 149 /* Parameter */: @@ -61898,35 +62597,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -61962,7 +62661,7 @@ var ts; var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) @@ -62005,7 +62704,7 @@ var ts; var statements = [classStatement]; // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -62366,7 +63065,7 @@ var ts; // // super(...arguments); // - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } // Add the property initializers. Transforms this: @@ -62408,7 +63107,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -62445,7 +63144,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -62492,7 +63191,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -62795,7 +63494,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } /** @@ -62922,8 +63621,8 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -62945,8 +63644,8 @@ var ts; return serializeTypeNode(node.type); case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: @@ -63034,7 +63733,7 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return serializeTypeNode(node.type); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -63049,7 +63748,7 @@ var ts; return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -63069,18 +63768,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: return serializeUnionOrIntersectionType(node); case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: case 142 /* UnknownKeyword */: - case 174 /* ThisType */: - case 179 /* ImportType */: + case 176 /* ThisType */: + case 181 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63093,7 +63792,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -63132,7 +63831,7 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); @@ -63179,7 +63878,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. + name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -63513,7 +64212,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -63594,7 +64293,7 @@ var ts; * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -63618,7 +64317,7 @@ var ts; // enum body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63643,7 +64342,7 @@ var ts; // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63691,7 +64390,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } /** * Transforms the value of an enum member. @@ -63769,12 +64468,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentScope.kind === 274 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 238 /* EnumDeclaration */) { + if (node.kind === 241 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -63836,7 +64535,7 @@ var ts; // module body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63860,7 +64559,7 @@ var ts; // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63893,7 +64592,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240 /* ModuleBlock */) { + if (body.kind === 243 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -63939,13 +64638,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 !== 240 /* ModuleBlock */) { + if (body.kind !== 243 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -63986,7 +64685,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 246 /* NamespaceImport */) { + if (node.kind === 249 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -64141,17 +64840,17 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -64218,16 +64917,16 @@ 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(71 /* Identifier */); - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(239 /* ModuleDeclaration */); + context.enableEmitNotification(242 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; } /** * Hook for node emit. @@ -64288,9 +64987,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -64328,9 +65027,9 @@ 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 !== 274 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); + if (container && container.kind !== 277 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -64465,15 +65164,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -64482,27 +65181,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 213 /* Block */: - case 227 /* SwitchStatement */: - case 241 /* CaseBlock */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 230 /* TryStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 226 /* WithStatement */: - case 228 /* LabeledStatement */: + case 216 /* Block */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 229 /* WithStatement */: + case 231 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -64537,7 +65236,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -64703,7 +65402,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 === 193 /* ArrowFunction */; + var isArrowFunction = node.kind === 195 /* 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 @@ -64776,11 +65475,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -64824,11 +65523,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -64860,7 +65559,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -64959,25 +65658,25 @@ var ts; return node; } switch (node.kind) { - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitVoidExpression(node); case 155 /* Constructor */: return visitConstructorDeclaration(node); @@ -64987,19 +65686,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); case 149 /* Parameter */: return visitParameter(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -65033,7 +65732,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -65045,7 +65744,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 272 /* SpreadAssignment */) { + if (e.kind === 275 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -65054,7 +65753,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -65072,7 +65771,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 !== 184 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -65211,13 +65910,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -65385,11 +66084,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -65433,11 +66132,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -65469,7 +66168,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -65582,13 +66281,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -65598,13 +66297,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -65679,7 +66378,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265 /* JsxExpression */) { + else if (node.kind === 268 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -65773,7 +66472,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255 /* JsxElement */) { + if (node.kind === 258 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -66079,7 +66778,7 @@ var ts; return node; } switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66312,13 +67011,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 225 /* ReturnStatement */ + && node.kind === 228 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -66346,63 +67045,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return visitClassExpression(node); case 149 /* Parameter */: return visitParameter(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -66413,28 +67112,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitMetaProperty(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -66521,14 +67220,14 @@ 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 === 224 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -66539,7 +67238,7 @@ var ts; } } else { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -66656,7 +67355,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -66720,7 +67419,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), /*location*/ extendsClauseElement)); } } @@ -66839,11 +67538,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 225 /* ReturnStatement */) { + if (statement.kind === 228 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 217 /* IfStatement */) { + else if (statement.kind === 220 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -66851,7 +67550,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 213 /* Block */) { + else if (statement.kind === 216 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -66909,7 +67608,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -66919,8 +67618,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 /* BinaryExpression */ - || superCallExpression.left.kind !== 187 /* CallExpression */) { + if (superCallExpression.kind !== 202 /* BinaryExpression */ + || superCallExpression.left.kind !== 189 /* 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. @@ -67035,7 +67734,7 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -67049,7 +67748,7 @@ 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.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -67101,7 +67800,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) ]), 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 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) @@ -67117,7 +67816,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -67137,7 +67836,7 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return statements; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -67151,8 +67850,8 @@ var ts; // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -67183,7 +67882,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: @@ -67227,7 +67926,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -67245,7 +67944,7 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); + var statement = ts.createExpressionStatement(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. @@ -67388,7 +68087,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -67433,7 +68132,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193 /* ArrowFunction */); + ts.Debug.assert(node.kind === 195 /* 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 @@ -67501,10 +68200,10 @@ 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 191 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + case 193 /* ParenthesizedExpression */: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 202 /* BinaryExpression */: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); } @@ -67522,9 +68221,9 @@ var ts; // 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 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -67566,7 +68265,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -67725,14 +68424,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -67790,11 +68489,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -67883,13 +68582,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -67988,11 +68687,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -68156,7 +68855,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -68173,7 +68872,7 @@ var ts; ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { @@ -68282,10 +68981,10 @@ var ts; case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -68537,7 +69236,7 @@ var ts; statements.push(funcStatements[classBodyStart]); classBodyStart++; // Add the class alias following the declaration. - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } // Find the trailing 'return' statement (4) while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { @@ -68674,7 +69373,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -68941,9 +69640,9 @@ var ts; context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(193 /* ArrowFunction */); - context.enableEmitNotification(192 /* FunctionExpression */); - context.enableEmitNotification(234 /* FunctionDeclaration */); + context.enableEmitNotification(195 /* ArrowFunction */); + context.enableEmitNotification(194 /* FunctionExpression */); + context.enableEmitNotification(237 /* FunctionDeclaration */); } } /** @@ -68984,10 +69683,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 235 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -69069,11 +69768,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -69081,7 +69780,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -69134,15 +69833,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257 /* JsxOpeningElement */); - context.enableEmitNotification(258 /* JsxClosingElement */); - context.enableEmitNotification(256 /* JsxSelfClosingElement */); + context.enableEmitNotification(260 /* JsxOpeningElement */); + context.enableEmitNotification(261 /* JsxClosingElement */); + context.enableEmitNotification(259 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(270 /* PropertyAssignment */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(273 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -69161,9 +69860,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -69495,13 +70194,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -69514,24 +70213,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return visitBreakStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return visitContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -69552,21 +70251,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitConditionalExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69579,9 +70278,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -69757,7 +70456,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } /** @@ -69809,7 +70508,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -69821,7 +70520,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -69945,7 +70644,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* Statement */, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -70098,7 +70797,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -70197,35 +70896,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: return transformAndEmitBlock(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return transformAndEmitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return transformAndEmitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return transformAndEmitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return transformAndEmitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -70262,7 +70961,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -70413,7 +71112,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -70423,7 +71122,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -70484,7 +71183,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); @@ -70507,7 +71206,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -70655,7 +71354,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -70668,7 +71367,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -71531,7 +72230,7 @@ var ts; // indicate entry into a protected region by pushing the label numbers // for each block in the protected region. var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, [ ts.createArrayLiteral([ createLabel(startLabel), @@ -71545,7 +72244,7 @@ var ts; if (markLabelEnd) { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -71703,7 +72402,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -71897,11 +72596,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(277 /* 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. @@ -71994,7 +72693,7 @@ var ts; // // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, + ts.createExpressionStatement(ts.createCall(define, /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ // Add the dependency array argument: // @@ -72045,9 +72744,9 @@ var ts; 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.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(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"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -72071,7 +72770,7 @@ var ts; // } // })(function ...) var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, + ts.createExpressionStatement(ts.createCall(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // @@ -72150,7 +72849,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. @@ -72205,7 +72904,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); @@ -72223,23 +72922,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -72266,17 +72965,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -72370,7 +73069,7 @@ var ts; ts.createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; @@ -72465,7 +73164,7 @@ var ts; if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -72533,7 +73232,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( @@ -72546,7 +73245,7 @@ var ts; } else { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -72585,13 +73284,13 @@ var ts; 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)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { // export * from "mod"; - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } /** @@ -72697,7 +73396,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -72758,7 +73457,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -72813,10 +73512,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -72946,10 +73645,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), @@ -72970,7 +73669,7 @@ var ts; * @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); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -73015,7 +73714,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -73079,10 +73778,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -73103,7 +73802,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -73178,7 +73877,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -73254,11 +73953,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(277 /* 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. @@ -73320,7 +74019,7 @@ var ts; 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.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) @@ -73479,7 +74178,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -73504,7 +74203,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250 /* ExportDeclaration */) { + if (externalImport.kind !== 253 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -73558,9 +74257,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) ])), - ts.createStatement(ts.createCall(exportFunction, + ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) ], /*multiline*/ true)); } @@ -73582,19 +74281,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -73610,7 +74309,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { @@ -73619,7 +74318,7 @@ var ts; // emit as: // // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, /*typeArguments*/ undefined, [parameterName]))); } break; @@ -73644,15 +74343,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -73753,7 +74452,7 @@ 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.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -73790,7 +74489,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -73828,7 +74527,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 274 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 277 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -73892,7 +74591,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 === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -73954,10 +74653,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -74109,7 +74808,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -74137,43 +74836,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitDefaultClause(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitTryStatement(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -74356,7 +75055,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 200 /* BinaryExpression */) { + && node.kind === 202 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -74421,7 +75120,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274 /* SourceFile */; + return container !== undefined && container.kind === 277 /* SourceFile */; } else { return false; @@ -74454,7 +75153,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -74502,7 +75201,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -74538,10 +75237,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -74634,14 +75333,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 199 /* PostfixUnaryExpression */) { + if (node.kind === 201 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -74663,7 +75362,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -74702,7 +75401,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274 /* SourceFile */); + context.enableEmitNotification(277 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -74731,10 +75430,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -74841,7 +75540,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74870,7 +75569,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -74917,7 +75616,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { 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 : @@ -74936,7 +75635,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 === 235 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { 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 : @@ -75027,7 +75726,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -75041,7 +75740,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234 /* FunctionDeclaration */: + case 237 /* 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 : @@ -75097,7 +75796,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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 : @@ -75110,7 +75809,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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 163 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -75125,10 +75824,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159 /* ConstructSignature */: @@ -75142,17 +75841,17 @@ var ts; 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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -75167,7 +75866,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 235 /* ClassDeclaration */) { + if (node.parent.parent.kind === 238 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = node.parent.token === 108 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -75264,7 +75963,13 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + // If it is visible via `// `, then we should just use that + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -75319,10 +76024,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -75350,7 +76055,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -75448,7 +76153,7 @@ var ts; return name; } else { - if (name.kind === 181 /* ArrayBindingPattern */) { + if (name.kind === 183 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -75456,7 +76161,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206 /* OmittedExpression */) { + if (elem.kind === 208 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -75514,7 +76219,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 /* Parameter */ @@ -75536,20 +76241,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return false; } return false; @@ -75603,7 +76308,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -75615,7 +76320,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -75642,7 +76347,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -75747,14 +76452,14 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 207 /* ExpressionWithTypeArguments */: { + case 209 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -75808,7 +76513,7 @@ var ts; return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -75822,7 +76527,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171 /* ConditionalType */: { + case 173 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -75840,7 +76545,7 @@ var ts; case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179 /* ImportType */: { + case 181 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -75879,7 +76584,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250 /* ExportDeclaration */: { + case 253 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -75888,7 +76593,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -75918,10 +76623,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -75942,24 +76647,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 236 /* InterfaceDeclaration */: { + case 239 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 234 /* FunctionDeclaration */: { + case 237 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type return cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); } - case 239 /* ModuleDeclaration */: { + case 242 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240 /* ModuleBlock */) { + if (inner && inner.kind === 243 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -75980,7 +76685,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 235 /* ClassDeclaration */: { + case 238 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -76020,7 +76725,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 @@ -76050,10 +76755,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238 /* EnumDeclaration */: { + case 241 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -76072,7 +76777,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239 /* ModuleDeclaration */) { + if (input.kind === 242 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -76093,7 +76798,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206 /* OmittedExpression */) { + if (e.kind === 208 /* OmittedExpression */) { return; } if (e.name) { @@ -76147,7 +76852,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 274 /* SourceFile */; + var parentIsFile = node.parent.kind === 277 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -76168,7 +76873,7 @@ var ts; var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3 /* MultiLineCommentTrivia */) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -76182,7 +76887,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -76195,7 +76900,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* InterfaceDeclaration */) { return true; } return false; @@ -76224,7 +76929,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: @@ -76234,17 +76939,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: - case 214 /* VariableStatement */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 217 /* VariableStatement */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return true; } return false; @@ -76261,14 +76966,14 @@ var ts; case 153 /* MethodSignature */: case 158 /* CallSignature */: case 160 /* IndexSignature */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 148 /* TypeParameter */: - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: case 162 /* TypeReference */: - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 179 /* ImportType */: + case 181 /* ImportType */: return true; } return false; @@ -76344,7 +77049,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(306 /* Count */); + var enabledSyntaxKindFeatures = new Array(309 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -76679,7 +77384,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap @@ -76689,7 +77393,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 277 /* 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 = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -76780,7 +77484,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** * Emits a mapping. @@ -76840,6 +77543,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -76850,50 +77554,55 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { // empty } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); // First, decode the old component sourcemap - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); + } + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -76910,7 +77619,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -76965,13 +77674,15 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -77087,7 +77798,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 304 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 10 /* JsxText */; @@ -77108,7 +77819,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 === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -77450,7 +78161,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275 /* Bundle */) { + if (sourceFile.kind === 278 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; @@ -77585,6 +78296,11 @@ var ts; // Setup and perform the transformation to retrieve declarations from the input files var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + // Checker wont collect the linked aliases since thats only done when declaration is enabled. + // Do that here when emitting only dts files + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -77612,9 +78328,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71 /* Identifier */) { + resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -77714,9 +78443,9 @@ var ts; break; } switch (node.kind) { - case 274 /* SourceFile */: return printFile(node); - case 275 /* Bundle */: return printBundle(node); - case 276 /* UnparsedSource */: return printUnparsedSource(node); + case 277 /* SourceFile */: return printFile(node); + case 278 /* Bundle */: return printBundle(node); + case 279 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -77861,7 +78590,7 @@ var ts; } return pipelineEmitWithoutComments; case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { return pipelineEmitWithSourceMap; } // falls through @@ -77887,7 +78616,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); + ts.Debug.assert(hint !== 0 /* SourceFile */); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -77906,7 +78635,7 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 276 /* UnparsedSource */: + case 279 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: @@ -77951,7 +78680,7 @@ var ts; return emitTypeReference(node); case 163 /* FunctionType */: return emitFunctionType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 164 /* ConstructorType */: return emitConstructorType(node); @@ -77963,178 +78692,181 @@ var ts; return emitArrayType(node); case 168 /* TupleType */: return emitTupleType(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return emitOptionalType(node); + case 171 /* UnionType */: return emitUnionType(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return emitIntersectionType(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return emitConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return emitInferType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return emitParenthesizedType(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return emitThisType(); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return emitTypeOperator(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return emitMappedType(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return emitLiteralType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return emitImportTypeNode(node); - case 279 /* JSDocAllType */: + case 282 /* JSDocAllType */: write("*"); return; - case 280 /* JSDocUnknownType */: + case 283 /* JSDocUnknownType */: write("?"); return; - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 285 /* JSDocVariadicType */: - return emitJSDocVariadicType(node); + case 170 /* RestType */: + case 288 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return emitBindingElement(node); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return emitTemplateSpan(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 213 /* Block */: + case 216 /* Block */: return emitBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return emitVariableStatement(node); - case 215 /* EmptyStatement */: + case 218 /* EmptyStatement */: return emitEmptyStatement(); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return emitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return emitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return emitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return emitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return emitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return emitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return emitForOfStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return emitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return emitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return emitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return emitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return emitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return emitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return emitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return emitTryStatement(node); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return emitClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return emitModuleBlock(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return emitCaseBlock(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return emitImportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return emitImportClause(node); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return emitNamespaceImport(node); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return emitNamedImports(node); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return emitImportSpecifier(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return emitExportDeclaration(node); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return emitNamedExports(node); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return emitExportSpecifier(node); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return; // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 258 /* JsxClosingElement */: - case 261 /* JsxClosingFragment */: + case 261 /* JsxClosingElement */: + case 264 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return emitJsxAttribute(node); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return emitJsxAttributes(node); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return emitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return emitDefaultClause(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return emitHeritageClause(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -78169,71 +78901,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return emitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return emitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return emitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return emitArrowFunction(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return emitDeleteExpression(node); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return emitVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return emitAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return emitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return emitConditionalExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return emitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return emitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return emitSpreadExpression(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return emitClassExpression(node); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: return emitAsExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return emitNonNullExpression(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return emitJsxElement(node); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return emitCommaList(node); } } @@ -78250,7 +78982,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 /* Bundle */ ? node : undefined; + var bundle = node.kind === 278 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -78376,7 +79108,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -78545,7 +79277,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -78554,6 +79286,10 @@ var ts; emitList(node, node.elementTypes, 272 /* TupleTypeElements */); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260 /* UnionTypeConstituents */); } @@ -78835,7 +79571,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 === 198 /* PrefixUnaryExpression */ + return operand.kind === 200 /* PrefixUnaryExpression */ && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } @@ -78955,7 +79691,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217 /* IfStatement */) { + if (node.elseStatement.kind === 220 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -79026,7 +79762,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { emit(node); } else { @@ -79128,7 +79864,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272 /* VariableDeclarationList */); } @@ -79321,7 +80057,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239 /* ModuleDeclaration */) { + while (body.kind === 242 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -80246,7 +80982,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -80311,81 +81047,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: ts.forEach(node.statements, generateNames); break; - case 228 /* LabeledStatement */: - case 226 /* WithStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 231 /* LabeledStatement */: + case 229 /* WithStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: generateNames(node.statement); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: generateNames(node.declarationList); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: generateNames(node.importClause); break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -80394,8 +81130,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 152 /* PropertyDeclaration */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -80581,17 +81317,17 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 252 /* ExportAssignment */: return generateNameForExportDefault(); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return generateNameForClassExpression(); case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -81252,17 +81988,20 @@ var ts; } return context; } - function formatLocation(file, start, host) { + /* @internal */ + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -81281,11 +82020,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -82012,7 +82751,16 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + // Use local caches + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + // Before falling back to the host + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -82272,10 +83020,10 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: - case 232 /* VariableDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: + case 235 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -82283,41 +83031,41 @@ var ts; } } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -82330,25 +83078,25 @@ 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: // 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; } // falls through - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); } break; case 152 /* PropertyDeclaration */: @@ -82370,11 +83118,11 @@ var ts; return; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -83040,14 +83788,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -84701,11 +85449,12 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - // Note: fromSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + // Note: importingSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -84718,7 +85467,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); @@ -84736,13 +85485,13 @@ var ts; function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -84812,11 +85561,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0 /* EqualTo */) { resolvedParts.pop(); originalParts.pop(); } @@ -84850,17 +85600,16 @@ var ts; return [target]; } /** - * Looks for a existing imports that use symlinks to this module. + * Looks for existing imports that use symlinks to this module. * Only if no symlink is available, the real path will be used. */ - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -84936,7 +85685,7 @@ var ts; var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); @@ -85344,7 +86093,7 @@ var ts; } var trace = host.trace && (function (s) { host.trace(s + newLine); }); var watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? ts.WatchLogLevel.Verbose : - compilerOptions.diagnostis ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; // TODO: GH#18217 var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -85876,16 +86625,20 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */) ? ".jsx" /* Jsx */ : ".js" /* Js */); + var newExtension = ts.fileExtensionIs(inputFileName, ".json" /* Json */) ? ".json" /* Json */ : + ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -86057,9 +86810,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -86109,7 +86859,7 @@ var ts; // Everything is broken - we don't even know what to watch. Give up. return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { // Watch this file @@ -86136,7 +86886,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -86341,14 +87091,18 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -86356,7 +87110,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -86652,12 +87410,12 @@ var ts; } // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -86726,7 +87484,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; @@ -87184,7 +87942,7 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ - ts.defaultPreferences = {}; + ts.emptyOptions = {}; var TextChange = /** @class */ (function () { function TextChange() { } @@ -87420,35 +88178,35 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 149 /* Parameter */: - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 269 /* CatchClause */: - case 262 /* JsxAttribute */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 272 /* CatchClause */: + case 265 /* JsxAttribute */: return 1 /* Value */; case 148 /* TypeParameter */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: case 166 /* TypeLiteral */: return 2 /* Type */; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 273 /* EnumMember */: - case 235 /* ClassDeclaration */: + case 276 /* EnumMember */: + case 238 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -87458,26 +88216,26 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* EnumDeclaration */: - case 247 /* NamedImports */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 241 /* EnumDeclaration */: + case 250 /* NamedImports */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 249 /* ExportAssignment */) { + else if (node.parent.kind === 252 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -87510,7 +88268,7 @@ var ts; // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 243 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { while (node.parent.kind === 146 /* QualifiedName */) { @@ -87536,16 +88294,16 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 185 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { + if (root.parent.kind === 187 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -87556,25 +88314,25 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return true; } switch (node.parent.kind) { case 162 /* TypeReference */: return true; - case 179 /* ImportType */: + case 181 /* ImportType */: return !node.parent.isTypeOf; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 189 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 190 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -87587,7 +88345,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -87612,11 +88370,11 @@ var ts; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -87628,20 +88386,20 @@ var ts; switch (node.parent.kind) { case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 273 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 276 /* EnumMember */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return node.parent.argumentExpression === node; case 147 /* ComputedPropertyName */: return true; - case 178 /* LiteralType */: - return node.parent.parent.kind === 176 /* IndexedAccessType */; + case 180 /* LiteralType */: + return node.parent.parent.kind === 178 /* IndexedAccessType */; default: return false; } @@ -87665,17 +88423,17 @@ var ts; return undefined; } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return node; } } @@ -87683,26 +88441,26 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return "class" /* classElement */; - case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 237 /* TypeAliasDeclaration */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 240 /* TypeAliasDeclaration */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 238 /* EnumDeclaration */: return "enum" /* enumElement */; - case 232 /* VariableDeclaration */: + case 241 /* EnumDeclaration */: return "enum" /* enumElement */; + case 235 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return "function" /* functionElement */; case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; @@ -87717,15 +88475,14 @@ var ts; case 158 /* CallSignature */: return "call" /* callSignatureElement */; case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 273 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 276 /* EnumMember */: return "enum member" /* enumMemberElement */; case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: - case 252 /* ExportSpecifier */: - case 246 /* NamespaceImport */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: + case 249 /* NamespaceImport */: return "alias" /* alias */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -87749,11 +88506,13 @@ var ts; return "" /* unknown */; } } + case 71 /* Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; } function getKindOfVariableDeclaration(v) { - return ts.isConst(v) + return ts.isVarConst(v) ? "const" /* constElement */ : ts.isLet(v) ? "let" /* letElement */ @@ -87786,6 +88545,10 @@ var ts; return startEndContainsRange(r1.pos, r1.end, r2); } ts.rangeContainsRange = rangeContainsRange; + function rangeContainsRangeExclusive(r1, r2) { + return rangeContainsPositionExclusive(r1, r2.pos) && rangeContainsPositionExclusive(r1, r2.end); + } + ts.rangeContainsRangeExclusive = rangeContainsRangeExclusive; function rangeContainsPosition(r, pos) { return r.pos <= pos && pos <= r.end; } @@ -87806,6 +88569,10 @@ var ts; return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); } ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function nodeOverlapsWithStartEnd(node, sourceFile, start, end) { + return startEndOverlapsWithStartEnd(node.getStart(sourceFile), node.end, start, end); + } + ts.nodeOverlapsWithStartEnd = nodeOverlapsWithStartEnd; function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { var start = Math.max(start1, start2); var end = Math.min(end1, end2); @@ -87825,28 +88592,28 @@ var ts; return false; } switch (n.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: - case 180 /* ObjectBindingPattern */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: case 166 /* TypeLiteral */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 241 /* CaseBlock */: - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 244 /* CaseBlock */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 188 /* NewExpression */: + case 190 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 187 /* CallExpression */: - case 191 /* ParenthesizedExpression */: - case 173 /* ParenthesizedType */: + case 189 /* CallExpression */: + case 193 /* ParenthesizedExpression */: + case 175 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -87854,13 +88621,13 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 159 /* ConstructSignature */: case 158 /* CallSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -87870,19 +88637,19 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 183 /* ArrayLiteralExpression */: - case 181 /* ArrayBindingPattern */: - case 186 /* ElementAccessExpression */: + case 185 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 188 /* ElementAccessExpression */: case 147 /* ComputedPropertyName */: case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); @@ -87891,44 +88658,44 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); case 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 195 /* TypeOfExpression */: - case 194 /* DeleteExpression */: - case 196 /* VoidExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: + case 197 /* TypeOfExpression */: + case 196 /* DeleteExpression */: + case 198 /* VoidExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -87992,38 +88759,30 @@ var ts; * position >= start and (position < end or (position === end && token is literal or keyword or identifier)) */ function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, /*includeJsDocComment*/ true, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); + return getTouchingToken(sourceFile, position, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); } ts.getTouchingPropertyName = getTouchingPropertyName; /** * Returns the token if position is in [start, end). * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true */ - function getTouchingToken(sourceFile, position, includeJsDocComment, includePrecedingTokenAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false, includeJsDocComment); + function getTouchingToken(sourceFile, position, includePrecedingTokenAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile, position, includeJsDocComment, includeEndPosition) { - if (includeEndPosition === void 0) { includeEndPosition = false; } - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, includeEndPosition, includeJsDocComment); + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, /*includeEndPosition*/ false); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition, includeJsDocComment) { + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition) { var current = sourceFile; outer: while (true) { - if (ts.isToken(current)) { - // exit early - return current; - } // find the child that contains 'position' for (var _i = 0, _a = current.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; - if (!includeJsDocComment && ts.isJSDocNode(child)) { - continue; - } - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { // If this child begins after position, then all subsequent children will as well. break; @@ -88054,7 +88813,7 @@ var ts; function findTokenOnLeftOfPosition(file, position) { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. - var tokenAtPosition = getTokenAtPosition(file, position, /*includeJsDocComment*/ false); + var tokenAtPosition = getTokenAtPosition(file, position); if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } @@ -88068,19 +88827,14 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - var children = n.getChildren(); - for (var _i = 0, children_3 = children; _i < children_3.length; _i++) { - var child = children_3[_i]; + return ts.firstDefined(n.getChildren(), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || // previous token ends exactly at the beginning of child (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child, sourceFile)) { - return find(child); - } - } - return undefined; + return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find(child) : undefined; + }); } } ts.findNextToken = findNextToken; @@ -88088,7 +88842,7 @@ var ts; * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { + function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) { var result = find(startNode || sourceFile); ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; @@ -88105,7 +88859,7 @@ var ts; // we need to find the last token in a previous child. // 2) `position` is within the same span: we recurse on `child`. if (position < child.end) { - var start = child.getStart(sourceFile, includeJsDoc); + var start = child.getStart(sourceFile, /*includeJsDoc*/ !excludeJsdoc); var lookInPreviousChild = (start >= position) || // cursor in the leading trivia !nodeHasTokens(child, sourceFile) || isWhiteSpaceOnlyJsxText(child); @@ -88120,7 +88874,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 277 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); // 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. @@ -88180,7 +88934,7 @@ var ts; * returns true if the position is in between the open and close elements of an JSX expression. */ function isInsideJsxElementOrAttribute(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); if (!token) { return false; } @@ -88192,17 +88946,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { return true; } return false; @@ -88212,7 +88966,7 @@ var ts; return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; } function isInTemplateString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; @@ -88254,7 +89008,7 @@ var ts; if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { - return { called: token, nTypeArguments: nTypeArguments }; + return ts.isDeclarationName(token) ? undefined : { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -88324,19 +89078,13 @@ var ts; * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - function isInComment(sourceFile, position, tokenAtPosition, predicate) { - return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); + function isInComment(sourceFile, position, tokenAtPosition) { + return ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*precedingToken*/ undefined, tokenAtPosition); } ts.isInComment = isInComment; function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*"; - } + var token = getTokenAtPosition(sourceFile, position); + return !!ts.findAncestor(token, ts.isJSDoc); } ts.hasDocComment = hasDocComment; function nodeHasTokens(n, sourceFile) { @@ -88345,7 +89093,7 @@ var ts; return n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node) { - var flags = ts.getCombinedModifierFlags(node); + var flags = ts.isDeclaration(node) ? ts.getCombinedModifierFlags(node) : 0 /* None */; var result = []; if (flags & 8 /* Private */) result.push("private" /* privateMemberModifier */); @@ -88365,10 +89113,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -88413,18 +89161,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 183 /* ArrayLiteralExpression */ || - node.kind === 184 /* ObjectLiteralExpression */) { + if (node.kind === 185 /* ArrayLiteralExpression */ || + node.kind === 186 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 200 /* BinaryExpression */ && + if (node.parent.kind === 202 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 222 /* ForOfStatement */ && + if (node.parent.kind === 225 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -88432,7 +89180,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -88440,19 +89188,17 @@ var ts; } ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; function isInReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ true); } ts.isInReferenceComment = isInReferenceComment; function isInNonReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ false); } ts.isInNonReferenceComment = isInNonReferenceComment; + function isInReferenceCommentWorker(sourceFile, position, shouldBeReference) { + var range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined); + return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); + } function createTextSpanFromNode(node, sourceFile) { return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); } @@ -88566,13 +89312,17 @@ var ts; QuotePreference[QuotePreference["Single"] = 0] = "Single"; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); + function quotePreferenceFromString(str, sourceFile) { + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + } + ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference) { return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; } else { - var firstModuleSpecifier = ts.firstOrUndefined(sourceFile.imports); - return !!firstModuleSpecifier && !ts.isStringDoubleQuoted(firstModuleSpecifier, sourceFile) ? 0 /* Single */ : 1 /* Double */; + var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, ts.isStringLiteral); + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; } } ts.getQuotePreference = getQuotePreference; @@ -88652,6 +89402,37 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + var NodeMap = /** @class */ (function () { + function NodeMap() { + this.map = ts.createMap(); + } + NodeMap.prototype.get = function (node) { + var res = this.map.get(String(ts.getNodeId(node))); + return res && res.value; + }; + NodeMap.prototype.getOrUpdate = function (node, setValue) { + var res = this.get(node); + if (res) + return res; + var value = setValue(); + this.set(node, value); + return value; + }; + NodeMap.prototype.set = function (node, value) { + this.map.set(String(ts.getNodeId(node)), { node: node, value: value }); + }; + NodeMap.prototype.has = function (node) { + return this.map.has(String(ts.getNodeId(node))); + }; + NodeMap.prototype.forEach = function (cb) { + this.map.forEach(function (_a) { + var node = _a.node, value = _a.value; + return cb(value, node); + }); + }; + return NodeMap; + }()); + ts.NodeMap = NodeMap; function getParentNodeInSpan(node, file, span) { if (!node) return undefined; @@ -88667,6 +89448,10 @@ var ts; return ts.textSpanContainsPosition(span, node.getStart(file)) && node.getEnd() <= ts.textSpanEnd(span); } + function findModifier(node, kind) { + return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); + } + ts.findModifier = findModifier; /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); @@ -88879,7 +89664,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && + (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -89308,7 +90093,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_5 = dense[i + 1]; + var length_6 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -89317,8 +90102,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_5, classification: convertClassification(type) }); - lastEnd = start + length_5; + entries.push({ length: length_6, classification: convertClassification(type) }); + lastEnd = start + length_6; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -89497,10 +90282,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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -89712,18 +90497,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -89810,22 +90595,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -89854,17 +90639,17 @@ var ts; var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 232 /* VariableDeclaration */ || + if (parent.kind === 235 /* VariableDeclaration */ || parent.kind === 152 /* PropertyDeclaration */ || parent.kind === 149 /* Parameter */ || - parent.kind === 262 /* JsxAttribute */) { + parent.kind === 265 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 200 /* BinaryExpression */ || - parent.kind === 198 /* PrefixUnaryExpression */ || - parent.kind === 199 /* PostfixUnaryExpression */ || - parent.kind === 201 /* ConditionalExpression */) { + if (parent.kind === 202 /* BinaryExpression */ || + parent.kind === 200 /* PrefixUnaryExpression */ || + parent.kind === 201 /* PostfixUnaryExpression */ || + parent.kind === 203 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -89875,7 +90660,7 @@ var ts; } else if (tokenKind === 9 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -89891,7 +90676,7 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -89901,17 +90686,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -89963,12 +90748,12 @@ var ts; }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker)); + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; - function getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; + var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); @@ -89980,7 +90765,6 @@ var ts; } } else { - // Check for node modules return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } } @@ -90097,7 +90881,7 @@ var ts; for (var path in paths) { var patterns = paths[path]; if (paths.hasOwnProperty(path) && patterns) { - var _loop_13 = function (name, kind) { + var _loop_12 = function (name, kind) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind)); @@ -90105,7 +90889,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind; - _loop_13(name, kind); + _loop_12(name, kind); } } } @@ -90121,7 +90905,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_14 = function (moduleName) { + var _loop_13 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); @@ -90129,7 +90913,7 @@ var ts; }; for (var _e = 0, _f = enumerateNodeModulesVisibleToScript(host, scriptPath); _e < _f.length; _e++) { var moduleName = _f[_e]; - _loop_14(moduleName); + _loop_13(moduleName); } } if (!foundGlobal) { @@ -90146,14 +90930,16 @@ var ts; function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") && ts.startsWith(path, fragment) ? [{ name: path, kind: "directory" /* directory */ }] : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); - if (!ts.startsWith(fragment, pathPrefix)) { - return [{ name: pathPrefix, kind: "directory" /* directory */ }]; + var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); + return remainingFragment === undefined ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { + return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); + }); + function justPathMappingName(name) { + return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; } - var remainingFragment = fragment.slice(pathPrefix.length); - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { if (!host.readDirectory) { @@ -90210,7 +90996,7 @@ var ts; return nonRelativeModuleNames; } function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { - var token = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, position); var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); var range = commentRanges && ts.find(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end; }); if (!range) { @@ -90683,11 +91469,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.parent.parent.kind) { case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent)), isNewIdentifier: false }; - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -90695,12 +91481,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 179 /* ImportType */: + case 181 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(node.parent.parent) && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -90717,7 +91503,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -90730,8 +91516,8 @@ var ts; } return undefined; } - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -90740,9 +91526,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 254 /* ExternalModuleReference */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 257 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -90819,7 +91605,7 @@ var ts; || ts.codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) : symbol.name; } - function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, getCanonicalFileName, preferences, cancellationToken) { + function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); var name = entryId.name; @@ -90848,7 +91634,7 @@ var ts; } case "symbol": { var symbol = symbolCompletion.symbol, location = symbolCompletion.location, symbolToOriginInfoMap = symbolCompletion.symbolToOriginInfoMap, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -90891,14 +91677,14 @@ var ts; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, allSourceFiles, preferences) { + function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, allSourceFiles, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || symbolOriginInfo.type !== "export") { return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; + var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, allSourceFiles, formatContext, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { @@ -90939,11 +91725,11 @@ var ts; return getContextualTypeFromParent(previousToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -90953,7 +91739,7 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo @@ -90968,15 +91754,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checker.getContextualType(parent); - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 266 /* CaseClause */: + case 269 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -90992,16 +91778,15 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 274 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); - var currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // TODO: GH#15853 + var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) log("getCompletionData: Get current token: " + (ts.timestamp() - start)); start = ts.timestamp(); - // Completion not allowed inside comments, bail out if this is the case var insideComment = ts.isInComment(sourceFile, position, currentToken); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); var insideJsDocTagTypeExpression = false; @@ -91044,11 +91829,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { - currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 299 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 302 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -91066,7 +91851,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); // The decision to provide completion depends on the contextToken, which is determined through the previousToken. // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file @@ -91075,7 +91860,7 @@ var ts; // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { var start_4 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); } // Find the node where completion is requested on. @@ -91098,15 +91883,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; case 146 /* QualifiedName */: node = parent.left; break; - case 179 /* ImportType */: - case 210 /* MetaProperty */: + case 181 /* ImportType */: + case 212 /* MetaProperty */: node = parent; break; default: @@ -91119,7 +91904,7 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 185 /* PropertyAccessExpression */) { + if (parent && parent.kind === 187 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -91127,39 +91912,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 200 /* BinaryExpression */: - if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { - // It has a left-hand side, so we're not in an opening JSX tag. + case 202 /* BinaryExpression */: + if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: + case 260 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -91212,11 +91996,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: - case 294 /* JSDocReturnTag */: - case 296 /* JSDocTypeTag */: - case 298 /* JSDocTypedefTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: + case 297 /* JSDocReturnTag */: + case 299 /* JSDocTypeTag */: + case 301 /* JSDocTypedefTag */: return true; default: return false; @@ -91250,7 +92034,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -91274,27 +92058,31 @@ var ts; // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker, /*isForAccess*/ true)); + symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker)); } else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } } } function addPropertySymbol(symbol) { + // For a computed property with an accessible name like `Symbol.iterator`, + // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. - var symbolSymbol = ts.firstDefined(symbol.declarations, function (decl) { - var name = ts.getNameOfDeclaration(decl); - var leftName = name.kind === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; - return leftName && typeChecker.getSymbolAtLocation(leftName); - }); - if (symbolSymbol) { - symbols.push(symbolSymbol); - symbolToOriginInfoMap[ts.getSymbolId(symbolSymbol)] = { type: "symbol-member" }; + var computedPropertyName = ts.firstDefined(symbol.declarations, function (decl) { return ts.tryCast(ts.getNameOfDeclaration(decl), ts.isComputedPropertyName); }); + if (computedPropertyName) { + var leftMostName = getLeftMostName(computedPropertyName.expression); // The completion is for `Symbol`, not `iterator`. + var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); + // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. + var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); + if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + symbols.push(firstAccessibleSymbol); + symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = { type: "symbol-member" }; + } } else { symbols.push(symbol); @@ -91378,10 +92166,10 @@ var ts; var symbolMeanings = 67901928 /* Type */ | 67216319 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 274 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { - for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { + for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { type: "this-type" }; symbols.push(symbol); @@ -91414,10 +92202,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 274 /* SourceFile */: - case 202 /* TemplateExpression */: - case 265 /* JsxExpression */: - case 213 /* Block */: + case 277 /* SourceFile */: + case 204 /* TemplateExpression */: + case 268 /* JsxExpression */: + case 216 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -91464,12 +92252,12 @@ var ts; return parentKind === 152 /* PropertyDeclaration */ || parentKind === 151 /* PropertySignature */ || parentKind === 149 /* Parameter */ || - parentKind === 232 /* VariableDeclaration */ || + parentKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 237 /* TypeAliasDeclaration */; + return parentKind === 240 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 208 /* AsExpression */; + return parentKind === 210 /* AsExpression */; } } return false; @@ -91572,11 +92360,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; + if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; } } return false; @@ -91586,36 +92374,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 187 /* CallExpression */ // func( a, | + return containingNodeKind === 189 /* CallExpression */ // func( a, | || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 188 /* NewExpression */ // new C(a, | - || containingNodeKind === 183 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 200 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 190 /* NewExpression */ // new C(a, | + || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 187 /* CallExpression */ // func( | + return containingNodeKind === 189 /* CallExpression */ // func( | || containingNodeKind === 155 /* Constructor */ // constructor( | - || containingNodeKind === 188 /* NewExpression */ // new C(a| - || containingNodeKind === 191 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 173 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + || containingNodeKind === 190 /* NewExpression */ // new C(a| + || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + return containingNodeKind === 185 /* ArrayLiteralExpression */ // [ | || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 129 /* ModuleKeyword */: // module | case 130 /* NamespaceKeyword */: // namespace | return true; case 23 /* DotToken */: - return containingNodeKind === 239 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 200 /* BinaryExpression */; // x = a| + return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 202 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: @@ -91653,16 +92441,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = hasIndexSignature(typeForObject); - typeMembers = getPropertiesForCompletion(typeForObject, typeChecker, /*isForAccess*/ false); + typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -91673,7 +92461,7 @@ var ts; // through type declaration or inference. // 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 = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 222 /* ForOfStatement */; + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 225 /* ForOfStatement */; if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); @@ -91720,7 +92508,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -91764,8 +92552,8 @@ var ts; if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented var baseSymbols = ts.flatMap(ts.getAllSuperTypeNodes(decl), function (baseTypeNode) { - var type = typeChecker.getTypeAtLocation(baseTypeNode); // TODO: GH#18217 - return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); + var type = typeChecker.getTypeAtLocation(baseTypeNode); + return type && typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); } @@ -91835,14 +92623,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: - case 263 /* JsxAttributes */: - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { + case 187 /* PropertyAccessExpression */: + case 266 /* JsxAttributes */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 262 /* JsxAttribute */) { + else if (parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91854,7 +92642,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent && ((parent.kind === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91864,8 +92652,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 265 /* JsxExpression */ && - parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { + parent.kind === 268 /* JsxExpression */ && + parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91873,7 +92661,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91893,49 +92681,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 232 /* VariableDeclaration */ || - containingNodeKind === 233 /* VariableDeclarationList */ || - containingNodeKind === 214 /* VariableStatement */ || - containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 235 /* VariableDeclaration */ || + containingNodeKind === 236 /* VariableDeclarationList */ || + containingNodeKind === 217 /* VariableStatement */ || + containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 182 /* BindingElement */; // var {x :html| + return containingNodeKind === 184 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 269 /* CatchClause */ || + return containingNodeKind === 272 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | - containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | + containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| + (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 248 /* ImportSpecifier */ || - containingNodeKind === 252 /* ExportSpecifier */ || - containingNodeKind === 246 /* NamespaceImport */; + return containingNodeKind === 251 /* ImportSpecifier */ || + containingNodeKind === 255 /* ExportSpecifier */ || + containingNodeKind === 249 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -92019,9 +92807,9 @@ 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 !== 270 /* PropertyAssignment */ && - m.kind !== 271 /* ShorthandPropertyAssignment */ && - m.kind !== 182 /* BindingElement */ && + if (m.kind !== 273 /* PropertyAssignment */ && + m.kind !== 274 /* ShorthandPropertyAssignment */ && + m.kind !== 184 /* BindingElement */ && m.kind !== 154 /* MethodDeclaration */ && m.kind !== 156 /* GetAccessor */ && m.kind !== 157 /* SetAccessor */) { @@ -92043,7 +92831,7 @@ var ts; // NOTE: if one only performs this step when m.name is an identifier, // things like '__proto__' are not filtered out. var name = ts.getNameOfDeclaration(m); - existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; + existingName = name && ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } @@ -92102,7 +92890,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 262 /* JsxAttribute */) { + if (attr.kind === 265 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -92209,47 +92997,28 @@ var ts; } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { - var jsDoc = getJsDocHavingNode(node).jsDoc; - if (!jsDoc) - return undefined; - for (var _i = 0, jsDoc_1 = jsDoc; _i < jsDoc_1.length; _i++) { - var _a = jsDoc_1[_i], pos = _a.pos, end = _a.end, tags = _a.tags; - if (!tags || position < pos || position > end) - continue; - for (var i = tags.length - 1; i >= 0; i--) { - var tag = tags[i]; - if (position >= tag.pos) { - return tag; - } - } - } + var jsdoc = ts.findAncestor(node, ts.isJSDoc); + return jsdoc && jsdoc.tags && (ts.rangeContainsPosition(jsdoc, position) ? ts.findLast(jsdoc.tags, function (tag) { return tag.pos < position; }) : undefined); } - function getJsDocHavingNode(node) { - if (!ts.isToken(node)) - return node; - switch (node.kind) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - // if the current token is var, let or const, skip the VariableDeclarationList - return node.parent.parent; - default: - return node.parent; - } + function getPropertiesForObjectExpression(contextualType, obj, checker) { + return contextualType.isUnion() + ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { + // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. + return !(memberType.flags & 32764 /* Primitive */ || + checker.isArrayLikeType(memberType) || + ts.typeHasCallOrConstructSignatures(memberType, checker) || + checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); + })) + : contextualType.getApparentProperties(); } /** * Gets all properties on a type, but if that type is a union of several types, * excludes array-like types or callable/constructable types. */ - function getPropertiesForCompletion(type, checker, isForAccess) { - if (!(type.isUnion())) { - return ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); - } - // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - var filteredTypes = isForAccess ? type.types : type.types.filter(function (memberType) { - return !(memberType.flags & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); - }); - return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); + function getPropertiesForCompletion(type, checker) { + return type.isUnion() + ? ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") + : ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } /** * Returns the immediate owning class declaration of a context token, @@ -92258,7 +93027,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 300 /* SyntaxList */: + case 303 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -92305,7 +93074,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -92314,12 +93083,16 @@ var ts; return ts.Debug.assertNever(triggerCharacter); } } + function binaryExpressionMayBeOpenTag(_a) { + var left = _a.left; + return ts.nodeIsMissing(left); + } function isStringLiteralOrTemplate(node) { switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: return true; default: return false; @@ -92453,7 +93226,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -92485,16 +93258,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 227 /* SwitchStatement */: - if (statement.kind === 223 /* ContinueStatement */) { + case 230 /* SwitchStatement */: + if (statement.kind === 226 /* ContinueStatement */) { return false; } // falls through - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -92504,24 +93277,17 @@ var ts; }); } function getModifierOccurrences(modifier, declaration) { - var modifierFlag = ts.modifierToFlag(modifier); - return ts.mapDefined(getNodesToSearchForModifier(declaration, modifierFlag), function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - var mod = ts.find(node.modifiers, function (m) { return m.kind === modifier; }); - ts.Debug.assert(!!mod); - return mod; - } - }); + return ts.mapDefined(getNodesToSearchForModifier(declaration, ts.modifierToFlag(modifier)), function (node) { return ts.findModifier(node, modifier); }); } function getNodesToSearchForModifier(declaration, modifierFlag) { // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: - case 213 /* Block */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: + case 216 /* Block */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -92531,10 +93297,10 @@ var ts; } case 155 /* Constructor */: case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: var 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. @@ -92567,7 +93333,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 218 /* DoStatement */) { + if (loopNode.kind === 221 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -92587,13 +93353,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -92965,12 +93731,13 @@ var ts; if (!markSeenDirectImport(direct)) { continue; } - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -92983,20 +93750,20 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -93006,7 +93773,7 @@ var ts; directImports.push(direct); } break; - case 179 /* ImportType */: + case 181 /* ImportType */: directImports.push(direct); break; default: @@ -93023,7 +93790,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -93078,7 +93845,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 243 /* ImportEqualsDeclaration */) { + if (decl.kind === 246 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -93088,7 +93855,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 179 /* ImportType */) { + if (decl.kind === 181 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -93103,17 +93870,17 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 250 /* ExportDeclaration */) { + if (decl.kind === 253 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -93163,7 +93930,7 @@ var ts; } } else { - var localSymbol = element.kind === 252 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 255 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -93192,7 +93959,7 @@ var ts; for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { var referencingFile = sourceFiles_5[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 274 /* SourceFile */) { + if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -93222,7 +93989,8 @@ var ts; var map = ts.createMap(); for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { var sourceFile = sourceFiles_6[_i]; - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { @@ -93239,7 +94007,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -93254,15 +94022,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: { + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -93286,7 +94054,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 185 /* PropertyAccessExpression */) { + if (parent.kind === 187 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -93408,10 +94176,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 232 /* VariableDeclaration */) { + if (parent.kind === 235 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -93420,15 +94188,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -93461,21 +94229,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 274 /* SourceFile */) { + if (parent.kind === 277 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -93510,13 +94278,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // 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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var result_6 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_6.push(nodeEntry(node)); }); return result_6; @@ -93532,8 +94300,7 @@ var ts; return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true }); } } - function findReferencedEntries(program, cancellationToken, sourceFiles, sourceFile, position, options) { - var node = ts.getTouchingPropertyName(sourceFile, position); + function findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options) { return ts.map(flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options)), toReferenceEntry); } FindAllReferences.findReferencedEntries = findReferencedEntries; @@ -93620,13 +94387,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 205 /* ClassExpression */) { + else if (node.kind === 207 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -93739,10 +94506,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -93900,7 +94667,7 @@ var ts; this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; - /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ + /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { if (searchOptions === void 0) { searchOptions = {}; } // Note: if this is an external module symbol, the name doesn't include quotes. @@ -93983,6 +94750,24 @@ var ts; } } } + function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { + var importTracker = FindAllReferences.createImportTracker(sourceFiles, ts.arrayToSet(sourceFiles, function (f) { return f.fileName; }), checker, cancellationToken); + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers; + for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { + var importLocation = importSearches_2[_i][0]; + cb(importLocation); + } + for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) { + var indirectUser = indirectUsers_2[_b]; + for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { + var node = _d[_c]; + if (ts.isIdentifier(node) && checker.getSymbolAtLocation(node) === exportSymbol) { + cb(node); + } + } + } + } + Core.eachExportReference = eachExportReference; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; @@ -94015,9 +94800,9 @@ var ts; : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 184 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 182 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -94039,7 +94824,7 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -94049,7 +94834,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 235 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -94078,7 +94863,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -94117,6 +94902,28 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function eachSignatureCall(signature, sourceFiles, checker, cb) { + if (!signature.name || !ts.isIdentifier(signature.name)) + return; + var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { + var name = _b[_a]; + if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) + continue; + var called = ts.climbPastPropertyAccess(name); + var call = called.parent; + if (!ts.isCallExpression(call) || call.expression !== called) + continue; + var referenceSymbol = checker.getSymbolAtLocation(name); + if (referenceSymbol && checker.getRootSymbols(referenceSymbol).some(function (s) { return s === symbol; })) { + cb(call); + } + } + } + } + Core.eachSignatureCall = eachSignatureCall; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos); }); @@ -94341,6 +95148,7 @@ var ts; function getReferenceForShorthandProperty(_a, search, state) { var flags = _a.flags, valueDeclaration = _a.valueDeclaration; var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + var name = valueDeclaration && ts.getNameOfDeclaration(valueDeclaration); /* * 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 @@ -94348,8 +95156,8 @@ var ts; * 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. */ - if (!(flags & 33554432 /* Transient */) && search.includes(shorthandValueSymbol)) { - addReference(ts.getNameOfDeclaration(valueDeclaration), shorthandValueSymbol, state); + if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { @@ -94457,7 +95265,7 @@ var ts; if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -94477,7 +95285,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 213 /* Block */) { + if (body.kind === 216 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -94505,13 +95313,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 183 /* ArrayLiteralExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 185 /* ArrayLiteralExpression */: return true; default: return false; @@ -94609,20 +95417,20 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 = ts.flatMap(searchSpaceNode.kind === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -94630,19 +95438,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 274 /* SourceFile */: - return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); + case 277 /* SourceFile */: + return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -94844,16 +95652,17 @@ var ts; }); } ts.getEditsForFileRename = getEditsForFileRename; + // exported for tests function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var canonicalPath = getCanonicalFileName(path); - if (canonicalPath === canonicalOldPath) + if (getCanonicalFileName(path) === canonicalOldPath) return newFileOrDirPath; - var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + var suffix = ts.tryRemoveDirectoryPrefix(path, canonicalOldPath, getCanonicalFileName); return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; }; } + ts.getPathUpdater = getPathUpdater; function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) @@ -94924,9 +95733,10 @@ var ts; } } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { - var _loop_15 = function (sourceFile) { - var newFromOld = oldToNew(sourceFile.fileName); - var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.fileName; + var allFiles = program.getSourceFiles(); + var _loop_14 = function (sourceFile) { + var newFromOld = oldToNew(sourceFile.path); + var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.path; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); var oldFromNew = newToOld(sourceFile.fileName); var oldImportFromPath = oldFromNew || sourceFile.fileName; @@ -94939,20 +95749,24 @@ var ts; var newAbsolute = oldToNew(oldAbsolute); return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); }, function (importLiteral) { + var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + // No need to update if it's an ambient module^M + if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. // TODO:GH#18217 ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) - : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); - // If neither the importing source file nor the imported file moved, do nothing. - return toImport === undefined || !toImport.updated && !importingSourceFileMoved - ? undefined - : ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, preferences); + : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew); + // Need an update if the imported file moved, or the importing file moved and was using a relative path. + return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text))) + ? ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, allFiles, preferences) + : undefined; }); }; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - _loop_15(sourceFile); + for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { + var sourceFile = allFiles_1[_i]; + _loop_14(sourceFile); } } function combineNormal(pathA, pathB) { @@ -94961,12 +95775,10 @@ var ts; function combinePathsSafe(pathA, pathB) { return ts.ensurePathIsNonModuleName(combineNormal(pathA, pathB)); } - function getSourceFileToImport(importLiteral, importingSourceFile, program, host, oldToNew) { - var symbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); - if (symbol) { - if (symbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) - return undefined; // No need to update if it's an ambient module - var oldFileName = ts.find(symbol.declarations, ts.isSourceFile).fileName; + function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) { + if (importedModuleSymbol) { + // `find` should succeed because we checked for ambient modules before calling this function. + var oldFileName = ts.find(importedModuleSymbol.declarations, ts.isSourceFile).fileName; var newFileName = oldToNew(oldFileName); return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true }; } @@ -95042,7 +95854,8 @@ var ts; return getDefinitionInfoForIndexSignatures(node, typeChecker); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); - if (calledDeclaration) { + // Don't go to the component constructor definition for a JSX element, just go to the component definition. + if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && ts.isConstructorDeclaration(calledDeclaration))) { var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. @@ -95062,7 +95875,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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -95111,7 +95924,7 @@ var ts; */ function symbolMatchesSignature(s, calledDeclaration) { return s === calledDeclaration.symbol || s === calledDeclaration.symbol.parent || - ts.isVariableDeclaration(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; + !ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; } function getReferenceAtPosition(sourceFile, position, program) { var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); @@ -95204,11 +96017,11 @@ var ts; return true; } switch (declaration.kind) { - case 245 /* ImportClause */: - case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: return true; - case 248 /* ImportSpecifier */: - return declaration.parent.kind === 247 /* NamedImports */; + case 251 /* ImportSpecifier */: + return declaration.parent.kind === 250 /* NamedImports */; default: return false; } @@ -95262,7 +96075,7 @@ var ts; return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); } function findReferenceInPosition(refs, pos) { - return ts.find(refs, function (ref) { return ref.pos <= pos && pos <= ref.end; }); + return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; function getDefinitionInfoForFileReference(name, targetFileName) { @@ -95367,11 +96180,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: return [declaration]; - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -95392,16 +96205,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return withNode(tag.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -95531,7 +96344,7 @@ var ts; if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { return undefined; } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; @@ -95549,10 +96362,7 @@ var ts; var singleLineResult = "/** */"; return { newText: singleLineResult, caretOffset: 3 }; } - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - // replace non-whitespace characters in prefix with spaces. - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); + var indentationStr = getIndentationStringAtPosition(sourceFile, position); // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -95560,8 +96370,7 @@ var ts; // * TODO: other tags. // * the closing comment line // * if the caret was directly in front of the object, then we add an extra line and indentation. - var preamble = "/**" + newLine + - indentationStr + " * "; + var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + @@ -95569,6 +96378,14 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function getIndentationStringAtPosition(sourceFile, position) { + var text = sourceFile.text; + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + var pos = lineStart; + for (; pos <= position && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) + ; + return text.slice(lineStart, pos); + } function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; @@ -95580,20 +96397,21 @@ var ts; function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: case 151 /* PropertySignature */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 237 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 240 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -95601,14 +96419,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 274 /* SourceFile */: + case 277 /* SourceFile */: return undefined; - case 239 /* ModuleDeclaration */: + case 242 /* 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 { }'. - return commentOwner.parent.kind === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 200 /* BinaryExpression */: { + return commentOwner.parent.kind === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 202 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -95628,14 +96446,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return rightHandSide.parameters; - case 205 /* ClassExpression */: { + case 207 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -95654,7 +96472,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_16 = function (sourceFile) { + var _loop_15 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { return "continue"; @@ -95664,15 +96482,12 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; - _loop_16(sourceFile); + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_15(sourceFile); } rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - return rawItems.map(createNavigateToItem); + return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } NavigateTo.getNavigateToItems = getNavigateToItems; function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { @@ -95687,23 +96502,23 @@ var ts; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 + // If the pattern has dots in it, then also see if the declaration container matches as well. + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } } else { - // If the pattern has dots in it, then also see if the declaration container matches as well. rawItems.push({ name: name, fileName: fileName, matchKind: match.kind, isCaseSensitive: match.isCaseSensitive, declaration: declaration }); } } } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 245 /* ImportClause */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - var importer = checker.getSymbolAtLocation(declaration.name); + case 248 /* ImportClause */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; default: @@ -95748,14 +96563,14 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; + if (name && name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + return ts.emptyArray; } // Now, walk up our containers, adding all their names to the container array. var container = ts.getContainerNode(declaration); while (container) { if (!tryAddSingleDeclarationName(container, containers)) { - return undefined; + return ts.emptyArray; } container = ts.getContainerNode(container); } @@ -95780,7 +96595,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ // TODO: GH#18217 Just use `container ? ...` + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -95941,19 +96756,19 @@ var ts; addLeafNode(node); } break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addLeafNode(importClause); + addLeafNode(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -95964,8 +96779,8 @@ var ts; } } break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -95986,12 +96801,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -96001,9 +96816,9 @@ var ts; } endNode(); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -96011,18 +96826,18 @@ var ts; } endNode(); break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 252 /* ExportSpecifier */: - case 243 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: case 160 /* IndexSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -96030,7 +96845,7 @@ var ts; case 3 /* PrototypeProperty */: case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); - break; + return; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: @@ -96106,7 +96921,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -96116,7 +96931,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -96146,7 +96961,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -96154,16 +96969,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -96173,16 +96988,16 @@ var ts; } } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -96220,25 +97035,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 274 /* SourceFile */: - case 237 /* TypeAliasDeclaration */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 277 /* SourceFile */: + case 240 /* TypeAliasDeclaration */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return true; case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -96248,8 +97063,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; @@ -96260,7 +97075,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; + return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; }); } } @@ -96317,7 +97132,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -96328,16 +97143,16 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 + return decl.body.kind === 242 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -96347,16 +97162,16 @@ var ts; return ts.declarationNameToString(node.name); } // See if it is a var initializer. If so, use the var name. - else if (node.parent.kind === 232 /* VariableDeclaration */) { + else if (node.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (node.parent.kind === 200 /* BinaryExpression */ && + else if (node.parent.kind === 202 /* BinaryExpression */ && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name - else if (node.parent.kind === 270 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 273 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -96369,9 +97184,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: return true; default: return false; @@ -96427,10 +97242,7 @@ var ts; }); // Delete or replace the first import. if (newImportDecls.length === 0) { - changeTracker.deleteNode(sourceFile, oldImportDecls[0], { - useNonAdjustedStartPosition: true, - useNonAdjustedEndPosition: false, - }); + changeTracker.delete(sourceFile, oldImportDecls[0]); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. @@ -96442,7 +97254,7 @@ var ts; } // Delete any subsequent imports. for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + changeTracker.delete(sourceFile, oldImportDecls[i]); } } } @@ -96738,7 +97550,7 @@ var ts; var currentLineStart = lineStarts[i]; var lineEnd = i + 1 === lineStarts.length ? sourceFile.getEnd() : lineStarts[i + 1] - 1; var lineText = sourceFile.text.substring(currentLineStart, lineEnd); - var result = lineText.match(/^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/); + var result = isRegionDelimiter(lineText); if (!result || ts.isInComment(sourceFile, currentLineStart)) { continue; } @@ -96756,6 +97568,10 @@ var ts; } } } + var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + function isRegionDelimiter(lineText) { + return regionDelimiterRegExp.exec(lineText); + } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); if (!comments) @@ -96763,11 +97579,19 @@ var ts; var firstSingleLineCommentStart = -1; var lastSingleLineCommentEnd = -1; var singleLineCommentCount = 0; - for (var _i = 0, comments_3 = comments; _i < comments_3.length; _i++) { - var _a = comments_3[_i], kind = _a.kind, pos = _a.pos, end = _a.end; + var sourceText = sourceFile.getFullText(); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var _a = comments_2[_i], kind = _a.kind, pos = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { case 2 /* SingleLineCommentTrivia */: + // never fold region delimiters into single-line comment regions + var commentText = sourceText.slice(pos, end); + if (isRegionDelimiter(commentText)) { + combineAndAddMultipleSingleLineComments(); + singleLineCommentCount = 0; + break; + } // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (singleLineCommentCount === 0) { @@ -96798,24 +97622,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* ArrowFunction */); } // 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. switch (n.parent.kind) { - case 218 /* DoStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 269 /* CatchClause */: + case 221 /* DoStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 272 /* CatchClause */: return spanForNode(n.parent); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -96830,16 +97654,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanForNode(n.parent); - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 241 /* CaseBlock */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 244 /* CaseBlock */: return spanForNode(n); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -96913,7 +97737,6 @@ var ts; if (!candidateMatch) { return undefined; } - candidateContainers = candidateContainers || []; // -1 because the last part was checked against the name, and only the rest // of the parts are checked against the container. if (dotSeparatedSegments.length - 1 > candidateContainers.length) { @@ -97150,13 +97973,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_17 = function (start) { + var _loop_16 = function (start) { if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) { return { value: start }; } }; for (var start = 0; start <= n; start++) { - var state_4 = _loop_17(start); + var state_4 = _loop_16(start); if (typeof state_4 === "object") return state_4.value; } @@ -97672,21 +98495,12 @@ var ts; (function (ts) { var Rename; (function (Rename) { - function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); + function getRenameInfo(program, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }) : undefined; return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); - function isDefinedInLibraryFile(declaration) { - if (!defaultLibFileName) { - return false; - } - var sourceFile = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - return canonicalName === getCanonicalDefaultLibName(); - } } Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { @@ -97780,7 +98594,7 @@ var ts; InvocationKind[InvocationKind["Call"] = 0] = "Call"; InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; })(InvocationKind || (InvocationKind = {})); - function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { + function getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -97788,6 +98602,12 @@ var ts; // We are at the beginning of the file return undefined; } + if (shouldCarefullyCheckContext(triggerReason)) { + // In the middle of a string, don't provide signature help unless the user explicitly requested it. + if (ts.isInString(sourceFile, position, startingToken)) { + return undefined; + } + } var argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); if (!argumentInfo) return undefined; @@ -97806,6 +98626,10 @@ var ts; return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + function shouldCarefullyCheckContext(reason) { + // Only need to be careful if the user typed a character and signature help wasn't showing. + return !!reason && reason.kind === "characterTyped"; + } function getCandidateInfo(argumentInfo, checker) { var invocation = argumentInfo.invocation; if (invocation.kind === 0 /* Call */) { @@ -97828,11 +98652,11 @@ var ts; return undefined; } var typeChecker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_17 = function (sourceFile) { var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - var _loop_19 = function (declaration) { + var _loop_18 = function (declaration) { var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -97846,7 +98670,7 @@ var ts; }; for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { var declaration = declarations_13[_i]; - var state_6 = _loop_19(declaration); + var state_6 = _loop_18(declaration); if (typeof state_6 === "object") return state_6; } @@ -97854,7 +98678,7 @@ var ts; }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - var state_5 = _loop_18(sourceFile); + var state_5 = _loop_17(sourceFile); if (typeof state_5 === "object") return state_5.value; } @@ -97923,10 +98747,10 @@ var ts; return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -98075,7 +98899,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 === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -98084,7 +98908,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - var _loop_20 = function (n) { + var _loop_19 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); }); @@ -98094,7 +98918,7 @@ var ts; } }; for (var n = node; !ts.isBlock(n) && !ts.isSourceFile(n); n = n.parent) { - var state_7 = _loop_20(n); + var state_7 = _loop_19(n); if (typeof state_7 === "object") return state_7.value; } @@ -98239,7 +99063,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var decl = ts.getDeclarationOfJSInitializer(node); if (decl) { var symbol_3 = decl.symbol; @@ -98249,7 +99073,7 @@ var ts; } } // falls through if no diagnostic was created - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -98279,11 +99103,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); // TODO: GH#18217 - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -98300,12 +99124,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -98328,7 +99152,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -98373,7 +99197,7 @@ var ts; if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return "parameter" /* parameterElement */; } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { return "const" /* constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { @@ -98416,11 +99240,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 257 /* JsxOpeningElement */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -98460,7 +99284,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 185 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 187 /* 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)) { @@ -98481,7 +99305,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 190 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* 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 @@ -98568,7 +99392,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 207 /* 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 @@ -98602,7 +99426,7 @@ var ts; } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } @@ -98612,7 +99436,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -98650,7 +99474,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 237 /* TypeAliasDeclaration */) { + else if (declaration.kind === 240 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -98667,7 +99491,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 273 /* EnumMember */) { + if (declaration.kind === 276 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -98697,17 +99521,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); break; - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -98716,7 +99540,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 243 /* ImportEqualsDeclaration */) { + if (declaration.kind === 246 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -98794,10 +99618,10 @@ var ts; // For some special property access expressions like `exports.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 === 274 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -98909,16 +99733,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 192 /* FunctionExpression */) { + if (declaration.kind === 194 /* FunctionExpression */) { return true; } - if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* FunctionDeclaration */) { + if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { + if (parent.kind === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { return false; } } @@ -99031,7 +99855,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_21 = function (opt) { + var _loop_20 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -99050,7 +99874,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_21(opt); + _loop_20(opt); } return options; } @@ -99227,10 +100051,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 262 /* JsxAttribute */: - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 265 /* JsxAttribute */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. return ts.isKeyword(node.kind) || node.kind === 71 /* Identifier */; } @@ -99711,44 +100535,44 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 220 /* ForStatement */; + return context.contextNode.kind === 223 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 171 /* ConditionalType */: - case 208 /* AsExpression */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 173 /* ConditionalType */: + case 210 /* AsExpression */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 161 /* TypePredicate */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 182 /* BindingElement */: + case 184 /* BindingElement */: // equals in type X = ... - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: // equal in p = 0; case 149 /* Parameter */: - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] case 148 /* TypeParameter */: return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; @@ -99764,19 +100588,19 @@ var ts; return contextKind === 152 /* PropertyDeclaration */ || contextKind === 151 /* PropertySignature */ || contextKind === 149 /* Parameter */ || - contextKind === 232 /* VariableDeclaration */ || + contextKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 201 /* ConditionalExpression */ || - context.contextNode.kind === 171 /* ConditionalType */; + return context.contextNode.kind === 203 /* ConditionalExpression */ || + context.contextNode.kind === 173 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 180 /* ObjectBindingPattern */ || - context.contextNode.kind === 177 /* MappedType */ || + return context.contextNode.kind === 182 /* ObjectBindingPattern */ || + context.contextNode.kind === 179 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -99802,17 +100626,17 @@ var ts; return true; } switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 184 /* ObjectLiteralExpression */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 186 /* ObjectLiteralExpression */: + case 243 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -99820,13 +100644,13 @@ var ts; case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: case 158 /* CallSignature */: - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: case 155 /* Constructor */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -99835,40 +100659,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; + return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: case 166 /* TypeLiteral */: - case 239 /* ModuleDeclaration */: - case 250 /* ExportDeclaration */: - case 251 /* NamedExports */: - case 244 /* ImportDeclaration */: - case 247 /* NamedImports */: + case 242 /* ModuleDeclaration */: + case 253 /* ExportDeclaration */: + case 254 /* NamedExports */: + case 247 /* ImportDeclaration */: + case 250 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 269 /* CatchClause */: - case 240 /* ModuleBlock */: - case 227 /* SwitchStatement */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 272 /* CatchClause */: + case 243 /* ModuleBlock */: + case 230 /* SwitchStatement */: return true; - case 213 /* Block */: { + case 216 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { return true; } } @@ -99877,31 +100701,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 217 /* IfStatement */: - case 227 /* SwitchStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 230 /* TryStatement */: - case 218 /* DoStatement */: - case 226 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 229 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 269 /* CatchClause */: + case 272 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 184 /* ObjectLiteralExpression */; + return context.contextNode.kind === 186 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 187 /* CallExpression */; + return context.contextNode.kind === 189 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 188 /* NewExpression */; + return context.contextNode.kind === 190 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -99913,28 +100737,28 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 193 /* ArrowFunction */; + return context.contextNode.kind === 195 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 179 /* ImportType */; + return context.contextNode.kind === 181 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; + return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; + return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 262 /* JsxAttribute */; + return context.nextTokenParent.kind === 265 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 262 /* JsxAttribute */; + return context.contextNode.kind === 265 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 256 /* JsxSelfClosingElement */; + return context.contextNode.kind === 259 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -99952,14 +100776,14 @@ var ts; return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 239 /* ModuleDeclaration */; + return context.contextNode.kind === 242 /* ModuleDeclaration */; } function isObjectTypeContext(context) { return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -99973,21 +100797,21 @@ var ts; } switch (parent.kind) { case 162 /* TypeReference */: - case 190 /* TypeAssertionExpression */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 192 /* TypeAssertionExpression */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -99998,16 +100822,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 190 /* TypeAssertionExpression */; + return context.contextNode.kind === 192 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 209 /* NonNullExpression */; + return context.contextNode.kind === 211 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -100241,17 +101065,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 274 /* SourceFile */: - case 213 /* Block */: - case 240 /* ModuleBlock */: + return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 277 /* SourceFile */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -100474,10 +101298,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 235 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 236 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 234 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 238 /* EnumDeclaration */: return 238 /* EnumDeclaration */; + case 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; case 156 /* GetAccessor */: return 125 /* GetKeyword */; case 157 /* SetAccessor */: return 136 /* SetKeyword */; case 154 /* MethodDeclaration */: @@ -100487,7 +101311,10 @@ var ts; // falls through case 152 /* PropertyDeclaration */: case 149 /* Parameter */: - return ts.getNameOfDeclaration(node).kind; + var name = ts.getNameOfDeclaration(node); + if (name) { + return name.kind; + } } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { @@ -100531,15 +101358,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 177 /* MappedType */) { + if (container.kind !== 179 /* MappedType */) { return false; } break; @@ -100639,7 +101466,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -101007,56 +101834,47 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword + tokenAtPosition) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } + var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); + if (jsdoc) + tokenAtPosition = jsdoc.parent; var tokenStart = tokenAtPosition.getStart(sourceFile); if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } - if (precedingToken === undefined) { - precedingToken = ts.findPrecedingToken(position, sourceFile); - } + precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); - var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? - trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : - trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; - if (commentRanges) { - for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { - var range = commentRanges_1[_i]; - // The end marker of a single-line comment does not include the newline character. - // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for closed multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // However, unterminated multi-line comments *do* contain their end. - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - // - if ((range.pos < position && position < range.end || - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()))) { - return (range.kind === 3 /* MultiLineCommentTrivia */ || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; - } - } - } - return undefined; + var commentRanges = ts.concatenate(trailingRangesOfPreviousToken, leadingCommentRangesOfNextToken); + return commentRanges && ts.find(commentRanges, function (range) { return ts.rangeContainsPositionExclusive(range, position) || + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -101064,8 +101882,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -101170,9 +101988,9 @@ var ts; if (options.indentStyle === ts.IndentStyle.None) { return 0; } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword - if (enclosingCommentRange) { + var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -101190,7 +102008,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* 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 */) { @@ -101346,7 +102164,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 === 274 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -101394,7 +102212,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -101412,13 +102230,13 @@ var ts; switch (node.parent.kind) { case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.parent.properties; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return node.parent.elements; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: @@ -101429,21 +102247,21 @@ var ts; return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 188 /* NewExpression */: - case 187 /* CallExpression */: { + case 190 /* NewExpression */: + case 189 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -101483,10 +102301,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: node = node.expression; break; default: @@ -101551,82 +102369,82 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 216 /* ExpressionStatement */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 183 /* ArrayLiteralExpression */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 184 /* ObjectLiteralExpression */: + case 219 /* ExpressionStatement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 185 /* ArrayLiteralExpression */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 177 /* MappedType */: + case 179 /* MappedType */: case 168 /* TupleType */: - case 241 /* CaseBlock */: - case 267 /* DefaultClause */: - case 266 /* CaseClause */: - case 191 /* ParenthesizedExpression */: - case 185 /* PropertyAccessExpression */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 214 /* VariableStatement */: - case 249 /* ExportAssignment */: - case 225 /* ReturnStatement */: - case 201 /* ConditionalExpression */: - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: - case 256 /* JsxSelfClosingElement */: - case 265 /* JsxExpression */: + case 244 /* CaseBlock */: + case 270 /* DefaultClause */: + case 269 /* CaseClause */: + case 193 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 217 /* VariableStatement */: + case 252 /* ExportAssignment */: + case 228 /* ReturnStatement */: + case 203 /* ConditionalExpression */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: + case 259 /* JsxSelfClosingElement */: + case 268 /* JsxExpression */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 149 /* Parameter */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 173 /* ParenthesizedType */: - case 189 /* TaggedTemplateExpression */: - case 197 /* AwaitExpression */: - case 251 /* NamedExports */: - case 247 /* NamedImports */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 175 /* ParenthesizedType */: + case 191 /* TaggedTemplateExpression */: + case 199 /* AwaitExpression */: + case 254 /* NamedExports */: + case 250 /* NamedImports */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 152 /* PropertyDeclaration */: return true; - case 232 /* VariableDeclaration */: - case 270 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 235 /* VariableDeclaration */: + case 273 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } return true; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - return childKind !== 213 /* Block */; - case 250 /* ExportDeclaration */: - return childKind !== 251 /* NamedExports */; - case 244 /* ImportDeclaration */: - return childKind !== 245 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 247 /* NamedImports */); - case 255 /* JsxElement */: - return childKind !== 258 /* JsxClosingElement */; - case 259 /* JsxFragment */: - return childKind !== 261 /* JsxClosingFragment */; - case 170 /* IntersectionType */: - case 169 /* UnionType */: + return childKind !== 216 /* Block */; + case 253 /* ExportDeclaration */: + return childKind !== 254 /* NamedExports */; + case 247 /* ImportDeclaration */: + return childKind !== 248 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); + case 258 /* JsxElement */: + return childKind !== 261 /* JsxClosingElement */; + case 262 /* JsxFragment */: + return childKind !== 264 /* JsxClosingFragment */; + case 172 /* IntersectionType */: + case 171 /* UnionType */: if (childKind === 166 /* TypeLiteral */) { return false; } @@ -101638,17 +102456,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: { - if (parent.kind !== 213 /* Block */) { + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: { + if (parent.kind !== 216 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 194 /* FunctionExpression */ || grandParent.kind === 237 /* FunctionDeclaration */); } - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return true; default: return false; @@ -101777,7 +102595,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 184 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -101793,8 +102611,8 @@ var ts; this.formatContext = formatContext; this.changes = []; this.newFiles = []; - this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map + this.deletedNodes = []; } ChangeTracker.fromContext = function (context) { return new ChangeTracker(ts.getNewLineOrDefaultFromHost(context.host, context.formatContext.options), context.formatContext); @@ -101808,13 +102626,11 @@ var ts; this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); return this; }; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { - if (options === void 0) { options = {}; } - var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); - var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); - return this; + ChangeTracker.prototype.delete = function (sourceFile, node) { + this.deletedNodes.push({ sourceFile: sourceFile, node: node, }); + }; + ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { + this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } @@ -101829,30 +102645,6 @@ var ts; var endPosition = afterEndNode === undefined ? sourceFile.text.length : getAdjustedStartPosition(sourceFile, afterEndNode, options, Position.FullStart); this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); }; - ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { - var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); - if (!containingList) { - ts.Debug.fail("node is not a list element"); - return this; - } - var index = ts.indexOfNode(containingList, node); - if (index < 0) { - return this; - } - if (containingList.length === 1) { - this.deleteNode(sourceFile, node); - return this; - } - // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. - // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. - ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice"); - this.deletedNodesInLists.add(node); - this.deleteRange(sourceFile, { - pos: startPositionToDeleteNodeInList(sourceFile, node), - end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), - }); - return this; - }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); @@ -101918,7 +102710,7 @@ var ts; // If so, we do not want to separate the node from its comment if we can. // Otherwise, add an extra new line immediately before the error span. var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); - var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); @@ -101942,7 +102734,7 @@ var ts; } } else { - endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -101961,6 +102753,9 @@ var ts; else if (ts.isParameter(before)) { return {}; } + else if (ts.isStringLiteral(before) && ts.isImportDeclaration(before.parent) || ts.isNamedImports(before)) { + return { suffix: ", " }; + } return ts.Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { @@ -102020,6 +102815,9 @@ var ts; var endPosition = this.insertNodeAfterWorker(sourceFile, after, newNode); this.insertNodeAt(sourceFile, endPosition, newNode, this.getInsertNodeAfterOptions(sourceFile, after)); }; + ChangeTracker.prototype.insertNodeAtEndOfList = function (sourceFile, list, newNode) { + this.insertNodeAt(sourceFile, list.end, newNode, { prefix: ", " }); + }; ChangeTracker.prototype.insertNodesAfter = function (sourceFile, after, newNodes) { var endPosition = this.insertNodeAfterWorker(sourceFile, after, ts.first(newNodes)); this.insertNodesAt(sourceFile, endPosition, newNodes, this.getInsertNodeAfterOptions(sourceFile, after)); @@ -102040,32 +102838,34 @@ var ts; return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { - if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) { - return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - } - else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { - return { suffix: this.newLineCharacter }; - } - else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { - return { prefix: ", " }; - } - else if (ts.isPropertyAssignment(node)) { - return { suffix: "," + this.newLineCharacter }; - } - else if (ts.isParameter(node)) { - return {}; + switch (node.kind) { + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + case 235 /* VariableDeclaration */: + case 9 /* StringLiteral */: + case 71 /* Identifier */: + return { prefix: ", " }; + case 273 /* PropertyAssignment */: + return { suffix: "," + this.newLineCharacter }; + case 84 /* ExportKeyword */: + return { prefix: " " }; + case 149 /* Parameter */: + return {}; + default: + ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it + return { suffix: this.newLineCharacter }; } - return ts.Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 193 /* ArrowFunction */) { + if (node.kind === 195 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); - this.deleteNode(sourceFile, arrow); + deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` @@ -102073,14 +102873,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); } - if (node.body.kind !== 213 /* Block */) { + if (node.body.kind !== 216 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -102106,7 +102906,7 @@ var ts; if (index !== containingList.length - 1) { // any element except the last one // use next sibling as an anchor - var nextToken = ts.getTokenAtPosition(sourceFile, after.end, /*includeJsDocComment*/ false); + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); if (nextToken && isSeparator(after, nextToken)) { // for list // a, b, c @@ -102211,14 +103011,25 @@ var ts; } }); }; - ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () { + ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - this.deletedNodesInLists.forEach(function (node) { + var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var _loop_21 = function (sourceFile, node) { + if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { + deleteDeclaration.deleteDeclaration(this_1, deletedNodesInLists, sourceFile, node); + } + }; + var this_1 = this; + for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { + var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; + _loop_21(sourceFile, node); + } + deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (node !== ts.last(list)) return; - var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2); + var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !deletedNodesInLists.has(n); }, list.length - 2); if (lastNonDeletedIndex !== -1) { _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) }); } @@ -102231,8 +103042,8 @@ var ts; * so we can only call this once and can't get the non-formatted text separately. */ ChangeTracker.prototype.getChanges = function (validate) { + this.finishDeleteDeclarations(); this.finishClassesWithNodesInsertedAtStart(); - this.finishTrailingCommaAfterDeletingNodesInList(); var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) { var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements; @@ -102329,8 +103140,8 @@ var ts; })(changesToText || (changesToText = {})); function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { - var change = changes[i]; - text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + var _a = changes[i], span = _a.span, newText = _a.newText; + text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); } return text; } @@ -102532,6 +103343,177 @@ var ts; return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } + var deleteDeclaration; + (function (deleteDeclaration_1) { + function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { + switch (node.kind) { + case 149 /* Parameter */: { + var oldFunction = node.parent; + if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { + // Lambdas with exactly one parameter are special because, after removal, there + // must be an empty parameter list (i.e. `()`) and this won't necessarily be the + // case if the parameter is simply removed (e.g. in `x => 1`). + var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, + /*parameters*/ undefined, // TODO: GH#18217 + oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); + // Drop leading and trailing trivia of the new function because we're only going + // to replace the span (vs the full span) of the old function - the old leading + // and trailing trivia will remain. + ts.suppressLeadingAndTrailingTrivia(newFunction); + changes.replaceNode(sourceFile, oldFunction, newFunction); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 247 /* ImportDeclaration */: + deleteNode(changes, sourceFile, node, + // For first import, leave header comment in place + node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); + break; + case 184 /* BindingElement */: + var pattern = node.parent; + var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + if (preserveComma) { + deleteNode(changes, sourceFile, node); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 235 /* VariableDeclaration */: + deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); + break; + case 148 /* TypeParameter */: { + var typeParameters = ts.getEffectiveTypeParameterDeclarations(node.parent); + if (typeParameters.length === 1) { + var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; + var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1); + var nextToken = ts.getTokenAtPosition(sourceFile, end); + ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); + ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); + changes.deleteNodeRange(sourceFile, previousToken, nextToken); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 251 /* ImportSpecifier */: + var namedImports = node.parent; + if (namedImports.elements.length === 1) { + deleteImportBinding(changes, sourceFile, namedImports); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 249 /* NamespaceImport */: + deleteImportBinding(changes, sourceFile, node); + break; + default: + if (ts.isImportClause(node.parent) && node.parent.name === node) { + deleteDefaultImport(changes, sourceFile, node.parent); + } + else if (ts.isCallLikeExpression(node.parent)) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + else { + deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + } + } + } + deleteDeclaration_1.deleteDeclaration = deleteDeclaration; + function deleteDefaultImport(changes, sourceFile, importClause) { + if (!importClause.namedBindings) { + // Delete the whole import + deleteNode(changes, sourceFile, importClause.parent); + } + else { + // import |d,| * as ns from './file' + var start = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26 /* CommaToken */) { + // shift first non-whitespace position after comma to the start position of the node + var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); + changes.deleteRange(sourceFile, { pos: start, end: end }); + } + else { + deleteNode(changes, sourceFile, importClause.name); + } + } + } + function deleteImportBinding(changes, sourceFile, node) { + if (node.parent.name) { + // Delete named imports while preserving the default import + // import d|, * as ns| from './file' + // import d|, { a }| from './file' + var previousToken = ts.Debug.assertDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1)); + changes.deleteRange(sourceFile, { pos: previousToken.getStart(sourceFile), end: node.end }); + } + else { + // Delete the entire import declaration + // |import * as ns from './file'| + // |import { a } from './file'| + var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + deleteNode(changes, sourceFile, importDecl); + } + } + function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { + var parent = node.parent; + if (parent.kind === 272 /* CatchClause */) { + // TODO: There's currently no unused diagnostic for this, could be a suggestion + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + return; + } + if (parent.declarations.length !== 1) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + return; + } + var gp = parent.parent; + switch (gp.kind) { + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: + changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); + break; + case 223 /* ForStatement */: + deleteNode(changes, sourceFile, parent); + break; + case 217 /* VariableStatement */: + deleteNode(changes, sourceFile, gp); + break; + default: + ts.Debug.assertNever(gp); + } + } + })(deleteDeclaration || (deleteDeclaration = {})); + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + // Exported for tests only! (TODO: improve tests to not need this) + function deleteNode(changes, sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + changes.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + textChanges_3.deleteNode = deleteNode; + function deleteNodeInList(changes, deletedNodesInLists, sourceFile, node) { + var containingList = ts.Debug.assertDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile)); + var index = ts.indexOfNode(containingList, node); + ts.Debug.assert(index !== -1); + if (containingList.length === 1) { + deleteNode(changes, sourceFile, node); + return; + } + // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. + // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. + ts.Debug.assert(!deletedNodesInLists.has(node), "Deleting a node twice"); + deletedNodesInLists.add(node); + changes.deleteRange(sourceFile, { + pos: startPositionToDeleteNodeInList(sourceFile, node), + end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), + }); + } })(textChanges = ts.textChanges || (ts.textChanges = {})); })(ts || (ts = {})); /* @internal */ @@ -102587,15 +103569,14 @@ var ts; function createCombinedCodeActions(changes, commands) { return { changes: changes, commands: commands }; } + codefix.createCombinedCodeActions = createCombinedCodeActions; function createFileTextChanges(fileName, textChanges) { return { fileName: fileName, textChanges: textChanges }; } codefix.createFileTextChanges = createFileTextChanges; function codeFixAll(context, errorCodes, use) { var commands = []; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { - return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); - }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); }); return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } codefix.codeFixAll = codeFixAll; @@ -102608,6 +103589,7 @@ var ts; } } } + codefix.eachDiagnostic = eachDiagnostic; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -102658,7 +103640,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, }); function makeChange(changeTracker, sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var decorator = ts.findAncestor(token, ts.isDecorator); ts.Debug.assert(!!decorator, "Expected position to be owned by a decorator."); var replacement = ts.createCall(decorator.expression, /*typeArguments*/ undefined, /*argumentsArray*/ undefined); @@ -102690,7 +103672,7 @@ var ts; }); }, }); function getDeclaration(file, pos) { - var name = ts.getTokenAtPosition(file, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(file, pos); // For an arrow function with no name, 'name' lands on the first parameter. return ts.tryCast(ts.isParameter(name.parent) ? name.parent.parent : name.parent, parameterShouldGetTypeFromJSDoc); } @@ -102737,24 +103719,24 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 232 /* VariableDeclaration */ || + node.kind === 235 /* VariableDeclaration */ || node.kind === 151 /* PropertySignature */ || node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 162 /* TypeReference */: return transformJSDocTypeReference(node); @@ -102778,7 +103760,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 288 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -102844,8 +103826,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, err) { return doChange(changes, err.file, err.start, context.program.getTypeChecker()); }); }, }); function doChange(changes, sourceFile, position, checker) { - var deletedNodes = []; - var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false)); + var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; @@ -102854,20 +103835,20 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); + changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { ts.copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 - deleteNode(precedingNode); + changes.delete(sourceFile, precedingNode); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + changes.delete(sourceFile, ctorDeclaration); } break; } @@ -102877,22 +103858,6 @@ var ts; ts.copyComments(ctorDeclaration, newClassDeclaration, sourceFile); // Because the preceding node could be touched, we need to insert nodes before delete nodes. changes.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration); - for (var _i = 0, deletedNodes_1 = deletedNodes; _i < deletedNodes_1.length; _i++) { - var _a = deletedNodes_1[_i], node = _a.node, inList = _a.inList; - if (inList) { - changes.deleteNodeInList(sourceFile, node); - } - else { - changes.deleteNode(sourceFile, node); - } - } - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - // If parent node has already been deleted, do nothing - if (!deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n.node); })) { - deletedNodes.push({ node: node, inList: inList }); - } - } function createClassElementsFromSymbol(symbol) { var memberElements = []; // all instance members are stored in the "member" array of symbol @@ -102930,15 +103895,15 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 216 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 219 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); + changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -102946,12 +103911,12 @@ var ts; ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 193 /* ArrowFunction */: { + case 195 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 213 /* Block */) { + if (arrowFunctionBody.kind === 216 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -102979,7 +103944,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { @@ -103043,10 +104008,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -103099,20 +104064,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 187 /* CallExpression */: { + case 189 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -103154,8 +104119,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: { + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -103178,7 +104143,7 @@ var ts; if (ts.isExportsOrModuleExportsOrAlias(sourceFile, left)) { if (ts.isExportsOrModuleExportsOrAlias(sourceFile, right)) { // `const alias = module.exports;` or `module.exports = alias;` can be removed. - changes.deleteNode(sourceFile, assignment.parent); + changes.delete(sourceFile, assignment.parent); } else { var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right) @@ -103209,10 +104174,10 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 271 /* ShorthandPropertyAssignment */: - case 272 /* SpreadAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 275 /* SpreadAssignment */: return undefined; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); @@ -103269,7 +104234,7 @@ var ts; changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); if (semi) - changes.deleteNode(sourceFile, semi, { useNonAdjustedEndPosition: true }); + changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` @@ -103280,7 +104245,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -103288,10 +104253,10 @@ var ts; } } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -103309,7 +104274,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: { + case 182 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -103320,7 +104285,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 181 /* ArrayBindingPattern */: { + case 183 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -103403,11 +104368,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node; - case 182 /* BindingElement */: + case 184 /* BindingElement */: return parent.propertyName !== node; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -103466,7 +104431,7 @@ var ts; }); }, }); function getQualifiedName(sourceFile, pos) { - var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ true), ts.isQualifiedName); + var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), ts.isQualifiedName); ts.Debug.assert(!!qualifiedName, "Expected position to be owned by a qualified name."); return ts.isIdentifier(qualifiedName.left) ? qualifiedName : undefined; } @@ -103511,7 +104476,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -103539,7 +104504,7 @@ var ts; } } function getHeritageClauseSymbolTable(classDeclaration, checker) { - var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var heritageClauseNode = ts.getEffectiveBaseTypeNode(classDeclaration); if (!heritageClauseNode) return ts.createSymbolTable(); var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); @@ -103553,42 +104518,109 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var ChangeTracker = ts.textChanges.ChangeTracker; + codefix.importFixId = "fixMissingImport"; + var errorCodes = [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.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, + ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, + ]; codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics.Cannot_find_name_0.code, - ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.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, - ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, - ], - getCodeActions: function (context) { return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(context) - : getActionsForNonUMDImport(context); }, - // TODO: GH#20315 - fixIds: [], - getAllCodeActions: ts.notImplemented, + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span; + var info = getFixesInfo(context, errorCode, span.start); + if (!info) + return undefined; + var fixes = info.fixes, symbolName = info.symbolName; + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference); }); + }, + fixIds: [codefix.importFixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, preferences = context.preferences; + // Namespace fixes don't conflict, so just build a list. + var addToNamespace = []; + // Keys are import clause node IDs. + var addToExisting = ts.createMap(); + // Keys are module specifiers. + var newImports = ts.createMap(); + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getFixesInfo(context, diag.code, diag.start); + if (!info || !info.fixes.length) + return; + var fixes = info.fixes, symbolName = info.symbolName; + var fix = ts.first(fixes); + switch (fix.kind) { + case 0 /* UseNamespace */: + addToNamespace.push(fix); + break; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + var key = String(ts.getNodeId(importClause)); + var entry = addToExisting.get(key); + if (!entry) { + addToExisting.set(key, entry = { importClause: importClause, defaultImport: undefined, namedImports: [] }); + } + if (importKind === 0 /* Named */) { + ts.pushIfUnique(entry.namedImports, symbolName); + } + else { + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + } + break; + } + case 2 /* AddNew */: { + var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind; + var entry = newImports.get(moduleSpecifier); + if (!entry) { + newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined }); + } + switch (importKind) { + case 1 /* Default */: + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + break; + case 0 /* Named */: + ts.pushIfUnique(entry.namedImports, symbolName); + break; + case 3 /* Equals */: + case 2 /* Namespace */: + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; + break; + } + break; + } + default: + ts.Debug.assertNever(fix); + } + }); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) { + var fix = addToNamespace_1[_i]; + addNamespaceQualifier(changes, sourceFile, fix); + } + addToExisting.forEach(function (_a) { + var importClause = _a.importClause, defaultImport = _a.defaultImport, namedImports = _a.namedImports; + doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports); + }); + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + newImports.forEach(function (imports, moduleSpecifier) { + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports); + }); + })); + }, }); - function createCodeAction(descriptionDiagnostic, diagnosticArgs, changes) { - // TODO: GH#20315 - return codefix.createCodeFixActionNoFixId("import", changes, [descriptionDiagnostic].concat(diagnosticArgs)); - } - function convertToImportCodeFixContext(context, symbolToken, symbolName) { - var program = context.program; - var checker = program.getTypeChecker(); - return { - host: context.host, - formatContext: context.formatContext, - sourceFile: context.sourceFile, - program: program, - checker: checker, - compilerOptions: program.getCompilerOptions(), - getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), - symbolName: symbolName, - symbolToken: symbolToken, - preferences: context.preferences, - }; - } + // Sorted with the preferred fix coming first. + var ImportFixKind; + (function (ImportFixKind) { + ImportFixKind[ImportFixKind["UseNamespace"] = 0] = "UseNamespace"; + ImportFixKind[ImportFixKind["AddToExisting"] = 1] = "AddToExisting"; + ImportFixKind[ImportFixKind["AddNew"] = 2] = "AddNew"; + })(ImportFixKind || (ImportFixKind = {})); var ImportKind; (function (ImportKind) { ImportKind[ImportKind["Named"] = 0] = "Named"; @@ -103596,13 +104628,13 @@ var ts; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; })(ImportKind || (ImportKind = {})); - function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, symbolToken, preferences) { + function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, allSourceFiles, formatContext, symbolToken, preferences) { var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, checker, allSourceFiles); ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, exportInfos, host, preferences)).moduleSpecifier; - var ctx = { host: host, program: program, checker: checker, compilerOptions: compilerOptions, sourceFile: sourceFile, formatContext: formatContext, symbolName: symbolName, getCanonicalFileName: getCanonicalFileName, symbolToken: symbolToken, preferences: preferences }; - return { moduleSpecifier: moduleSpecifier, codeAction: ts.first(getCodeActionsForImport(exportInfos, ctx)) }; + var fix = ts.first(getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences)); + return { moduleSpecifier: moduleSpecifier, codeAction: codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences)) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, checker, allSourceFiles) { @@ -103622,23 +104654,16 @@ var ts; }); return result; } - function getCodeActionsForImport(exportInfos, context) { - var result = []; - getCodeActionsForImport_separateExistingAndNew(exportInfos, context, result, result); - return result; - } - function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, context.checker, context.sourceFile); }); - ts.append(useExisting, tryUseExistingNamespaceImport(existingImports, context, context.symbolToken, context.checker)); - var addToExisting = tryAddToExistingImport(existingImports, context); - if (addToExisting) { - useExisting.push(addToExisting); - } - else { // Don't bother providing an action to add a new import if we can add to an existing one. - getCodeActionsForAddImport(exportInfos, context, existingImports, addNew); - } - } - function tryUseExistingNamespaceImport(existingImports, context, symbolToken, checker) { + function getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences) { + var checker = program.getTypeChecker(); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var useNamespace = tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker); + var addToExisting = tryAddToExistingImport(existingImports); + // Don't bother providing an action to add a new import if we can add to an existing one. + var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); + return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + } + function tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -103655,29 +104680,31 @@ var ts; var declaration = _a.declaration; var namespace = getNamespaceImportName(declaration); if (namespace) { - var moduleSymbol = namespace && checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); - if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { - return getCodeActionForUseExistingNamespaceImport(namespace.text, context, symbolToken); + var moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { + return { kind: 0 /* UseNamespace */, namespacePrefix: namespace.text, symbolToken: symbolToken }; } } }); } - function tryAddToExistingImport(existingImports, context) { + function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 244 /* ImportDeclaration */ && declaration.importClause) { - var changes = tryUpdateExistingImport(context, declaration.importClause, importKind); - if (changes) { - var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); - return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [context.symbolName, moduleSpecifierWithoutQuotes], changes); - } - } + if (declaration.kind !== 247 /* ImportDeclaration */) + return undefined; + var importClause = declaration.importClause; + if (!importClause) + return undefined; + var name = importClause.name, namedBindings = importClause.namedBindings; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + ? { kind: 1 /* AddToExisting */, importClause: importClause, importKind: importKind } + : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 244 /* ImportDeclaration */) { + if (declaration.kind === 247 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -103688,141 +104715,61 @@ var ts; var imports = _b.imports; return ts.mapDefined(imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } - function getCodeActionForNewImport(context, _a) { - var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; - var sourceFile = context.sourceFile, symbolName = context.symbolName, preferences = context.preferences; - var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); - var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifierWithoutQuotes, ts.getQuotePreference(sourceFile, preferences)); - var importDecl = importKind !== 3 /* Equals */ - ? ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClauseOfKind(importKind, symbolName), quotedModuleSpecifier) - : ts.createImportEqualsDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createIdentifier(symbolName), ts.createExternalModuleReference(quotedModuleSpecifier)); - var changes = ChangeTracker.with(context, function (t) { return ts.insertImport(t, sourceFile, importDecl); }); - // 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 separating code and import statements. - return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); - } - function createImportClauseOfKind(kind, symbolName) { - var id = ts.createIdentifier(symbolName); - switch (kind) { - case 1 /* Default */: - return ts.createImportClause(id, /*namedBindings*/ undefined); - case 2 /* Namespace */: - return ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(id)); - case 0 /* Named */: - return ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, id)])); - default: - ts.Debug.assertNever(kind); - } - } function getNewImportInfos(program, sourceFile, moduleSymbols, host, preferences) { var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var modulePathsGroups = ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences); - return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); + return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ kind: 2 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); }); // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together return ts.flatten(choicesForEachExportingModule.sort(function (a, b) { return ts.first(a).moduleSpecifier.length - ts.first(b).moduleSpecifier.length; })); } - function getCodeActionsForAddImport(exportInfos, ctx, existingImports, addNew) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); - var newImportInfos = existingDeclaration - ? [existingDeclaration] - : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.host, ctx.preferences); - for (var _i = 0, newImportInfos_1 = newImportInfos; _i < newImportInfos_1.length; _i++) { - var info = newImportInfos_1[_i]; - addNew.push(getCodeActionForNewImport(ctx, info)); - } + return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 244 /* ImportDeclaration */ + var expression = declaration.kind === 247 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; - return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; - } - function tryUpdateExistingImport(context, importClause, importKind) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - var name = importClause.name; - var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 - switch (importKind) { - case 1 /* Default */: - return name ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(ts.createIdentifier(symbolName), namedBindings)); - }); - case 0 /* Named */: { - var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - if (namedBindings && namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length !== 0) { - // There are already named imports; add another. - return ChangeTracker.with(context, function (t) { return t.insertNodeInListAfter(sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier_1); }); - } - if (!namedBindings || namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length === 0) { - return ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); - }); - } - return undefined; - } - case 2 /* Namespace */: - return namedBindings ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamespaceImport(ts.createIdentifier(symbolName)))); - }); - case 3 /* Equals */: - return undefined; - default: - ts.Debug.assertNever(importKind); - } + return expression && ts.isStringLiteral(expression) ? { kind: 2 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix, context, symbolToken) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - var changes = ChangeTracker.with(context, function (tracker) { - return tracker.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); - }); - return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); + function getFixesInfo(context, errorCode, pos) { + var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos); + var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getFixesInfoForUMDImport(context, symbolToken) + : getFixesInfoForNonUMDImport(context, symbolToken); + return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } - function getActionsForUMDImport(context) { - var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); - var checker = context.program.getTypeChecker(); - var umdSymbol; - if (ts.isIdentifier(token)) { - // try the identifier to see if it is the umd symbol - umdSymbol = checker.getSymbolAtLocation(token); - } - if (!ts.isUMDExportSymbol(umdSymbol)) { - // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. - var parent = token.parent; - var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(parent); - if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 260 /* JsxOpeningFragment */) { - umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); - } - } - if (ts.isUMDExportSymbol(umdSymbol)) { - var symbol = checker.getAliasedSymbol(umdSymbol); - if (symbol) { - return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(context.program.getCompilerOptions()) }], convertToImportCodeFixContext(context, token, umdSymbol.name)); - } - } - return undefined; + function getFixesInfoForUMDImport(_a, token) { + var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; + var checker = program.getTypeChecker(); + var umdSymbol = getUmdSymbol(token, checker); + if (!umdSymbol) + return undefined; + var symbol = checker.getAliasedSymbol(umdSymbol); + var symbolName = umdSymbol.name; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()) }]; + var fixes = getFixForImport(exportInfos, symbolName, token, program, sourceFile, host, preferences); + return { fixes: fixes, symbolName: symbolName }; + } + function getUmdSymbol(token, checker) { + // try the identifier to see if it is the umd symbol + var umdSymbol = ts.isIdentifier(token) ? checker.getSymbolAtLocation(token) : undefined; + if (ts.isUMDExportSymbol(umdSymbol)) + return umdSymbol; + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + var parent = token.parent; + return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67216319 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + : undefined; } function getUmdImportKind(compilerOptions) { // Import a synthetic `default` if enabled. @@ -103846,11 +104793,10 @@ var ts; return ts.Debug.assertNever(moduleKind); } } - function getActionsForNonUMDImport(context) { + function getFixesInfoForNonUMDImport(_a, symbolToken) { + var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. - var sourceFile = context.sourceFile, span = context.span, program = context.program, cancellationToken = context.cancellationToken; var checker = program.getTypeChecker(); - var symbolToken = ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false); // If we're at ``, we must check if `Foo` is already in scope, and if so, get an import for `React` instead. var symbolName = ts.isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken @@ -103860,14 +104806,14 @@ var ts; if (!symbolName) return undefined; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default"); - var addToExistingDeclaration = []; - var addNewDeclaration = []; - getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).forEach(function (exportInfos) { - getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); - }); - return addToExistingDeclaration.concat(addNewDeclaration); + ts.Debug.assert(symbolName !== "default" /* Default */); + var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + var _ = _a[0], exportInfos = _a[1]; + return getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences); + })); + return { fixes: fixes, symbolName: symbolName }; } + // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). @@ -103880,35 +104826,121 @@ var ts; // check the default export var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) { - var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); - if ((localSymbol && localSymbol.escapedName === symbolName || - getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target) === symbolName) && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { - addSymbol(moduleSymbol, localSymbol || defaultExport, 1 /* Default */); + var info = getDefaultExportInfo(defaultExport, moduleSymbol, program); + if (info && info.name === symbolName && symbolHasMeaning(info.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultExport, 1 /* Default */); } } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } - function getEscapedNameForExportDefault(symbol) { - return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { - if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.escapedText; - } + }); + return originalSymbolToExportInfos; + } + function getDefaultExportInfo(defaultExport, moduleSymbol, program) { + var checker = program.getTypeChecker(); + var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) + return { symbolForMeaning: localSymbol, name: localSymbol.name }; + var name = getNameForExportDefault(defaultExport); + if (name !== undefined) + return { symbolForMeaning: defaultExport, name: name }; + if (defaultExport.flags & 2097152 /* Alias */) { + var aliased = checker.getAliasedSymbol(defaultExport); + return getDefaultExportInfo(aliased, ts.Debug.assertDefined(aliased.parent), program); + } + else { + var moduleName = moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target); + return moduleName === undefined ? undefined : { symbolForMeaning: defaultExport, name: moduleName }; + } + } + function getNameForExportDefault(symbol) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + if (ts.isExportAssignment(declaration)) { + if (ts.isIdentifier(declaration.expression)) { + return declaration.expression.text; + } + } + else if (ts.isExportSpecifier(declaration)) { + ts.Debug.assert(declaration.name.text === "default" /* Default */); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } + function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) { + var diag; + var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { + diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference); + }); + return codefix.createCodeFixAction("import", changes, diag, codefix.importFixId, ts.Diagnostics.Add_all_missing_imports); + } + function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) { + switch (fix.kind) { + case 0 /* UseNamespace */: + addNamespaceQualifier(changes, sourceFile, fix); + return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + doAddExistingFix(changes, sourceFile, importClause, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(importClause.parent.moduleSpecifier.getText()); + return [ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; + } + case 2 /* AddNew */: { + var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier; + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === 1 /* Default */ ? { defaultImport: symbolName, namedImports: ts.emptyArray, namespaceLikeImport: undefined } + : importKind === 0 /* Named */ ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined } + : { defaultImport: undefined, namedImports: ts.emptyArray, namespaceLikeImport: { importKind: importKind, name: symbolName } }); + return [ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; + } + default: + return ts.Debug.assertNever(fix); + } + } + function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { + if (defaultImport) { + ts.Debug.assert(!clause.name); + changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); + } + if (namedImports.length) { + var specifiers = namedImports.map(function (name) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); }); + if (clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements.length) { + for (var _i = 0, specifiers_1 = specifiers; _i < specifiers_1.length; _i++) { + var spec = specifiers_1[_i]; + changes.insertNodeInListAfter(sourceFile, ts.last(ts.cast(clause.namedBindings, ts.isNamedImports).elements), spec); + } + } + else { + if (specifiers.length) { + var namedImports_1 = ts.createNamedImports(specifiers); + if (clause.namedBindings) { + changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } - else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - return declaration.propertyName && declaration.propertyName.escapedText; + else { + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); } - }); + } } - }); - return originalSymbolToExportInfos; + } + } + function addNamespaceQualifier(changes, sourceFile, _a) { + var namespacePrefix = _a.namespacePrefix, symbolToken = _a.symbolToken; + changes.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); + } + function addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, _a) { + var defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport; + var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); + if (defaultImport !== undefined || namedImports.length) { + ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); + } + if (namespaceLikeImport) { + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ + ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) + : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + } } - function checkSymbolHasMeaning(_a, meaning) { + function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } @@ -104009,7 +105041,7 @@ var ts; // This is the identifier of the misspelled word. eg: // this.speling = 1; // ^^^^^^^ - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); // TODO: GH#15852 + var node = ts.getTokenAtPosition(sourceFile, pos); var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { @@ -104081,46 +105113,99 @@ var ts; var info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, context.preferences); + if (info.kind === InfoKind.enum) { + var token_1 = info.token, parentDeclaration_1 = info.parentDeclaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), token_1, parentDeclaration_1); }); + return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_missing_enum_member_0, token_1.text], fixId, ts.Diagnostics.Add_all_missing_members)]; + } + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); var addMember = inJs ? - ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, token.text, makeStatic)) : - getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, classDeclaration, token, makeStatic); + ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic)) : + getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, parentDeclaration, token, makeStatic); return ts.concatenate(ts.singleElementArray(methodCodeAction), addMember); }, fixIds: [fixId], getAllCodeActions: function (context) { - var seenNames = ts.createMap(); - return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var program = context.program, preferences = context.preferences; - var info = getInfo(diag.file, diag.start, program.getTypeChecker()); - if (!info) - return; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - if (!ts.addToSeen(seenNames, token.text)) { - return; - } - // Always prefer to add a method declaration if possible. - if (call) { - addMethodDeclaration(changes, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, preferences); - } - else { - if (inJs) { - addMissingMemberInJs(changes, classDeclarationSourceFile, classDeclaration, token.text, makeStatic); + var program = context.program, preferences = context.preferences; + var checker = program.getTypeChecker(); + var seen = ts.createMap(); + var classToMembers = new ts.NodeMap(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(diag.file, diag.start, checker); + if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { + return; + } + if (info.kind === InfoKind.enum) { + var token = info.token, parentDeclaration = info.parentDeclaration; + addEnumMemberDeclaration(changes, checker, token, parentDeclaration); } else { - var typeNode = getTypeNode(program.getTypeChecker(), classDeclaration, token); - addPropertyDeclaration(changes, classDeclarationSourceFile, classDeclaration, token.text, typeNode, makeStatic); + var parentDeclaration = info.parentDeclaration, token_2 = info.token; + var infos = classToMembers.getOrUpdate(parentDeclaration, function () { return []; }); + if (!infos.some(function (i) { return i.token.text === token_2.text; })) + infos.push(info); } - } - }); + }); + classToMembers.forEach(function (infos, classDeclaration) { + var superClasses = getAllSuperClasses(classDeclaration, checker); + var _loop_23 = function (info) { + // If some superclass added this property, don't add it again. + if (superClasses.some(function (superClass) { + var superInfos = classToMembers.get(superClass); + return !!superInfos && superInfos.some(function (_a) { + var token = _a.token; + return token.text === info.token.text; + }); + })) + return "continue"; + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + // Always prefer to add a method declaration if possible. + if (call) { + addMethodDeclaration(context, changes, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + } + else { + if (inJs) { + addMissingMemberInJs(changes, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic); + } + else { + var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token); + addPropertyDeclaration(changes, classDeclarationSourceFile, parentDeclaration, token.text, typeNode, makeStatic); + } + } + }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + _loop_23(info); + } + }); + })); }, }); + function getAllSuperClasses(cls, checker) { + var res = []; + while (cls) { + var superElement = ts.getClassExtendsHeritageElement(cls); + var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); + var superDecl = superSymbol && ts.find(superSymbol.declarations, ts.isClassLike); + if (superDecl) { + res.push(superDecl); + } + cls = superDecl; + } + return res; + } + var InfoKind; + (function (InfoKind) { + InfoKind[InfoKind["enum"] = 0] = "enum"; + InfoKind[InfoKind["class"] = 1] = "class"; + })(InfoKind || (InfoKind = {})); function getInfo(tokenSourceFile, tokenPos, checker) { // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ - var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos); if (!ts.isIdentifier(token)) { return undefined; } @@ -104129,14 +105214,21 @@ var ts; return undefined; var leftExpressionType = ts.skipConstraint(checker.getTypeAtLocation(parent.expression)); var symbol = leftExpressionType.symbol; - var classDeclaration = symbol && symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); - if (!classDeclaration) + if (!symbol || !symbol.declarations) return undefined; - var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); - var classDeclarationSourceFile = classDeclaration.getSourceFile(); - var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); - var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { token: token, classDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); + if (classDeclaration) { + var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); + var classDeclarationSourceFile = classDeclaration.getSourceFile(); + var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); + var call = ts.tryCast(parent.parent, ts.isCallExpression); + return { kind: InfoKind.class, token: token, parentDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + } + var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); + if (enumDeclaration) { + return { kind: InfoKind.enum, token: token, parentDeclaration: enumDeclaration }; + } + return undefined; } function getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic); }); @@ -104145,7 +105237,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 205 /* ClassExpression */) { + if (classDeclaration.kind === 207 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -104171,7 +105263,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 200 /* BinaryExpression */) { + if (token.parent.parent.kind === 202 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); // TODO: GH#18217 @@ -104225,11 +105317,11 @@ var ts; return codefix.createCodeFixActionNoFixId(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]); } function getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, token.text], fixId, ts.Diagnostics.Add_all_missing_members); } - function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); + function addMethodDeclaration(context, changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { + var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences); var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); @@ -104238,6 +105330,19 @@ var ts; changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); } } + function addEnumMemberDeclaration(changes, checker, token, enumDeclaration) { + /** + * create initializer only literal enum that has string initializer. + * value of initializer is a string literal that equal to name of enum member. + * numeric enum or empty enum will not create initializer. + */ + var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { + var type = checker.getTypeAtLocation(member); + return !!(type && type.flags & 68 /* StringLike */); + }); + var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); + changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104271,7 +105376,7 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function getTypesPackageNameToInstall(host, sourceFile, pos, diagCode) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), ts.isStringLiteral).text; + var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) @@ -104312,11 +105417,11 @@ var ts; function getClass(sourceFile, pos) { // Token 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, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.cast(token.parent, ts.isClassLike); } function addMissingMembers(classDeclaration, sourceFile, checker, changeTracker, preferences) { - var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var extendsNode = ts.getEffectiveBaseTypeNode(classDeclaration); var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. @@ -104366,10 +105471,10 @@ var ts; }); function doChange(changes, sourceFile, constructor, superCall) { changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall); - changes.deleteNode(sourceFile, superCall); + changes.delete(sourceFile, superCall); } function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); if (token.kind !== 99 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); @@ -104408,7 +105513,7 @@ var ts; }); }, }); function getNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); return token.parent; } @@ -104444,7 +105549,7 @@ var ts; }); }, }); function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; @@ -104500,7 +105605,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos, diagCode) { - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(node)) return undefined; return { node: node, className: diagCode === didYouMeanStaticMemberCode ? ts.getContainingClass(node).name.text : undefined }; @@ -104534,25 +105639,30 @@ var ts; getCodeActions: function (context) { var errorCode = context.errorCode, sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); - var startToken = ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); - var importDecl = tryGetFullImport(startToken); + var sourceFiles = program.getSourceFiles(); + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var importDecl = tryGetFullImport(token); if (importDecl) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, importDecl); }); return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteFullDestructure(token, t, sourceFile, checker, sourceFiles, /*isFixAll*/ false); + }); if (delDestructure.length) { return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(t, sourceFile, startToken, /*deleted*/ undefined); }); + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(sourceFile, token, t); }); if (delVar.length) { return [codefix.createCodeFixAction(fixName, delVar, ts.Diagnostics.Remove_variable_statement, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var token = getToken(sourceFile, ts.textSpanEnd(context.span)); var result = []; - var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteDeclaration(sourceFile, token, t, checker, sourceFiles, /*isFixAll*/ false); + }); if (deletion.length) { - result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); + var name = ts.isComputedPropertyName(token.parent) ? token.parent : token; + result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, name.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } var prefix = ts.textChanges.ChangeTracker.with(context, function (t) { return tryPrefixDeclaration(t, errorCode, sourceFile, token); }); if (prefix.length) { @@ -104562,32 +105672,28 @@ var ts; }, fixIds: [fixIdPrefix, fixIdDelete], getAllCodeActions: function (context) { - // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors. - var deleted = new ts.NodeSet(); var sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); + var sourceFiles = program.getSourceFiles(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); - var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); + var token = ts.getTokenAtPosition(sourceFile, diag.start); switch (context.fixId) { case fixIdPrefix: if (ts.isIdentifier(token) && canPrefix(token)) { tryPrefixDeclaration(changes, diag.code, sourceFile, token); } break; - case fixIdDelete: - // Ignore if this range was already deleted. - if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) - break; - var importDecl = tryGetFullImport(startToken); + case fixIdDelete: { + var importDecl = tryGetFullImport(token); if (importDecl) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } - else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && - !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); + else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(sourceFile, token, changes)) { + tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, /*isFixAll*/ true); } break; + } default: ts.Debug.fail(JSON.stringify(context.fixId)); } @@ -104595,49 +105701,29 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(startToken) { - return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; + function tryGetFullImport(token) { + return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { - if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) + function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { + if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; - var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; - switch (decl.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(decl, checker, isFixAll)) - break; - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNodeInList(sourceFile, decl); - break; - case 182 /* BindingElement */: - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNode(sourceFile, decl); - break; - default: - return ts.Debug.assertNever(decl); + var decl = token.parent.parent; + if (decl.kind === 149 /* Parameter */) { + tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); + } + else { + changes.delete(sourceFile, decl); } return true; } - function tryDeleteFullVariableStatement(changes, sourceFile, startToken, deletedAncestors) { - var declarationList = ts.tryCast(startToken.parent, ts.isVariableDeclarationList); - if (declarationList && declarationList.getChildren(sourceFile)[0] === startToken) { - if (deletedAncestors) - deletedAncestors.add(declarationList); - changes.deleteNode(sourceFile, declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList); + function tryDeleteFullVariableStatement(sourceFile, token, changes) { + var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { + changes.delete(sourceFile, declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; } - function getToken(sourceFile, pos) { - var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true); - // this handles var ["computed"] = 12; - return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token; - } function tryPrefixDeclaration(changes, errorCode, sourceFile, token) { // Don't offer to prefix a property. if (errorCode !== ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code && ts.isIdentifier(token) && canPrefix(token)) { @@ -104648,209 +105734,61 @@ var ts; switch (token.parent.kind) { case 149 /* Parameter */: return true; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { - tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll); + function tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, isFixAll) { + tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll); if (ts.isIdentifier(token)) deleteAssignments(changes, sourceFile, token, checker); } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 185 /* PropertyAccessExpression */) + if (ref.parent.kind === 187 /* PropertyAccessExpression */) ref = ref.parent; - if (ref.parent.kind === 200 /* BinaryExpression */ && ref.parent.parent.kind === 216 /* ExpressionStatement */) { - changes.deleteNode(sourceFile, ref.parent.parent); + if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + changes.delete(sourceFile, ref.parent.parent); } }); } - function tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { + function tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll) { var parent = token.parent; - switch (parent.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); - break; - case 148 /* TypeParameter */: - var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent); - if (typeParameters.length === 1) { - var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; - var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false); - var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false); - ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); - ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); - changes.deleteNodeRange(sourceFile, previousToken, nextToken); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(parent, checker, isFixAll)) - break; - var oldFunction = parent.parent; - if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { - // Lambdas with exactly one parameter are special because, after removal, there - // must be an empty parameter list (i.e. `()`) and this won't necessarily be the - // case if the parameter is simply removed (e.g. in `x => 1`). - var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, // TODO: GH#18217 - oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); - // Drop leading and trailing trivia of the new function because we're only going - // to replace the span (vs the full span) of the old function - the old leading - // and trailing trivia will remain. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 182 /* BindingElement */: { - var pattern = parent.parent; - var preserveComma = pattern.kind === 181 /* ArrayBindingPattern */ && parent !== ts.last(pattern.elements); - if (preserveComma) { - changes.deleteNode(sourceFile, parent); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - } - // handle case where 'import a = A;' - case 243 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(token, 243 /* ImportEqualsDeclaration */); - changes.deleteNode(sourceFile, importEquals); - break; - case 248 /* ImportSpecifier */: - var namedImports = parent.parent; - if (namedImports.elements.length === 1) { - tryDeleteNamedImportBinding(changes, sourceFile, namedImports); - } - else { - // delete import specifier - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 245 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' - var importClause = parent; - if (!importClause.namedBindings) { // |import d from './file'| - changes.deleteNode(sourceFile, ts.getAncestor(importClause, 244 /* ImportDeclaration */)); - } - else { - // import |d,| * as ns from './file' - var start = importClause.name.getStart(sourceFile); - var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end, /*includeJsDocComment*/ false); - if (nextToken && nextToken.kind === 26 /* CommaToken */) { - // shift first non-whitespace position after comma to the start position of the node - var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); - changes.deleteRange(sourceFile, { pos: start, end: end }); - } - else { - changes.deleteNode(sourceFile, importClause.name); - } - } - break; - case 246 /* NamespaceImport */: - tryDeleteNamedImportBinding(changes, sourceFile, parent); - break; - default: - if (ts.isDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent); - changes.deleteNode(sourceFile, token.parent); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent.parent); - changes.deleteNode(sourceFile, token.parent.parent); - } - break; - } - } - function tryDeleteNamedImportBinding(changes, sourceFile, namedBindings) { - if (namedBindings.parent.name) { - // Delete named imports while preserving the default import - // import d|, * as ns| from './file' - // import d|, { a }| from './file' - var previousToken = ts.getTokenAtPosition(sourceFile, namedBindings.pos - 1, /*includeJsDocComment*/ false); - if (previousToken && previousToken.kind === 26 /* CommaToken */) { - changes.deleteRange(sourceFile, { pos: previousToken.getStart(), end: namedBindings.end }); - } + if (ts.isParameter(parent)) { + tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, isFixAll); } else { - // Delete the entire import declaration - // |import * as ns from './file'| - // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); - changes.deleteNode(sourceFile, importDecl); - } - } - // token.parent is a variableDeclaration - function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { - switch (varDecl.parent.parent.kind) { - case 220 /* ForStatement */: { - var forStatement = varDecl.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(forInitializer); - changes.deleteNode(sourceFile, forInitializer); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } - break; - } - case 222 /* ForOfStatement */: - var forOfStatement = varDecl.parent.parent; - ts.Debug.assert(forOfStatement.initializer.kind === 233 /* VariableDeclarationList */); - var forOfInitializer = forOfStatement.initializer; - if (deletedAncestors) - deletedAncestors.add(forOfInitializer.declarations[0]); - changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral()); - break; - case 221 /* ForInStatement */: - case 230 /* TryStatement */: - break; - default: - var variableStatement = varDecl.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(variableStatement); - changes.deleteNode(sourceFile, variableStatement); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } + changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); + } + } + function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { + if (mayDeleteParameter(p, checker, isFixAll)) { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { case 154 /* MethodDeclaration */: - // Don't remove a parameter if this overrides something + // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: { - // Can't remove a non-last parameter. Can remove a parameter in code-fix-all if future parameters are also unused. + case 237 /* FunctionDeclaration */: + return true; + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: { + // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); @@ -104865,6 +105803,14 @@ var ts; return ts.Debug.failBadSyntaxKind(parent); } } + function deleteUnusedArguments(changes, sourceFile, deletedParameter, sourceFiles, checker) { + ts.FindAllReferences.Core.eachSignatureCall(deletedParameter.parent, sourceFiles, checker, function (call) { + var index = deletedParameter.parent.parameters.indexOf(deletedParameter); + if (call.arguments.length > index) { // Just in case the call didn't provide enough arguments. + changes.delete(sourceFile, call.arguments[index]); + } + }); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104884,12 +105830,12 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -104900,16 +105846,16 @@ var ts; break; } // falls through - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - changes.deleteNode(sourceFile, container); + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + changes.delete(sourceFile, container); break; default: if (ts.isBlock(statement.parent)) { split(sliceAfter(statement.parent.statements, statement), shouldRemove, function (start, end) { return changes.deleteNodeRange(sourceFile, start, end); }); } else { - changes.deleteNode(sourceFile, statement); + changes.delete(sourceFile, statement); } } } @@ -104921,12 +105867,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -104960,7 +105906,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var labeledStatement = ts.cast(token.parent, ts.isLabeledStatement); var pos = token.getStart(sourceFile); var statementPos = labeledStatement.statement.getStart(sourceFile); @@ -104990,7 +105936,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 281 /* JSDocNullableType */) { + if (typeNode.kind === 284 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -105010,7 +105956,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -105019,7 +105965,7 @@ var ts; changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); // TODO: GH#18217 } function getInfo(sourceFile, pos, checker) { - var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), isTypeContainer); + var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), isTypeContainer); var typeNode = decl && decl.type; return typeNode && { typeNode: typeNode, type: checker.getTypeFromTypeNode(typeNode) }; } @@ -105027,22 +105973,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 208 /* AsExpression */: + case 210 /* AsExpression */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 156 /* GetAccessor */: case 160 /* IndexSignature */: - case 177 /* MappedType */: + case 179 /* MappedType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: - case 190 /* TypeAssertionExpression */: - case 232 /* VariableDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 192 /* TypeAssertionExpression */: + case 235 /* VariableDeclaration */: return true; default: return false; @@ -105089,7 +106035,7 @@ var ts; } } function getNodes(sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var containingFunction = ts.getContainingFunction(token); if (!containingFunction) { return; @@ -105099,11 +106045,11 @@ var ts; case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -105273,8 +106219,22 @@ var ts; signatureDeclaration.body = body; return signatureDeclaration; } - function createMethodFromCallExpression(_a, methodName, inJs, makeStatic, preferences) { + function createMethodFromCallExpression(context, _a, methodName, inJs, makeStatic, preferences) { var typeArguments = _a.typeArguments, args = _a.arguments, parent = _a.parent; + var checker = context.program.getTypeChecker(); + var types = ts.map(args, function (arg) { + var type = checker.getTypeAtLocation(arg); + if (type === undefined) { + return undefined; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + type = checker.getBaseTypeOfLiteralType(type); + return checker.typeToTypeNode(type); + }); + var names = ts.map(args, function (arg) { + return ts.isIdentifier(arg) ? arg.text : + ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + }); return ts.createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, @@ -105283,11 +106243,11 @@ var ts; /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); }), - /*parameters*/ createDummyParameters(args.length, /*names*/ undefined, /*minArgumentCount*/ undefined, inJs), + /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), createStubbedMethodBody(preferences)); } codefix.createMethodFromCallExpression = createMethodFromCallExpression; - function createDummyParameters(argCount, names, minArgumentCount, inJs) { + function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; for (var i = 0; i < argCount; i++) { var newParameter = ts.createParameter( @@ -105296,7 +106256,7 @@ var ts; /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -105322,7 +106282,7 @@ var ts; } var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); - var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*inJs*/ false); + var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); var restParameter = ts.createParameter( @@ -105386,18 +106346,19 @@ var ts; if (ts.isSourceFileJavaScript(sourceFile)) { return undefined; // TODO: GH#20113 } - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var declaration; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeenseen*/ ts.returnTrue); }); - return changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getNameOfDeclaration(declaration).getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start, /*includeJsDocComment*/ false), err.code, program, cancellationToken, markSeen); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen); }); }, }); @@ -105479,11 +106440,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return !!declaration.name; } return false; @@ -105543,8 +106504,8 @@ var ts; function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? @@ -105612,21 +106573,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -105634,13 +106595,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -105749,7 +106710,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -105777,7 +106738,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 187 /* CallExpression */) { + if (parent.kind === 189 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -105945,8 +106906,8 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 187 /* CallExpression */ : 188 /* NewExpression */; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -105973,7 +106934,7 @@ var ts; }); function getActionsForInvalidImportLocation(context) { var sourceFile = context.sourceFile; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -106048,7 +107009,7 @@ var ts; }, }); function getPropertyDeclaration(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined; } function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) { @@ -106133,7 +107094,7 @@ var ts; : ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, name, ts.createExternalModuleReference(required))); } function getInfo(sourceFile, pos) { - var parent = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false).parent; + var parent = ts.getTokenAtPosition(sourceFile, pos).parent; if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ true)) throw ts.Debug.failBadSyntaxKind(parent); var decl = ts.cast(parent.parent, ts.isVariableDeclaration); @@ -106166,7 +107127,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos) { - var name = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(name)) return undefined; // bad input var parent = name.parent; @@ -106190,7 +107151,7 @@ var ts; (function (codefix) { var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof"; var fixId = fixIdAddMissingTypeof; - var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code]; + var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { @@ -106205,9 +107166,9 @@ var ts; }); }, }); function getImportTypeNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 179 /* ImportType */); + ts.Debug.assert(token.parent.kind === 181 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -106243,7 +107204,7 @@ var ts; }); } }); function getInfo(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); if (ts.isClassDeclaration(indexSignature.parent)) return undefined; @@ -106272,129 +107233,325 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var generateGetAccessorAndSetAccessor; - (function (generateGetAccessorAndSetAccessor) { - var refactorName = "Convert import"; - var actionNameNamespaceToNamed = "Convert namespace import to named imports"; - var actionNameNamedToNamespace = "Convert named imports to namespace import"; - refactor.registerRefactor(refactorName, { - getAvailableActions: function (context) { - var i = getImportToConvert(context); - if (!i) + var refactorName = "Convert export"; + var actionNameDefaultToNamed = "Convert default export to named export"; + var actionNameNamedToDefault = "Convert named export to default export"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var info = getInfo(context); + if (!info) + return undefined; + var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; + var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + }, + }); + function getInfo(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var exportNode = ts.getParentNodeInSpan(token, file, span); + if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { + return undefined; + } + var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; + var flags = ts.getModifierFlags(exportNode); + var wasDefault = !!(flags & 512 /* Default */); + // If source file already has a default export, don't offer refactor. + if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + return undefined; + } + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: { + var node = exportNode; + return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + case 217 /* VariableStatement */: { + var vs = exportNode; + // Must be `export const x = something;`. + if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { return undefined; - var description = i.kind === 246 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 246 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; - return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; - }, - getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); - return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + var decl = ts.first(vs.declarationList.declarations); + if (!decl.initializer) + return undefined; + ts.Debug.assert(!wasDefault); + return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - }); - // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. - function getImportToConvert(context) { - var file = context.file; - var span = ts.getRefactorContextSpan(context); - var token = ts.getTokenAtPosition(file, span.start, /*includeJsDocComment*/ false); - var importDecl = ts.getParentNodeInSpan(token, file, span); - if (!importDecl || !ts.isImportDeclaration(importDecl)) + default: return undefined; - var importClause = importDecl.importClause; - return importClause && importClause.namedBindings; } - function doChange(sourceFile, program, changes, toConvert) { - var checker = program.getTypeChecker(); - if (toConvert.kind === 246 /* NamespaceImport */) { - doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + function doChange(exportingSourceFile, program, info, changes, cancellationToken) { + changeExport(exportingSourceFile, info, changes, program.getTypeChecker()); + changeImports(program, info, changes, cancellationToken); + } + function changeExport(exportingSourceFile, _a, changes, checker) { + var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; + if (wasDefault) { + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + } + else { + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + break; + case 217 /* VariableStatement */: + // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` + if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { + // We checked in `getInfo` that an initializer exists. + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + break; + } + // falls through + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: + // `export type T = number;` -> `type T = number; export default T;` + changes.deleteModifier(exportingSourceFile, exportKeyword); + changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); + break; + default: + ts.Debug.assertNever(exportNode); + } + } + } + function changeImports(program, _a, changes, cancellationToken) { + var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; + var checker = program.getTypeChecker(); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { + var importingSourceFile = ref.getSourceFile(); + if (wasDefault) { + changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text); } else { - doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + changeNamedToDefaultImport(importingSourceFile, ref, changes); } - } - function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { - var usedAsNamespaceOrDefault = false; - var nodesToReplace = []; - var conflictingNames = ts.createMap(); - ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { - if (!ts.isPropertyAccessExpression(id.parent)) { - usedAsNamespaceOrDefault = true; + }); + } + function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.default` --> `a.foo` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + // `default as foo` --> `foo`, `default as bar` --> `foo as bar` + changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); + break; + } + case 248 /* ImportClause */: { + var clause = parent; + ts.Debug.assert(clause.name === ref); + var spec = makeImportSpecifier(exportName, ref.text); + var namedBindings = clause.namedBindings; + if (!namedBindings) { + // `import foo from "./a";` --> `import { foo } from "./a";` + changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); + } + else if (namedBindings.kind === 249 /* NamespaceImport */) { + // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` + changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); + changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } else { - var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); - var exportName = parent.name.text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { - conflictingNames.set(exportName, true); - } - ts.Debug.assert(parent.expression === id); - nodesToReplace.push(parent); + // `import foo, { bar } from "./a"` --> `import { bar, foo } from "./a";` + changes.delete(importingSourceFile, ref); + changes.insertNodeAtEndOfList(importingSourceFile, namedBindings.elements, spec); } - }); - // We may need to change `mod.x` to `_x` to avoid a name conflict. - var exportNameToImportName = ts.createMap(); - for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { - var propertyAccess = nodesToReplace_1[_i]; - var exportName = propertyAccess.name.text; - var importName = exportNameToImportName.get(exportName); - if (importName === undefined) { - exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); - } - changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); - } - var importSpecifiers = []; - exportNameToImportName.forEach(function (name, propertyName) { - importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); - }); - var importDecl = toConvert.parent.parent; - if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { - // Need to leave the namespace import alone - changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); - } - else { - changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); + break; } + default: + ts.Debug.failBadSyntaxKind(parent); } - function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { - var importDecl = toConvert.parent.parent; - var moduleSpecifier = importDecl.moduleSpecifier; - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; - var namespaceNameConflicts = toConvert.elements.some(function (element) { - return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { - return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); - }) || false; - }); - var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; - var neededNamedImports = []; - var _loop_23 = function (element) { - var propertyName = (element.propertyName || element.name).text; - ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { - var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); - if (ts.isShorthandPropertyAssignment(id.parent)) { - changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); - } - else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { - if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { - neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); - } + } + function changeNamedToDefaultImport(importingSourceFile, ref, changes) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.foo` --> `a.default` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + if (spec.kind === 251 /* ImportSpecifier */) { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(spec.name.text); + if (spec.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, spec.parent, defaultImport); } else { - changes.replaceNode(sourceFile, id, access); + changes.delete(importingSourceFile, spec); + changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); } - }); - }; - for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { - var element = _a[_i]; - _loop_23(element); + } + else { + // `export { foo } from "./a";` --> `export { default as foo } from "./a";` + // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` + // `export { foo as default } from "./a";` --> `export { default } from "./a";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + } + break; + } + default: + ts.Debug.failBadSyntaxKind(parent); + } + } + function makeImportSpecifier(propertyName, name) { + return ts.createImportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + function makeExportSpecifier(propertyName, name) { + return ts.createExportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var refactorName = "Convert import"; + var actionNameNamespaceToNamed = "Convert namespace import to named imports"; + var actionNameNamedToNamespace = "Convert named imports to namespace import"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var i = getImportToConvert(context); + if (!i) + return undefined; + var description = i.kind === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 249 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + }); + // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. + function getImportToConvert(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var importDecl = ts.getParentNodeInSpan(token, file, span); + if (!importDecl || !ts.isImportDeclaration(importDecl)) + return undefined; + var importClause = importDecl.importClause; + return importClause && importClause.namedBindings; + } + function doChange(sourceFile, program, changes, toConvert) { + var checker = program.getTypeChecker(); + if (toConvert.kind === 249 /* NamespaceImport */) { + doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + else { + doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + } + } + function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { + var usedAsNamespaceOrDefault = false; + var nodesToReplace = []; + var conflictingNames = ts.createMap(); + ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { + if (!ts.isPropertyAccessExpression(id.parent)) { + usedAsNamespaceOrDefault = true; } - changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); - if (neededNamedImports.length) { - changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + else { + var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); + var exportName = parent.name.text; + if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + conflictingNames.set(exportName, true); + } + ts.Debug.assert(parent.expression === id); + nodesToReplace.push(parent); } + }); + // We may need to change `mod.x` to `_x` to avoid a name conflict. + var exportNameToImportName = ts.createMap(); + for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { + var propertyAccess = nodesToReplace_1[_i]; + var exportName = propertyAccess.name.text; + var importName = exportNameToImportName.get(exportName); + if (importName === undefined) { + exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); + } + changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); + } + var importSpecifiers = []; + exportNameToImportName.forEach(function (name, propertyName) { + importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); + }); + var importDecl = toConvert.parent.parent; + if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { + // Need to leave the namespace import alone + changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); } - function updateImport(old, defaultImportName, elements) { - return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + else { + changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); } - })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + } + function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { + var importDecl = toConvert.parent.parent; + var moduleSpecifier = importDecl.moduleSpecifier; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; + var namespaceNameConflicts = toConvert.elements.some(function (element) { + return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + }) || false; + }); + var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; + var neededNamedImports = []; + var _loop_24 = function (element) { + var propertyName = (element.propertyName || element.name).text; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); + if (ts.isShorthandPropertyAssignment(id.parent)) { + changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); + } + else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { + if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { + neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); + } + } + else { + changes.replaceNode(sourceFile, id, access); + } + }); + }; + for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { + var element = _a[_i]; + _loop_24(element); + } + changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); + if (neededNamedImports.length) { + changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + } + } + function updateImport(old, defaultImportName, elements) { + return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); /* @internal */ @@ -106552,7 +107709,7 @@ var ts; } // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start), sourceFile, span); // Do the same for the ending position var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; @@ -106705,7 +107862,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 235 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -106717,13 +107874,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 97 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 187 /* CallExpression */) { + if (node.parent.kind === 189 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -106738,8 +107895,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -106751,20 +107908,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 213 /* Block */: - if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { + case 216 /* Block */: + if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -106776,11 +107933,11 @@ var ts; break; } switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -106788,8 +107945,8 @@ var ts; seenLabels.pop(); break; } - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: { var label = node.label; if (label) { @@ -106799,20 +107956,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -106877,7 +108034,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 274 /* SourceFile */) { + if (current.kind === 277 /* SourceFile */) { return scopes; } } @@ -106969,12 +108126,12 @@ var ts; switch (scope.kind) { case 155 /* Constructor */: return "constructor"; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return "arrow function"; case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); @@ -106987,12 +108144,12 @@ var ts; } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 235 /* ClassDeclaration */ + return scope.kind === 238 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 240 /* ModuleBlock */ + return scope.kind === 243 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -107271,7 +108428,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 216 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 219 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.createVariableStatement( @@ -107290,9 +108447,9 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 216 /* ExpressionStatement */) { + if (node.parent.kind === 219 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. - changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); + changeTracker.delete(context.file, node.parent); } else { var localReference = ts.createIdentifier(localNameText); @@ -107377,7 +108534,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -107555,7 +108712,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 234 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -107618,7 +108775,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_24 = function (i) { + var _loop_25 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -107658,7 +108815,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_24(i); + _loop_25(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -107871,30 +109028,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 273 /* EnumMember */: + case 276 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return parent.kind !== 244 /* ImportDeclaration */ && - parent.kind !== 248 /* ImportSpecifier */; - case 204 /* SpreadElement */: - case 180 /* ObjectBindingPattern */: - case 182 /* BindingElement */: + return parent.kind !== 247 /* ImportDeclaration */ && + parent.kind !== 251 /* ImportSpecifier */; + case 206 /* SpreadElement */: + case 182 /* ObjectBindingPattern */: + case 184 /* BindingElement */: return false; case 71 /* Identifier */: - return parent.kind !== 182 /* BindingElement */ && - parent.kind !== 248 /* ImportSpecifier */ && - parent.kind !== 252 /* ExportSpecifier */; + return parent.kind !== 184 /* BindingElement */ && + parent.kind !== 251 /* ImportSpecifier */ && + parent.kind !== 255 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 213 /* Block */: - case 274 /* SourceFile */: - case 240 /* ModuleBlock */: - case 266 /* CaseClause */: + case 216 /* Block */: + case 277 /* SourceFile */: + case 243 /* ModuleBlock */: + case 269 /* CaseClause */: return true; default: return false; @@ -107914,8 +109071,7 @@ var ts; var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { - var file = context.file; - if (!getConvertibleFieldAtPosition(context, file)) + if (!getConvertibleFieldAtPosition(context)) return undefined; return [{ name: actionName, @@ -107930,7 +109086,7 @@ var ts; } function getEditsForAction(context, _actionName) { var file = context.file; - var fieldInfo = getConvertibleFieldAtPosition(context, file); + var fieldInfo = getConvertibleFieldAtPosition(context); if (!fieldInfo) return undefined; var isJS = ts.isSourceFileJavaScript(file); @@ -107991,13 +109147,13 @@ var ts; function startsWithUnderscore(name) { return name.charCodeAt(0) === 95 /* _ */; } - function getConvertibleFieldAtPosition(context, file) { - var startPosition = context.startPosition, endPosition = context.endPosition; - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + function getConvertibleFieldAtPosition(context) { + var file = context.file, startPosition = context.startPosition, endPosition = context.endPosition; + var node = ts.getTokenAtPosition(file, startPosition); var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; - if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) // TODO: GH#18217 + if (!declaration || !ts.nodeOverlapsWithStartEnd(declaration.name, file, startPosition, endPosition) // TODO: GH#18217 || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; @@ -108152,11 +109308,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return true; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -108209,10 +109365,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_25 = function (sourceFile) { + var _loop_26 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_26 = function (statement) { + var _loop_27 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -108234,22 +109390,22 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_26(statement); + _loop_27(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_25(sourceFile); + _loop_26(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + case 247 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -108280,20 +109436,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -108363,15 +109519,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -108384,23 +109540,23 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } else { if (name && defaultUnused) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } if (namedBindings) { if (namedBindingsUnused) { - changes.deleteNode(sourceFile, namedBindings); + changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 247 /* NamedImports */) { + else if (namedBindings.kind === 250 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) - changes.deleteNodeInList(sourceFile, element); + changes.delete(sourceFile, element); } } } @@ -108411,20 +109567,20 @@ var ts; switch (name.kind) { case 71 /* Identifier */: if (isUnused(name)) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { - changes.deleteNode(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); + changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } else { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (ts.isIdentifier(element.name) && isUnused(element.name)) { - changes.deleteNode(sourceFile, element.name); + changes.delete(sourceFile, element.name); } } } @@ -108521,13 +109677,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: return true; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -108539,7 +109695,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -108549,9 +109705,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -108560,7 +109716,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -108572,9 +109728,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return name; - case 180 /* ObjectBindingPattern */: { + case 182 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.createObjectBindingPattern(newElements) : undefined; @@ -108631,13 +109787,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -108645,17 +109801,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return cb(statement); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -108664,7 +109820,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -108696,23 +109852,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -108723,18 +109879,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -108809,7 +109965,7 @@ var ts; return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(file, startPosition); var func = ts.getContainingFunction(node); if (!func || !ts.isArrowFunction(func) || (!ts.rangeContainsRange(func, node) || ts.rangeContainsRange(func.body, node))) return undefined; @@ -108915,7 +110071,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 299 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 302 /* LastJSDocNode */; }); return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -108985,7 +110141,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(300 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(303 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -109042,7 +110198,7 @@ var ts; return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { - return ts.emptyArray; + return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -109296,7 +110452,7 @@ var ts; }; SourceFileObject.prototype.computeNamedDeclarations = function () { var result = ts.createMultiMap(); - ts.forEachChild(this, visit); + this.forEachChild(visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); @@ -109312,14 +110468,14 @@ var ts; return declarations; } function getDeclarationName(declaration) { - var name = ts.getNameOfDeclaration(declaration); + var name = ts.getNonAssignedNameOfDeclaration(declaration); return name && (ts.isComputedPropertyName(name) && ts.isPropertyAccessExpression(name.expression) ? name.expression.name.text : ts.isPropertyName(name) ? ts.getNameFromPropertyName(name) : undefined); } function visit(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: var functionDeclaration = node; @@ -109341,17 +110497,17 @@ var ts; } ts.forEachChild(node, visit); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 166 /* TypeLiteral */: @@ -109364,8 +110520,8 @@ var ts; break; } // falls through - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: { + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -109376,31 +110532,31 @@ var ts; } } // falls through - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: addDeclaration(node); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addDeclaration(importClause); + addDeclaration(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -109409,7 +110565,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -109777,7 +110933,7 @@ var ts; readFile: function (fileName) { // stub missing host functionality var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); if (entry) { return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot); } @@ -109827,7 +110983,7 @@ var ts; return; function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : (!!host.fileExists && host.fileExists(fileName)); @@ -109842,11 +110998,11 @@ var ts; return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); } function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { - ts.Debug.assert(hostCache !== undefined); + ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined // to the program to allow reporting of errors for missing files. - var hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path); + var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path); if (!hostFileInformation) { return undefined; } @@ -109942,17 +111098,17 @@ var ts; return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { - if (options === void 0) { options = ts.defaultPreferences; } + if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 - getCanonicalFileName, preferences, cancellationToken); + preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -109977,10 +111133,10 @@ var ts; return undefined; } // falls through - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_4 = typeChecker.getTypeAtLocation(node); @@ -110025,7 +111181,8 @@ var ts; return file.getLineAndCharacterOfPosition(position); } // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; function scanForSourcemapURL(fileName) { var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); @@ -110034,11 +111191,15 @@ var ts; } var starts = ts.getLineStarts(mappedFile); for (var index = starts.length - 1; index >= 0; index--) { - sourceMapCommentRegExp.lastIndex = starts[index]; - var comment = sourceMapCommentRegExp.exec(mappedFile.text); + var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); + var comment = sourceMapCommentRegExp.exec(lineText); if (comment) { return comment[1]; } + // If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!lineText.match(whitespaceOrMapCommentRegExp)) { + break; + } } } function convertDocumentToSourceMapper(file, contents, mapFileName) { @@ -110192,18 +111353,32 @@ var ts; return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; + return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); }); + } + else { + var refs = getReferences(node, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + return refs && refs.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + return ({ fileName: fileName, textSpan: textSpan }); + }); + } } function getReferencesAtPosition(fileName, position) { - return getReferences(fileName, position); + synchronizeHostData(); + return getReferences(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position); } - function getReferences(fileName, position, options) { + function getReferences(node, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. var sourceFiles = options && options.isForRename ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); - return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -110227,10 +111402,11 @@ var ts; /** * This is a semantic operation. */ - function getSignatureHelpItems(fileName, position) { + function getSignatureHelpItems(fileName, position, _a) { + var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); } /// Syntactic features function getNonBoundSourceFile(fileName) { @@ -110244,7 +111420,7 @@ var ts; return undefined; } switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: @@ -110252,7 +111428,7 @@ var ts; case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span @@ -110269,7 +111445,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 === 239 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 242 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -110339,7 +111515,7 @@ var ts; braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var token = ts.getTouchingToken(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, position); var matchKind = token.getStart(sourceFile) === position ? braceMatching.get(token.kind.toString()) : undefined; var match = matchKind && ts.findChildOfKind(token.parent, matchKind, sourceFile); // We want to order the braces when we return the result. @@ -110380,7 +111556,7 @@ var ts; return []; } function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = ts.createTextSpanFromBounds(start, end); @@ -110391,7 +111567,7 @@ var ts; }); } function getCombinedCodeFix(scope, fixId, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110399,7 +111575,7 @@ var ts; return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } function organizeImports(scope, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110407,7 +111583,7 @@ var ts; return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { @@ -110470,8 +111646,8 @@ var ts; } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); - return range && ts.createTextSpanFromRange(range); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); + return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -110599,8 +111775,7 @@ var ts; } function getRenameInfo(fileName, position) { synchronizeHostData(); - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - return ts.Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); + return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position); } function getRefactorContext(file, positionOrRange, preferences, formatOptions) { var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1]; @@ -110616,13 +111791,13 @@ var ts; }; } function getApplicableRefactors(fileName, positionOrRange, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getApplicableRefactors(getRefactorContext(file, positionOrRange, preferences)); } function getEditsForRefactor(fileName, formatOptions, positionOrRange, refactorName, actionName, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); @@ -110716,7 +111891,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 254 /* ExternalModuleReference */ || + node.parent.kind === 257 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -110734,7 +111909,7 @@ var ts; // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && + (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -110773,7 +111948,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 186 /* ElementAccessExpression */ && + node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -110804,7 +111979,7 @@ var ts; if (sourceFile.isDeclarationFile) { return undefined; } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { // Get previous token if the token is returned starts on new line @@ -110853,114 +112028,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return spanInVariableDeclaration(node); case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanInBlock(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInBlock(node.block); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 217 /* IfStatement */: + case 220 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return spanInForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 182 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 184 /* BindingElement */: // span on complete node return textSpan(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: // span in statement return spanInNode(node.statement); case 150 /* Decorator */: return spanInNodeArray(parent.decorators); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -111003,13 +112178,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 === 71 /* Identifier */ || - node.kind === 204 /* SpreadElement */ || - node.kind === 270 /* PropertyAssignment */ || - node.kind === 271 /* ShorthandPropertyAssignment */) && + node.kind === 206 /* SpreadElement */ || + node.kind === 273 /* PropertyAssignment */ || + node.kind === 274 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 200 /* BinaryExpression */) { + if (node.kind === 202 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -111031,22 +112206,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: return textSpan(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (node.parent.operatorToken.kind === 26 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -111055,20 +112230,20 @@ var ts; } } switch (node.parent.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; @@ -111077,7 +112252,7 @@ var ts; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -111107,7 +112282,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -111119,7 +112294,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 222 /* ForOfStatement */) { + parent.parent.kind === 225 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -111160,7 +112335,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -111183,26 +112358,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 221 /* ForInStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 224 /* 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 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 236 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -111227,21 +112402,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 182 /* BindingElement */) { + if (bindingPattern.parent.kind === 184 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 181 /* ArrayBindingPattern */ && node.kind !== 180 /* ObjectBindingPattern */); - var elements = node.kind === 183 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); + var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -111249,18 +112424,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 === 200 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 202 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -111268,25 +112443,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 238 /* EnumDeclaration */: - case 235 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -111294,7 +112469,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); @@ -111310,7 +112485,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 181 /* ArrayBindingPattern */: + case 183 /* 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); @@ -111325,12 +112500,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 187 /* CallExpression */ || - node.parent.kind === 188 /* NewExpression */) { + if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 189 /* CallExpression */ || + node.parent.kind === 190 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 191 /* ParenthesizedExpression */) { + if (node.parent.kind === 193 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -111339,21 +112514,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 191 /* ParenthesizedExpression */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 193 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -111363,20 +112538,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 273 /* PropertyAssignment */ || node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 190 /* TypeAssertionExpression */) { + if (node.parent.kind === 192 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 218 /* DoStatement */) { + if (node.parent.kind === 221 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -111384,7 +112559,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.kind === 225 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -111804,9 +112979,9 @@ var ts; return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 7ad35c1c63797..133c1e1ca954e 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -242,144 +242,147 @@ declare namespace ts { TypeLiteral = 166, ArrayType = 167, TupleType = 168, - UnionType = 169, - IntersectionType = 170, - ConditionalType = 171, - InferType = 172, - ParenthesizedType = 173, - ThisType = 174, - TypeOperator = 175, - IndexedAccessType = 176, - MappedType = 177, - LiteralType = 178, - ImportType = 179, - ObjectBindingPattern = 180, - ArrayBindingPattern = 181, - BindingElement = 182, - ArrayLiteralExpression = 183, - ObjectLiteralExpression = 184, - PropertyAccessExpression = 185, - ElementAccessExpression = 186, - CallExpression = 187, - NewExpression = 188, - TaggedTemplateExpression = 189, - TypeAssertionExpression = 190, - ParenthesizedExpression = 191, - FunctionExpression = 192, - ArrowFunction = 193, - DeleteExpression = 194, - TypeOfExpression = 195, - VoidExpression = 196, - AwaitExpression = 197, - PrefixUnaryExpression = 198, - PostfixUnaryExpression = 199, - BinaryExpression = 200, - ConditionalExpression = 201, - TemplateExpression = 202, - YieldExpression = 203, - SpreadElement = 204, - ClassExpression = 205, - OmittedExpression = 206, - ExpressionWithTypeArguments = 207, - AsExpression = 208, - NonNullExpression = 209, - MetaProperty = 210, - TemplateSpan = 211, - SemicolonClassElement = 212, - Block = 213, - VariableStatement = 214, - EmptyStatement = 215, - ExpressionStatement = 216, - IfStatement = 217, - DoStatement = 218, - WhileStatement = 219, - ForStatement = 220, - ForInStatement = 221, - ForOfStatement = 222, - ContinueStatement = 223, - BreakStatement = 224, - ReturnStatement = 225, - WithStatement = 226, - SwitchStatement = 227, - LabeledStatement = 228, - ThrowStatement = 229, - TryStatement = 230, - DebuggerStatement = 231, - VariableDeclaration = 232, - VariableDeclarationList = 233, - FunctionDeclaration = 234, - ClassDeclaration = 235, - InterfaceDeclaration = 236, - TypeAliasDeclaration = 237, - EnumDeclaration = 238, - ModuleDeclaration = 239, - ModuleBlock = 240, - CaseBlock = 241, - NamespaceExportDeclaration = 242, - ImportEqualsDeclaration = 243, - ImportDeclaration = 244, - ImportClause = 245, - NamespaceImport = 246, - NamedImports = 247, - ImportSpecifier = 248, - ExportAssignment = 249, - ExportDeclaration = 250, - NamedExports = 251, - ExportSpecifier = 252, - MissingDeclaration = 253, - ExternalModuleReference = 254, - JsxElement = 255, - JsxSelfClosingElement = 256, - JsxOpeningElement = 257, - JsxClosingElement = 258, - JsxFragment = 259, - JsxOpeningFragment = 260, - JsxClosingFragment = 261, - JsxAttribute = 262, - JsxAttributes = 263, - JsxSpreadAttribute = 264, - JsxExpression = 265, - CaseClause = 266, - DefaultClause = 267, - HeritageClause = 268, - CatchClause = 269, - PropertyAssignment = 270, - ShorthandPropertyAssignment = 271, - SpreadAssignment = 272, - EnumMember = 273, - SourceFile = 274, - Bundle = 275, - UnparsedSource = 276, - InputFiles = 277, - JSDocTypeExpression = 278, - JSDocAllType = 279, - JSDocUnknownType = 280, - JSDocNullableType = 281, - JSDocNonNullableType = 282, - JSDocOptionalType = 283, - JSDocFunctionType = 284, - JSDocVariadicType = 285, - JSDocComment = 286, - JSDocTypeLiteral = 287, - JSDocSignature = 288, - JSDocTag = 289, - JSDocAugmentsTag = 290, - JSDocClassTag = 291, - JSDocCallbackTag = 292, - JSDocParameterTag = 293, - JSDocReturnTag = 294, - JSDocThisTag = 295, - JSDocTypeTag = 296, - JSDocTemplateTag = 297, - JSDocTypedefTag = 298, - JSDocPropertyTag = 299, - SyntaxList = 300, - NotEmittedStatement = 301, - PartiallyEmittedExpression = 302, - CommaListExpression = 303, - MergeDeclarationMarker = 304, - EndOfDeclarationMarker = 305, - Count = 306, + OptionalType = 169, + RestType = 170, + UnionType = 171, + IntersectionType = 172, + ConditionalType = 173, + InferType = 174, + ParenthesizedType = 175, + ThisType = 176, + TypeOperator = 177, + IndexedAccessType = 178, + MappedType = 179, + LiteralType = 180, + ImportType = 181, + ObjectBindingPattern = 182, + ArrayBindingPattern = 183, + BindingElement = 184, + ArrayLiteralExpression = 185, + ObjectLiteralExpression = 186, + PropertyAccessExpression = 187, + ElementAccessExpression = 188, + CallExpression = 189, + NewExpression = 190, + TaggedTemplateExpression = 191, + TypeAssertionExpression = 192, + ParenthesizedExpression = 193, + FunctionExpression = 194, + ArrowFunction = 195, + DeleteExpression = 196, + TypeOfExpression = 197, + VoidExpression = 198, + AwaitExpression = 199, + PrefixUnaryExpression = 200, + PostfixUnaryExpression = 201, + BinaryExpression = 202, + ConditionalExpression = 203, + TemplateExpression = 204, + YieldExpression = 205, + SpreadElement = 206, + ClassExpression = 207, + OmittedExpression = 208, + ExpressionWithTypeArguments = 209, + AsExpression = 210, + NonNullExpression = 211, + MetaProperty = 212, + SyntheticExpression = 213, + TemplateSpan = 214, + SemicolonClassElement = 215, + Block = 216, + VariableStatement = 217, + EmptyStatement = 218, + ExpressionStatement = 219, + IfStatement = 220, + DoStatement = 221, + WhileStatement = 222, + ForStatement = 223, + ForInStatement = 224, + ForOfStatement = 225, + ContinueStatement = 226, + BreakStatement = 227, + ReturnStatement = 228, + WithStatement = 229, + SwitchStatement = 230, + LabeledStatement = 231, + ThrowStatement = 232, + TryStatement = 233, + DebuggerStatement = 234, + VariableDeclaration = 235, + VariableDeclarationList = 236, + FunctionDeclaration = 237, + ClassDeclaration = 238, + InterfaceDeclaration = 239, + TypeAliasDeclaration = 240, + EnumDeclaration = 241, + ModuleDeclaration = 242, + ModuleBlock = 243, + CaseBlock = 244, + NamespaceExportDeclaration = 245, + ImportEqualsDeclaration = 246, + ImportDeclaration = 247, + ImportClause = 248, + NamespaceImport = 249, + NamedImports = 250, + ImportSpecifier = 251, + ExportAssignment = 252, + ExportDeclaration = 253, + NamedExports = 254, + ExportSpecifier = 255, + MissingDeclaration = 256, + ExternalModuleReference = 257, + JsxElement = 258, + JsxSelfClosingElement = 259, + JsxOpeningElement = 260, + JsxClosingElement = 261, + JsxFragment = 262, + JsxOpeningFragment = 263, + JsxClosingFragment = 264, + JsxAttribute = 265, + JsxAttributes = 266, + JsxSpreadAttribute = 267, + JsxExpression = 268, + CaseClause = 269, + DefaultClause = 270, + HeritageClause = 271, + CatchClause = 272, + PropertyAssignment = 273, + ShorthandPropertyAssignment = 274, + SpreadAssignment = 275, + EnumMember = 276, + SourceFile = 277, + Bundle = 278, + UnparsedSource = 279, + InputFiles = 280, + JSDocTypeExpression = 281, + JSDocAllType = 282, + JSDocUnknownType = 283, + JSDocNullableType = 284, + JSDocNonNullableType = 285, + JSDocOptionalType = 286, + JSDocFunctionType = 287, + JSDocVariadicType = 288, + JSDocComment = 289, + JSDocTypeLiteral = 290, + JSDocSignature = 291, + JSDocTag = 292, + JSDocAugmentsTag = 293, + JSDocClassTag = 294, + JSDocCallbackTag = 295, + JSDocParameterTag = 296, + JSDocReturnTag = 297, + JSDocThisTag = 298, + JSDocTypeTag = 299, + JSDocTemplateTag = 300, + JSDocTypedefTag = 301, + JSDocPropertyTag = 302, + SyntaxList = 303, + NotEmittedStatement = 304, + PartiallyEmittedExpression = 305, + CommaListExpression = 306, + MergeDeclarationMarker = 307, + EndOfDeclarationMarker = 308, + Count = 309, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -391,7 +394,7 @@ declare namespace ts { FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 161, - LastTypeNode = 179, + LastTypeNode = 181, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, @@ -405,10 +408,10 @@ declare namespace ts { FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 146, - FirstJSDocNode = 278, - LastJSDocNode = 299, - FirstJSDocTagNode = 289, - LastJSDocTagNode = 299 + FirstJSDocNode = 281, + LastJSDocNode = 302, + FirstJSDocTagNode = 292, + LastJSDocTagNode = 302 } enum NodeFlags { None = 0, @@ -767,6 +770,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } + interface OptionalTypeNode extends TypeNode { + kind: SyntaxKind.OptionalType; + type: TypeNode; + } + interface RestTypeNode extends TypeNode { + kind: SyntaxKind.RestType; + type: TypeNode; + } type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; @@ -891,6 +902,11 @@ declare namespace ts { asteriskToken?: AsteriskToken; expression?: Expression; } + interface SyntheticExpression extends Expression { + kind: SyntaxKind.SyntheticExpression; + isSpread: boolean; + type: Type; + } type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; @@ -1105,7 +1121,10 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; } @@ -1780,6 +1799,7 @@ declare namespace ts { */ getTypeChecker(): TypeChecker; isSourceFileFromExternalLibrary(file: SourceFile): boolean; + isSourceFileDefaultLibrary(file: SourceFile): boolean; getProjectReferences(): (ResolvedProjectReference | undefined)[] | undefined; } interface ResolvedProjectReference { @@ -1818,7 +1838,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -1838,7 +1857,7 @@ declare namespace ts { getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1889,11 +1908,6 @@ declare namespace ts { typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): string; typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; @@ -1920,7 +1934,7 @@ declare namespace ts { getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined; + getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; @@ -1992,39 +2006,6 @@ declare namespace ts { AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8 } - /** - * @deprecated - */ - interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ - interface SymbolWriter extends SymbolTracker { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeProperty(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - } enum TypePredicateKind { This = 0, Identifier = 1 @@ -2214,7 +2195,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: Type[]; + aliasTypeArguments?: ReadonlyArray; } interface LiteralType extends Type { value: string | number; @@ -2279,10 +2260,18 @@ declare namespace ts { */ interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: Type[]; + typeArguments?: ReadonlyArray; } interface GenericType extends InterfaceType, TypeReference { } + interface TupleType extends GenericType { + minLength: number; + hasRestElement: boolean; + associatedNames?: __String[]; + } + interface TupleTypeReference extends TypeReference { + target: TupleType; + } interface UnionOrIntersectionType extends Type { types: Type[]; } @@ -2339,8 +2328,8 @@ declare namespace ts { } interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: TypeParameter[]; - parameters: Symbol[]; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; } enum IndexKind { String = 0, @@ -2388,14 +2377,14 @@ declare namespace ts { next?: DiagnosticMessageChain; } interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -2929,13 +2918,6 @@ declare namespace ts { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - /** @deprecated See comment on SymbolWriter */ - interface SymbolTracker { - trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError?(): void; - reportPrivateInBaseOfClassExpression?(propertyName: string): void; - reportInaccessibleUniqueSymbolError?(): void; - } interface TextSpan { start: number; length: number; @@ -3166,7 +3148,8 @@ declare namespace ts { function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; + function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; + function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** * Checks to see if the locale is in the appropriate format, @@ -3212,15 +3195,8 @@ declare namespace ts { function unescapeLeadingUnderscores(identifier: __String): string; function idText(identifier: Identifier): string; function symbolName(symbol: Symbol): string; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -3655,7 +3631,7 @@ declare namespace ts { /** Create a unique name based on the supplied text. This does not consider names injected by the transformer. */ function createFileLevelUniqueName(text: string): Identifier; /** Create a unique name generated for a node. */ - function getGeneratedNameForNode(node: Node): Identifier; + function getGeneratedNameForNode(node: Node | undefined): Identifier; function createToken(token: TKind): Token; function createSuper(): SuperExpression; function createThis(): ThisExpression & Token; @@ -3710,7 +3686,11 @@ declare namespace ts { function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTypleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; + function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; + function createRestTypeNode(type: TypeNode): RestTypeNode; + function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; @@ -3763,7 +3743,7 @@ declare namespace ts { function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + /** @deprecated */ function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; @@ -3781,7 +3761,7 @@ declare namespace ts { function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): 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; + /** @deprecated */ function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; @@ -3813,8 +3793,12 @@ declare namespace ts { function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; - function createStatement(expression: Expression): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createExpressionStatement(expression: Expression): ExpressionStatement; + function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + const createStatement: typeof createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + const updateStatement: typeof updateExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; @@ -4504,12 +4488,12 @@ declare namespace ts { */ interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** * One or more of the outputs of the project does not exist. @@ -4629,8 +4613,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; + getCallSignatures(): ReadonlyArray; + getConstructSignatures(): ReadonlyArray; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4771,7 +4755,7 @@ declare namespace ts { getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; @@ -4831,13 +4815,54 @@ declare namespace ts { type OrganizeImportsScope = CombinedCodeFixScope; type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } interface ApplyCodeActionCommandResult { successMessage: string; } @@ -5025,7 +5050,7 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index c1ead6a1fac3f..4785ced00f304 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -26,6 +26,33 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +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 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, 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 __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; @@ -889,23 +916,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1866,8 +1876,9 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; - function tryRemovePrefix(str, prefix) { - return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2207,160 +2218,163 @@ var ts; SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType"; + SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 213] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 295] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 296] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 297] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 298] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 299] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 296] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 297] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 298] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 299] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 300] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 301] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 302] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 300] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 303] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 301] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 302] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 303] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 304] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 305] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 304] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 305] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 306] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 307] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 308] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 306] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 309] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -2373,7 +2387,7 @@ var ts; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; @@ -2387,10 +2401,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 299] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 299] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 302] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 302] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -2564,6 +2578,7 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; @@ -2783,6 +2798,8 @@ var ts; CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; CheckFlags[CheckFlags["Late"] = 1024] = "Late"; CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped"; + CheckFlags[CheckFlags["OptionalParameter"] = 4096] = "OptionalParameter"; + CheckFlags[CheckFlags["RestParameter"] = 8192] = "RestParameter"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var InternalSymbolName; @@ -4417,6 +4434,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -4575,7 +4595,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -4695,6 +4714,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -4725,7 +4746,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -4795,6 +4816,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -4844,6 +4866,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -4991,6 +5014,9 @@ var ts; Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -5077,6 +5103,8 @@ var ts; Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -5376,6 +5404,10 @@ var ts; Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true), All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5407,6 +5439,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -5438,6 +5472,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -5582,6 +5617,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -7730,7 +7769,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274 /* SourceFile */) { + while (node && node.kind !== 277 /* SourceFile */) { node = node.parent; } return node; @@ -7738,11 +7777,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return true; } return false; @@ -7880,7 +7919,7 @@ 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 === 300 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 303 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7973,14 +8012,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; // 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) { @@ -7994,7 +8025,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; + return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -8026,11 +8057,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 && node.kind === 239 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 /* SourceFile */ || - node.kind === 239 /* ModuleDeclaration */ || + return node.kind === 277 /* SourceFile */ || + node.kind === 242 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8047,9 +8078,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node.parent); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8061,22 +8092,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 269 /* CatchClause */: - case 239 /* ModuleDeclaration */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 272 /* CatchClause */: + case 242 /* ModuleDeclaration */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; - case 213 /* Block */: + case 216 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8092,22 +8123,22 @@ var ts; case 160 /* IndexSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: - case 288 /* JSDocSignature */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 291 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -8117,8 +8148,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8127,15 +8158,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 214 /* VariableStatement */: - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 217 /* VariableStatement */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -8156,7 +8187,7 @@ var ts; // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -8183,7 +8214,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8228,7 +8259,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213 /* Block */) { + if (node.body && node.body.kind === 216 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8242,7 +8273,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* 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 @@ -8251,25 +8282,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: errorNode = node.name; break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8301,35 +8332,34 @@ var ts; return file.scriptKind === 6 /* JSON */; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */ && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */) - || !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 /* ImportType */ && - n.argument.kind === 178 /* LiteralType */ && + return n.kind === 181 /* ImportType */ && + n.argument.kind === 180 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 /* ExpressionStatement */ + return node.kind === 219 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -8340,9 +8370,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 /* Parameter */ || node.kind === 148 /* TypeParameter */ || - node.kind === 192 /* FunctionExpression */ || - node.kind === 193 /* ArrowFunction */ || - node.kind === 191 /* ParenthesizedExpression */) ? + node.kind === 194 /* FunctionExpression */ || + node.kind === 195 /* ArrowFunction */ || + node.kind === 193 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -8358,7 +8388,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -8372,11 +8402,11 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 196 /* VoidExpression */; - case 207 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 198 /* VoidExpression */; + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148 /* TypeParameter */: - return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; + return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: @@ -8384,20 +8414,20 @@ var ts; if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 187 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 185 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through case 146 /* QualifiedName */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: { var parent = node.parent; if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 179 /* ImportType */) { + if (parent.kind === 181 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8406,22 +8436,22 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148 /* TypeParameter */: return node === parent.constraint; case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return node === parent.type; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -8432,12 +8462,12 @@ var ts; case 159 /* ConstructSignature */: case 160 /* IndexSignature */: return node === parent.type; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return node === parent.type; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8462,23 +8492,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitor(node); - case 241 /* CaseBlock */: - case 213 /* Block */: - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 226 /* WithStatement */: - case 227 /* SwitchStatement */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 228 /* LabeledStatement */: - case 230 /* TryStatement */: - case 269 /* CatchClause */: + case 244 /* CaseBlock */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8488,19 +8518,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -8543,12 +8573,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 166 /* TypeLiteral */: return node.members; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.properties; } } @@ -8556,14 +8586,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182 /* BindingElement */: - case 273 /* EnumMember */: + case 184 /* BindingElement */: + case 276 /* EnumMember */: case 149 /* Parameter */: - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 271 /* ShorthandPropertyAssignment */: - case 232 /* VariableDeclaration */: + case 274 /* ShorthandPropertyAssignment */: + case 235 /* VariableDeclaration */: return true; } } @@ -8575,12 +8605,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 /* VariableDeclarationList */ - && node.parent.parent.kind === 214 /* VariableStatement */; + return node.parent.kind === 236 /* VariableDeclarationList */ + && node.parent.parent.kind === 217 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -8592,8 +8622,8 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return true; } return false; @@ -8604,7 +8634,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228 /* LabeledStatement */) { + if (node.statement.kind !== 231 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -8612,17 +8642,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 184 /* ObjectLiteralExpression */ || - node.parent.kind === 205 /* ClassExpression */); + (node.parent.kind === 186 /* ObjectLiteralExpression */ || + node.parent.kind === 207 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8635,7 +8665,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270 /* PropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -8672,7 +8702,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274 /* SourceFile */); + ts.Debug.assert(node.kind !== 277 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -8707,14 +8737,14 @@ var ts; node = node.parent; } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 239 /* ModuleDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 242 /* ModuleDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 154 /* MethodDeclaration */: @@ -8725,8 +8755,8 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 238 /* EnumDeclaration */: - case 274 /* SourceFile */: + case 241 /* EnumDeclaration */: + case 277 /* SourceFile */: return node; } } @@ -8737,8 +8767,8 @@ var ts; if (container) { switch (container.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return container; } } @@ -8763,9 +8793,9 @@ var ts; case 147 /* ComputedPropertyName */: node = node.parent; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!stopOnFunctions) { continue; } @@ -8796,14 +8826,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { + if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 191 /* ParenthesizedExpression */) { + while (parent.kind === 193 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -8814,7 +8844,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -8823,7 +8853,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -8831,7 +8861,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -8844,10 +8874,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return node.tag; - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -8856,25 +8886,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // classes are valid targets return true; case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 235 /* ClassDeclaration */; + return parent.kind === 238 /* ClassDeclaration */; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 154 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 235 /* ClassDeclaration */; + && parent.kind === 238 /* ClassDeclaration */; case 149 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined && (parent.kind === 155 /* Constructor */ || parent.kind === 154 /* MethodDeclaration */ || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 235 /* ClassDeclaration */; + && grandparent.kind === 238 /* ClassDeclaration */; } return false; } @@ -8890,7 +8920,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 case 154 /* MethodDeclaration */: case 157 /* SetAccessor */: @@ -8902,9 +8932,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 /* JsxOpeningElement */ || - parent.kind === 256 /* JsxSelfClosingElement */ || - parent.kind === 258 /* JsxClosingElement */) { + if (parent.kind === 260 /* JsxOpeningElement */ || + parent.kind === 259 /* JsxSelfClosingElement */ || + parent.kind === 261 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -8917,37 +8947,37 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: - case 208 /* AsExpression */: - case 190 /* TypeAssertionExpression */: - case 209 /* NonNullExpression */: - case 191 /* ParenthesizedExpression */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: - case 193 /* ArrowFunction */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 204 /* SpreadElement */: - case 202 /* TemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: + case 210 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 211 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 206 /* SpreadElement */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 206 /* OmittedExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 203 /* YieldExpression */: - case 197 /* AwaitExpression */: - case 210 /* MetaProperty */: + case 208 /* OmittedExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 205 /* YieldExpression */: + case 199 /* AwaitExpression */: + case 212 /* MetaProperty */: return true; case 146 /* QualifiedName */: while (node.parent.kind === 146 /* QualifiedName */) { @@ -8971,47 +9001,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 182 /* BindingElement */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 184 /* BindingElement */: return parent.initializer === node; - case 216 /* ExpressionStatement */: - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 225 /* ReturnStatement */: - case 226 /* WithStatement */: - case 227 /* SwitchStatement */: - case 266 /* CaseClause */: - case 229 /* ThrowStatement */: + case 219 /* ExpressionStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 228 /* ReturnStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 232 /* ThrowStatement */: return parent.expression === node; - case 220 /* ForStatement */: + case 223 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forInStatement.expression === node; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return node === parent.expression; - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return node === parent.expression; case 147 /* ComputedPropertyName */: return node === parent.expression; case 150 /* Decorator */: - case 265 /* JsxExpression */: - case 264 /* JsxSpreadAttribute */: - case 272 /* SpreadAssignment */: + case 268 /* JsxExpression */: + case 267 /* JsxSpreadAttribute */: + case 275 /* SpreadAssignment */: return true; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -9019,7 +9049,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9028,7 +9058,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -9060,7 +9090,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187 /* CallExpression */) { + if (callExpression.kind !== 189 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -9156,11 +9186,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 192 /* FunctionExpression */ || - initializer.kind === 205 /* ClassExpression */ || - initializer.kind === 193 /* ArrowFunction */) { + if (initializer.kind === 194 /* FunctionExpression */ || + initializer.kind === 207 /* ClassExpression */ || + initializer.kind === 195 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9229,7 +9259,7 @@ var ts; return false; } function getRightMostAssignedExpression(node) { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -9252,6 +9282,14 @@ var ts; return 0 /* None */; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + // F.prototype = { ... } + return 6 /* Prototype */; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } @@ -9260,11 +9298,7 @@ var ts; return 2 /* ModuleExports */; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - // F.prototype = { ... } - return 6 /* Prototype */; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } @@ -9284,7 +9318,7 @@ var ts; } return 0 /* None */; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -9298,7 +9332,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9308,14 +9342,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.parent; - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return node.parent.parent; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return node.parent; - case 178 /* LiteralType */: + case 180 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9325,12 +9359,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.moduleSpecifier; - case 243 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 179 /* ImportType */: + case 246 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 181 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9339,11 +9373,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9351,7 +9385,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -9360,8 +9394,8 @@ var ts; case 149 /* Parameter */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 271 /* ShorthandPropertyAssignment */: - case 270 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return node.questionToken !== undefined; @@ -9371,14 +9405,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 /* JSDocFunctionType */ && + return node.kind === 287 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 301 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9403,12 +9437,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152 /* PropertyDeclaration */: return node.initializer; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return node.initializer; } } @@ -9418,59 +9452,57 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 /* ModuleDeclaration */ + node.body.kind === 242 /* ModuleDeclaration */ ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - if (parent.kind === 270 /* PropertyAssignment */ || parent.kind === 152 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { - getJSDocCommentsAndTagsWorker(parent); - } - // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } + // Pull parameter comments from declaring function as well + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); } - // Pull parameter comments from declaring function as well if (node.kind === 149 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; } - if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { - result = ts.addRange(result, node.initializer.jsDoc); - } - if (ts.hasJSDocNodes(node)) { - result = ts.addRange(result, node.jsDoc); - } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 /* PropertyAssignment */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + return parent; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -9519,7 +9551,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9532,31 +9564,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 191 /* ParenthesizedExpression */: - case 183 /* ArrayLiteralExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 185 /* ArrayLiteralExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: node = parent; break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -9583,22 +9615,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 213 /* Block */: - case 214 /* VariableStatement */: - case 226 /* WithStatement */: - case 217 /* IfStatement */: - case 227 /* SwitchStatement */: - case 241 /* CaseBlock */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 228 /* LabeledStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 230 /* TryStatement */: - case 269 /* CatchClause */: + case 216 /* Block */: + case 217 /* VariableStatement */: + case 229 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return true; } return false; @@ -9615,15 +9647,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173 /* ParenthesizedType */); + return walkUp(node, 175 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191 /* ParenthesizedExpression */); + return walkUp(node, 193 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */) { + while (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -9631,11 +9663,11 @@ var ts; ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194 /* DeleteExpression */; + return node && node.kind === 196 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9692,9 +9724,9 @@ var ts; case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 185 /* PropertyAccessExpression */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 187 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; case 146 /* QualifiedName */: @@ -9706,12 +9738,12 @@ var ts; return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 182 /* BindingElement */: - case 248 /* ImportSpecifier */: + case 184 /* BindingElement */: + case 251 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 252 /* ExportSpecifier */: - case 262 /* JsxAttribute */: + case 255 /* ExportSpecifier */: + case 265 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -9727,13 +9759,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ || - node.kind === 242 /* NamespaceExportDeclaration */ || - node.kind === 245 /* ImportClause */ && !!node.name || - node.kind === 246 /* NamespaceImport */ || - node.kind === 248 /* ImportSpecifier */ || - node.kind === 252 /* ExportSpecifier */ || - node.kind === 249 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 245 /* NamespaceExportDeclaration */ || + node.kind === 248 /* ImportClause */ && !!node.name || + node.kind === 249 /* NamespaceImport */ || + node.kind === 251 /* ImportSpecifier */ || + node.kind === 255 /* ExportSpecifier */ || + node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9742,11 +9774,22 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + // Prefer an @augments tag because it may have type parameters. + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; @@ -9755,7 +9798,7 @@ var ts; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -9828,14 +9871,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -9849,9 +9892,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined @@ -9957,7 +10000,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182 /* BindingElement */) { + while (node.kind === 184 /* BindingElement */) { node = node.parent.parent; } return node; @@ -9966,14 +10009,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 /* Constructor */ - || kind === 192 /* FunctionExpression */ - || kind === 234 /* FunctionDeclaration */ - || kind === 193 /* ArrowFunction */ + || kind === 194 /* FunctionExpression */ + || kind === 237 /* FunctionDeclaration */ + || kind === 195 /* ArrowFunction */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ - || kind === 239 /* ModuleDeclaration */ - || kind === 274 /* SourceFile */; + || kind === 242 /* ModuleDeclaration */ + || kind === 277 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9992,23 +10035,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: return 1 /* Right */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -10032,15 +10075,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200 /* BinaryExpression */) { + if (expression.kind === 202 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { + else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10050,15 +10093,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return 0; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return 1; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return 2; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return 4; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -10079,21 +10122,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: return 16; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return 17; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return 18; - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 19 : 18; - case 189 /* TaggedTemplateExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 191 /* TaggedTemplateExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -10103,19 +10146,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 191 /* ParenthesizedExpression */: - case 206 /* OmittedExpression */: + case 204 /* TemplateExpression */: + case 193 /* ParenthesizedExpression */: + case 208 /* OmittedExpression */: return 20; default: return -1; @@ -10174,6 +10217,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -10181,6 +10225,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -10603,7 +10664,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); @@ -10615,7 +10676,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -10908,8 +10969,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 184 /* ObjectLiteralExpression */ - || kind === 183 /* ArrayLiteralExpression */; + return kind === 186 /* ObjectLiteralExpression */ + || kind === 185 /* ArrayLiteralExpression */; } return false; } @@ -10919,7 +10980,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */ + return node.kind === 209 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -10941,16 +11002,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); + (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 /* ObjectLiteralExpression */ && + return expression.kind === 186 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 /* ArrayLiteralExpression */ && + return expression.kind === 185 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11291,8 +11352,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11369,21 +11430,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && parent.parent.kind === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -11486,7 +11547,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -11556,6 +11617,11 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + /* @internal */ + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; // Returns true if 'span' contains 'other'. function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -11749,7 +11815,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { return current; } } @@ -11774,27 +11840,34 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232 /* VariableDeclaration */) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236 /* VariableDeclarationList */) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217 /* VariableStatement */) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags @@ -11804,19 +11877,7 @@ var ts; // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** @@ -11924,16 +11985,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -11950,17 +12001,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return expr.name; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11969,10 +12020,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 228 /* LabeledStatement */: { + case 231 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11984,7 +12035,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -11995,29 +12046,20 @@ var ts; return !!node.name; // A 'name' property should always be a DeclarationName. } ts.isNamedDeclaration = isNamedDeclaration; - // TODO: GH#18217 This is often used as if it returns a defined result - function getNameOfDeclaration(declaration) { - if (!declaration) { - return undefined; - } + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71 /* Identifier */: return declaration; - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: { + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -12029,17 +12071,22 @@ var ts; return undefined; } } - case 292 /* JSDocCallbackTag */: - return declaration.name; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -12328,545 +12375,545 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169 /* UnionType */; + return node.kind === 171 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170 /* IntersectionType */; + return node.kind === 172 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171 /* ConditionalType */; + return node.kind === 173 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172 /* InferType */; + return node.kind === 174 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173 /* ParenthesizedType */; + return node.kind === 175 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174 /* ThisType */; + return node.kind === 176 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175 /* TypeOperator */; + return node.kind === 177 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176 /* IndexedAccessType */; + return node.kind === 178 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177 /* MappedType */; + return node.kind === 179 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178 /* LiteralType */; + return node.kind === 180 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179 /* ImportType */; + return node.kind === 181 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 180 /* ObjectBindingPattern */; + return node.kind === 182 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181 /* ArrayBindingPattern */; + return node.kind === 183 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182 /* BindingElement */; + return node.kind === 184 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 183 /* ArrayLiteralExpression */; + return node.kind === 185 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184 /* ObjectLiteralExpression */; + return node.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185 /* PropertyAccessExpression */; + return node.kind === 187 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186 /* ElementAccessExpression */; + return node.kind === 188 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187 /* CallExpression */; + return node.kind === 189 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188 /* NewExpression */; + return node.kind === 190 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189 /* TaggedTemplateExpression */; + return node.kind === 191 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190 /* TypeAssertionExpression */; + return node.kind === 192 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191 /* ParenthesizedExpression */; + return node.kind === 193 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302 /* PartiallyEmittedExpression */) { + while (node.kind === 305 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192 /* FunctionExpression */; + return node.kind === 194 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193 /* ArrowFunction */; + return node.kind === 195 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194 /* DeleteExpression */; + return node.kind === 196 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195 /* TypeOfExpression */; + return node.kind === 197 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196 /* VoidExpression */; + return node.kind === 198 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197 /* AwaitExpression */; + return node.kind === 199 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198 /* PrefixUnaryExpression */; + return node.kind === 200 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199 /* PostfixUnaryExpression */; + return node.kind === 201 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200 /* BinaryExpression */; + return node.kind === 202 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201 /* ConditionalExpression */; + return node.kind === 203 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202 /* TemplateExpression */; + return node.kind === 204 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203 /* YieldExpression */; + return node.kind === 205 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204 /* SpreadElement */; + return node.kind === 206 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205 /* ClassExpression */; + return node.kind === 207 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206 /* OmittedExpression */; + return node.kind === 208 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208 /* AsExpression */; + return node.kind === 210 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209 /* NonNullExpression */; + return node.kind === 211 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210 /* MetaProperty */; + return node.kind === 212 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 211 /* TemplateSpan */; + return node.kind === 214 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212 /* SemicolonClassElement */; + return node.kind === 215 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 213 /* Block */; + return node.kind === 216 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214 /* VariableStatement */; + return node.kind === 217 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215 /* EmptyStatement */; + return node.kind === 218 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216 /* ExpressionStatement */; + return node.kind === 219 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217 /* IfStatement */; + return node.kind === 220 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218 /* DoStatement */; + return node.kind === 221 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219 /* WhileStatement */; + return node.kind === 222 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220 /* ForStatement */; + return node.kind === 223 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221 /* ForInStatement */; + return node.kind === 224 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222 /* ForOfStatement */; + return node.kind === 225 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223 /* ContinueStatement */; + return node.kind === 226 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224 /* BreakStatement */; + return node.kind === 227 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; + return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225 /* ReturnStatement */; + return node.kind === 228 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226 /* WithStatement */; + return node.kind === 229 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227 /* SwitchStatement */; + return node.kind === 230 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228 /* LabeledStatement */; + return node.kind === 231 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229 /* ThrowStatement */; + return node.kind === 232 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230 /* TryStatement */; + return node.kind === 233 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231 /* DebuggerStatement */; + return node.kind === 234 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232 /* VariableDeclaration */; + return node.kind === 235 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233 /* VariableDeclarationList */; + return node.kind === 236 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234 /* FunctionDeclaration */; + return node.kind === 237 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235 /* ClassDeclaration */; + return node.kind === 238 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236 /* InterfaceDeclaration */; + return node.kind === 239 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237 /* TypeAliasDeclaration */; + return node.kind === 240 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */; + return node.kind === 241 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */; + return node.kind === 242 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240 /* ModuleBlock */; + return node.kind === 243 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241 /* CaseBlock */; + return node.kind === 244 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242 /* NamespaceExportDeclaration */; + return node.kind === 245 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */; + return node.kind === 246 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244 /* ImportDeclaration */; + return node.kind === 247 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245 /* ImportClause */; + return node.kind === 248 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246 /* NamespaceImport */; + return node.kind === 249 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247 /* NamedImports */; + return node.kind === 250 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248 /* ImportSpecifier */; + return node.kind === 251 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249 /* ExportAssignment */; + return node.kind === 252 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250 /* ExportDeclaration */; + return node.kind === 253 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251 /* NamedExports */; + return node.kind === 254 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252 /* ExportSpecifier */; + return node.kind === 255 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253 /* MissingDeclaration */; + return node.kind === 256 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 254 /* ExternalModuleReference */; + return node.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 255 /* JsxElement */; + return node.kind === 258 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256 /* JsxSelfClosingElement */; + return node.kind === 259 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257 /* JsxOpeningElement */; + return node.kind === 260 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258 /* JsxClosingElement */; + return node.kind === 261 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259 /* JsxFragment */; + return node.kind === 262 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260 /* JsxOpeningFragment */; + return node.kind === 263 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261 /* JsxClosingFragment */; + return node.kind === 264 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262 /* JsxAttribute */; + return node.kind === 265 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263 /* JsxAttributes */; + return node.kind === 266 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264 /* JsxSpreadAttribute */; + return node.kind === 267 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265 /* JsxExpression */; + return node.kind === 268 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 266 /* CaseClause */; + return node.kind === 269 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267 /* DefaultClause */; + return node.kind === 270 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268 /* HeritageClause */; + return node.kind === 271 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269 /* CatchClause */; + return node.kind === 272 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 270 /* PropertyAssignment */; + return node.kind === 273 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271 /* ShorthandPropertyAssignment */; + return node.kind === 274 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272 /* SpreadAssignment */; + return node.kind === 275 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 274 /* SourceFile */; + return node.kind === 277 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275 /* Bundle */; + return node.kind === 278 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276 /* UnparsedSource */; + return node.kind === 279 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 278 /* JSDocTypeExpression */; + return node.kind === 281 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279 /* JSDocAllType */; + return node.kind === 282 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280 /* JSDocUnknownType */; + return node.kind === 283 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281 /* JSDocNullableType */; + return node.kind === 284 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282 /* JSDocNonNullableType */; + return node.kind === 285 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283 /* JSDocOptionalType */; + return node.kind === 286 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284 /* JSDocFunctionType */; + return node.kind === 287 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285 /* JSDocVariadicType */; + return node.kind === 288 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286 /* JSDocComment */; + return node.kind === 289 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290 /* JSDocAugmentsTag */; + return node.kind === 293 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291 /* JSDocClassTag */; + return node.kind === 294 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295 /* JSDocThisTag */; + return node.kind === 298 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293 /* JSDocParameterTag */; + return node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294 /* JSDocReturnTag */; + return node.kind === 297 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296 /* JSDocTypeTag */; + return node.kind === 299 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297 /* JSDocTemplateTag */; + return node.kind === 300 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298 /* JSDocTypedefTag */; + return node.kind === 301 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299 /* JSDocPropertyTag */; + return node.kind === 302 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; + return node.kind === 302 /* JSDocPropertyTag */ || node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287 /* JSDocTypeLiteral */; + return node.kind === 290 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288 /* JSDocSignature */; + return node.kind === 291 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -12877,7 +12924,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 300 /* SyntaxList */; + return n.kind === 303 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -12992,8 +13039,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 180 /* ObjectBindingPattern */ - || kind === 181 /* ArrayBindingPattern */; + || kind === 182 /* ObjectBindingPattern */ + || kind === 183 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13008,13 +13055,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; default: return false; @@ -13025,11 +13072,11 @@ var ts; switch (kind) { case 153 /* MethodSignature */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: case 164 /* ConstructorType */: return true; default: @@ -13051,11 +13098,11 @@ var ts; || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ || kind === 160 /* IndexSignature */ - || kind === 212 /* SemicolonClassElement */; + || kind === 215 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); + return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -13090,9 +13137,9 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 /* PropertyAssignment */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 272 /* SpreadAssignment */ + return kind === 273 /* PropertyAssignment */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 275 /* SpreadAssignment */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */; @@ -13100,7 +13147,7 @@ var ts; ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ @@ -13113,14 +13160,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 207 /* ExpressionWithTypeArguments */ - || kind === 279 /* JSDocAllType */ - || kind === 280 /* JSDocUnknownType */ - || kind === 281 /* JSDocNullableType */ - || kind === 282 /* JSDocNonNullableType */ - || kind === 283 /* JSDocOptionalType */ - || kind === 284 /* JSDocFunctionType */ - || kind === 285 /* JSDocVariadicType */; + || kind === 209 /* ExpressionWithTypeArguments */ + || kind === 282 /* JSDocAllType */ + || kind === 283 /* JSDocUnknownType */ + || kind === 284 /* JSDocNullableType */ + || kind === 285 /* JSDocNonNullableType */ + || kind === 286 /* JSDocOptionalType */ + || kind === 287 /* JSDocFunctionType */ + || kind === 288 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13145,8 +13192,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 /* ArrayBindingPattern */ - || kind === 180 /* ObjectBindingPattern */; + return kind === 183 /* ArrayBindingPattern */ + || kind === 182 /* ObjectBindingPattern */; } return false; } @@ -13154,15 +13201,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 /* ArrayLiteralExpression */ - || kind === 184 /* ObjectLiteralExpression */; + return kind === 185 /* ArrayLiteralExpression */ + || kind === 186 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 /* BindingElement */ - || kind === 206 /* OmittedExpression */; + return kind === 184 /* BindingElement */ + || kind === 208 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13171,9 +13218,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return true; } return false; @@ -13194,8 +13241,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return true; } return false; @@ -13207,8 +13254,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return true; } return false; @@ -13217,25 +13264,25 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */ - || kind === 179 /* ImportType */; + || kind === 181 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: case 150 /* Decorator */: return true; default: @@ -13244,12 +13291,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; + return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 /* TemplateExpression */ + return kind === 204 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13260,32 +13307,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: - case 188 /* NewExpression */: - case 187 /* CallExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 189 /* TaggedTemplateExpression */: - case 183 /* ArrayLiteralExpression */: - case 191 /* ParenthesizedExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 190 /* NewExpression */: + case 189 /* CallExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 191 /* TaggedTemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 193 /* ParenthesizedExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 209 /* NonNullExpression */: - case 210 /* MetaProperty */: + case 211 /* NonNullExpression */: + case 212 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13299,13 +13346,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 190 /* TypeAssertionExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 192 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13314,9 +13361,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -13335,15 +13382,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: - case 193 /* ArrowFunction */: - case 200 /* BinaryExpression */: - case 204 /* SpreadElement */: - case 208 /* AsExpression */: - case 206 /* OmittedExpression */: - case 303 /* CommaListExpression */: - case 302 /* PartiallyEmittedExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: + case 195 /* ArrowFunction */: + case 202 /* BinaryExpression */: + case 206 /* SpreadElement */: + case 210 /* AsExpression */: + case 208 /* OmittedExpression */: + case 306 /* CommaListExpression */: + case 305 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13351,18 +13398,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 /* TypeAssertionExpression */ - || kind === 208 /* AsExpression */; + return kind === 192 /* TypeAssertionExpression */ + || kind === 210 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 302 /* PartiallyEmittedExpression */; + return node.kind === 305 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 301 /* NotEmittedStatement */; + return node.kind === 304 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -13373,13 +13420,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return true; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13387,7 +13434,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; + return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13411,113 +13458,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */ + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */; + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 239 /* ModuleDeclaration */; + || kind === 242 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 /* NamedImports */ - || kind === 246 /* NamespaceImport */; + return kind === 250 /* NamedImports */ + || kind === 249 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; + return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 /* ArrowFunction */ - || kind === 182 /* BindingElement */ - || kind === 235 /* ClassDeclaration */ - || kind === 205 /* ClassExpression */ + return kind === 195 /* ArrowFunction */ + || kind === 184 /* BindingElement */ + || kind === 238 /* ClassDeclaration */ + || kind === 207 /* ClassExpression */ || kind === 155 /* Constructor */ - || kind === 238 /* EnumDeclaration */ - || kind === 273 /* EnumMember */ - || kind === 252 /* ExportSpecifier */ - || kind === 234 /* FunctionDeclaration */ - || kind === 192 /* FunctionExpression */ + || kind === 241 /* EnumDeclaration */ + || kind === 276 /* EnumMember */ + || kind === 255 /* ExportSpecifier */ + || kind === 237 /* FunctionDeclaration */ + || kind === 194 /* FunctionExpression */ || kind === 156 /* GetAccessor */ - || kind === 245 /* ImportClause */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 248 /* ImportSpecifier */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 262 /* JsxAttribute */ + || kind === 248 /* ImportClause */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 251 /* ImportSpecifier */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 265 /* JsxAttribute */ || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ - || kind === 239 /* ModuleDeclaration */ - || kind === 242 /* NamespaceExportDeclaration */ - || kind === 246 /* NamespaceImport */ + || kind === 242 /* ModuleDeclaration */ + || kind === 245 /* NamespaceExportDeclaration */ + || kind === 249 /* NamespaceImport */ || kind === 149 /* Parameter */ - || kind === 270 /* PropertyAssignment */ + || kind === 273 /* PropertyAssignment */ || kind === 152 /* PropertyDeclaration */ || kind === 151 /* PropertySignature */ || kind === 157 /* SetAccessor */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 237 /* TypeAliasDeclaration */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 240 /* TypeAliasDeclaration */ || kind === 148 /* TypeParameter */ - || kind === 232 /* VariableDeclaration */ - || kind === 298 /* JSDocTypedefTag */ - || kind === 292 /* JSDocCallbackTag */ - || kind === 299 /* JSDocPropertyTag */; + || kind === 235 /* VariableDeclaration */ + || kind === 301 /* JSDocTypedefTag */ + || kind === 295 /* JSDocCallbackTag */ + || kind === 302 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 234 /* FunctionDeclaration */ - || kind === 253 /* MissingDeclaration */ - || kind === 235 /* ClassDeclaration */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 237 /* TypeAliasDeclaration */ - || kind === 238 /* EnumDeclaration */ - || kind === 239 /* ModuleDeclaration */ - || kind === 244 /* ImportDeclaration */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 250 /* ExportDeclaration */ - || kind === 249 /* ExportAssignment */ - || kind === 242 /* NamespaceExportDeclaration */; + return kind === 237 /* FunctionDeclaration */ + || kind === 256 /* MissingDeclaration */ + || kind === 238 /* ClassDeclaration */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 240 /* TypeAliasDeclaration */ + || kind === 241 /* EnumDeclaration */ + || kind === 242 /* ModuleDeclaration */ + || kind === 247 /* ImportDeclaration */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 253 /* ExportDeclaration */ + || kind === 252 /* ExportAssignment */ + || kind === 245 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 224 /* BreakStatement */ - || kind === 223 /* ContinueStatement */ - || kind === 231 /* DebuggerStatement */ - || kind === 218 /* DoStatement */ - || kind === 216 /* ExpressionStatement */ - || kind === 215 /* EmptyStatement */ - || kind === 221 /* ForInStatement */ - || kind === 222 /* ForOfStatement */ - || kind === 220 /* ForStatement */ - || kind === 217 /* IfStatement */ - || kind === 228 /* LabeledStatement */ - || kind === 225 /* ReturnStatement */ - || kind === 227 /* SwitchStatement */ - || kind === 229 /* ThrowStatement */ - || kind === 230 /* TryStatement */ - || kind === 214 /* VariableStatement */ - || kind === 219 /* WhileStatement */ - || kind === 226 /* WithStatement */ - || kind === 301 /* NotEmittedStatement */ - || kind === 305 /* EndOfDeclarationMarker */ - || kind === 304 /* MergeDeclarationMarker */; + return kind === 227 /* BreakStatement */ + || kind === 226 /* ContinueStatement */ + || kind === 234 /* DebuggerStatement */ + || kind === 221 /* DoStatement */ + || kind === 219 /* ExpressionStatement */ + || kind === 218 /* EmptyStatement */ + || kind === 224 /* ForInStatement */ + || kind === 225 /* ForOfStatement */ + || kind === 223 /* ForStatement */ + || kind === 220 /* IfStatement */ + || kind === 231 /* LabeledStatement */ + || kind === 228 /* ReturnStatement */ + || kind === 230 /* SwitchStatement */ + || kind === 232 /* ThrowStatement */ + || kind === 233 /* TryStatement */ + || kind === 217 /* VariableStatement */ + || kind === 222 /* WhileStatement */ + || kind === 229 /* WithStatement */ + || kind === 304 /* NotEmittedStatement */ + || kind === 308 /* EndOfDeclarationMarker */ + || kind === 307 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 297 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -13544,10 +13591,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213 /* Block */) + if (node.kind !== 216 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { + if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { return false; } } @@ -13557,7 +13604,7 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 254 /* ExternalModuleReference */ + return kind === 257 /* ExternalModuleReference */ || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } @@ -13568,62 +13615,62 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 185 /* PropertyAccessExpression */; + || kind === 187 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 255 /* JsxElement */ - || kind === 265 /* JsxExpression */ - || kind === 256 /* JsxSelfClosingElement */ + return kind === 258 /* JsxElement */ + || kind === 268 /* JsxExpression */ + || kind === 259 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 259 /* JsxFragment */; + || kind === 262 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 /* JsxAttribute */ - || kind === 264 /* JsxSpreadAttribute */; + return kind === 265 /* JsxAttribute */ + || kind === 267 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 265 /* JsxExpression */; + || kind === 268 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 /* JsxOpeningElement */ - || kind === 256 /* JsxSelfClosingElement */; + return kind === 260 /* JsxOpeningElement */ + || kind === 259 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 /* CaseClause */ - || kind === 267 /* DefaultClause */; + return kind === 269 /* CaseClause */ + || kind === 270 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 299 /* LastJSDocNode */; + return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 302 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 289 /* FirstJSDocTagNode */ && node.kind <= 299 /* LastJSDocTagNode */; + return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 302 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -13666,22 +13713,22 @@ var ts; case 161 /* TypePredicate */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: - case 177 /* MappedType */: - case 190 /* TypeAssertionExpression */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 208 /* AsExpression */: - case 232 /* VariableDeclaration */: - case 234 /* FunctionDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 278 /* JSDocTypeExpression */: - case 281 /* JSDocNullableType */: - case 282 /* JSDocNonNullableType */: - case 283 /* JSDocOptionalType */: - case 284 /* JSDocFunctionType */: - case 285 /* JSDocVariadicType */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: + case 179 /* MappedType */: + case 192 /* TypeAssertionExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 210 /* AsExpression */: + case 235 /* VariableDeclaration */: + case 237 /* FunctionDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 281 /* JSDocTypeExpression */: + case 284 /* JSDocNullableType */: + case 285 /* JSDocNonNullableType */: + case 286 /* JSDocOptionalType */: + case 287 /* JSDocFunctionType */: + case 288 /* JSDocVariadicType */: return true; } return false; @@ -13701,10 +13748,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -13716,7 +13763,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13753,7 +13800,7 @@ var ts; (function (ts) { /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; + return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -13894,6 +13941,13 @@ var ts; } /* @internal */ function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + /* @internal */ + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -13901,7 +13955,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; + } + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -14444,17 +14510,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.tryRemovePrefix(path, dirPath); - if (a === undefined) - return undefined; - switch (a.charCodeAt(0)) { - case 47 /* slash */: - case 92 /* backslash */: - return a.slice(1); - default: - return undefined; - } + function isDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; // Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. @@ -15007,7 +15071,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 274 /* SourceFile */) { + if (kind === 277 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -15071,14 +15135,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -15103,20 +15167,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15138,9 +15202,9 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15165,290 +15229,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172 /* InferType */: + case 174 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 179 /* ImportType */: + case 181 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: return visitNode(cbNode, node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177 /* MappedType */: + case 179 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return visitNode(cbNode, node.literal); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitNode(cbNode, node.name); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return visitNode(cbNode, node.label); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 278 /* JSDocTypeExpression */: - return visitNode(cbNode, node.type); - case 282 /* JSDocNonNullableType */: - return visitNode(cbNode, node.type); - case 281 /* JSDocNullableType */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 281 /* JSDocTypeExpression */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 286 /* JSDocOptionalType */: + case 288 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 283 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 286 /* JSDocComment */: + case 289 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15457,17 +15519,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 278 /* JSDocTypeExpression */) { + node.typeExpression.kind === 281 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15475,18 +15537,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292 /* JSDocCallbackTag */: + case 295 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295 /* JSDocThisTag */: + case 298 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 287 /* JSDocTypeLiteral */: + case 290 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15494,7 +15556,7 @@ var ts; } } return; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15708,7 +15770,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216 /* ExpressionStatement */); + var statement = createNode(219 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15825,13 +15887,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); // Should only be called once per node + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -15867,7 +15926,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // 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(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16674,7 +16733,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 152 /* PropertyDeclaration */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return true; case 154 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -16691,8 +16750,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: return true; } } @@ -16701,42 +16760,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 214 /* VariableStatement */: - case 213 /* Block */: - case 217 /* IfStatement */: - case 216 /* ExpressionStatement */: - case 229 /* ThrowStatement */: - case 225 /* ReturnStatement */: - case 227 /* SwitchStatement */: - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 215 /* EmptyStatement */: - case 230 /* TryStatement */: - case 228 /* LabeledStatement */: - case 218 /* DoStatement */: - case 231 /* DebuggerStatement */: - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 217 /* VariableStatement */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 219 /* ExpressionStatement */: + case 232 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 230 /* SwitchStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 218 /* EmptyStatement */: + case 233 /* TryStatement */: + case 231 /* LabeledStatement */: + case 221 /* DoStatement */: + case 234 /* DebuggerStatement */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -16752,7 +16811,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232 /* VariableDeclaration */) { + if (node.kind !== 235 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16878,7 +16937,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -16940,7 +17004,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202 /* TemplateExpression */); + var template = createNode(204 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -16952,7 +17016,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211 /* TemplateSpan */); + var span = createNode(214 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -17018,10 +17082,9 @@ var ts; case 163 /* FunctionType */: case 164 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17035,14 +17098,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174 /* ThisType */); + var node = createNode(176 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279 /* JSDocAllType */); + var result = createNode(282 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, result); + return createPostfixType(286 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17050,7 +17113,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282 /* JSDocNonNullableType */); + var result = createNode(285 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17074,18 +17137,18 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(280 /* JSDocUnknownType */, pos); + var result = createNode(283 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(281 /* JSDocNullableType */, pos); + var result = createNode(284 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -17107,12 +17170,12 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, type); + return createPostfixType(286 /* JSDocOptionalType */, type); } return type; } @@ -17452,7 +17515,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177 /* MappedType */); + var node = createNode(179 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17474,13 +17537,26 @@ var ts; parseExpected(18 /* CloseBraceToken */); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24 /* DotDotDotToken */)) { + var node = createNode(170 /* RestType */, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 169 /* OptionalType */; + } + return type; + } function parseTupleType() { var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173 /* ParenthesizedType */); + var node = createNode(175 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); parseExpected(20 /* CloseParenToken */); @@ -17498,10 +17574,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178 /* LiteralType */); + var node = createNode(180 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17522,7 +17598,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(179 /* ImportType */); + var node = createNode(181 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17648,19 +17724,19 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); + type = createPostfixType(285 /* JSDocNonNullableType */, type); break; case 55 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(281 /* JSDocNullableType */, type); + type = createPostfixType(284 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(176 /* IndexedAccessType */, type.pos); + var node = createNode(178 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); @@ -17679,21 +17755,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175 /* TypeOperator */); + var node = createNode(177 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172 /* InferType */); + var node = createNode(174 /* InferType */); parseExpected(126 /* InferKeyword */); var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); @@ -17726,10 +17802,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17813,7 +17889,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(171 /* ConditionalType */, type.pos); + var node = createNode(173 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -18006,7 +18082,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203 /* YieldExpression */); + var node = createNode(205 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -18028,11 +18104,11 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193 /* ArrowFunction */, asyncModifier.pos); + node = createNode(195 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193 /* ArrowFunction */, identifier.pos); + node = createNode(195 /* ArrowFunction */, identifier.pos); } var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; @@ -18230,7 +18306,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193 /* ArrowFunction */); + var node = createNodeWithJSDoc(195 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18294,7 +18370,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(201 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18374,39 +18450,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200 /* BinaryExpression */, left.pos); + var node = createNode(202 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208 /* AsExpression */, left.pos); + var node = createNode(210 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194 /* DeleteExpression */); + var node = createNode(196 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195 /* TypeOfExpression */); + var node = createNode(197 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196 /* VoidExpression */); + var node = createNode(198 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18422,7 +18498,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197 /* AwaitExpression */); + var node = createNode(199 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18466,7 +18542,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { parseErrorAt(pos, end, 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 { @@ -18563,7 +18639,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18576,7 +18652,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18632,7 +18708,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(210 /* MetaProperty */, fullStart); + var node = createNode(212 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18707,7 +18783,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(185 /* PropertyAccessExpression */, expression.pos); + var node = createNode(187 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -18716,8 +18792,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257 /* JsxOpeningElement */) { - var node = createNode(255 /* JsxElement */, opening.pos); + if (opening.kind === 260 /* JsxOpeningElement */) { + var node = createNode(258 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18726,15 +18802,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260 /* JsxOpeningFragment */) { - var node = createNode(259 /* JsxFragment */, opening.pos); + else if (opening.kind === 263 /* JsxOpeningFragment */) { + var node = createNode(262 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18749,7 +18825,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(200 /* BinaryExpression */, result.pos); + var badNode = createNode(202 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -18807,7 +18883,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263 /* JsxAttributes */); + var jsxAttributes = createNode(266 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18816,7 +18892,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18828,7 +18904,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(257 /* JsxOpeningElement */, fullStart); + node = createNode(260 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18840,7 +18916,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(256 /* JsxSelfClosingElement */, fullStart); + node = createNode(259 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18857,7 +18933,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18865,7 +18941,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265 /* JsxExpression */); + var node = createNode(268 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18887,7 +18963,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262 /* JsxAttribute */); + var node = createNode(265 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18902,7 +18978,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264 /* JsxSpreadAttribute */); + var node = createNode(267 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18910,7 +18986,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258 /* JsxClosingElement */); + var node = createNode(261 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18923,7 +18999,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261 /* JsxClosingFragment */); + var node = createNode(264 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18938,7 +19014,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190 /* TypeAssertionExpression */); + var node = createNode(192 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18949,7 +19025,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18957,14 +19033,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(211 /* 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(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(186 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -18991,7 +19067,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -19015,7 +19091,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -19023,7 +19099,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19135,28 +19211,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204 /* SpreadElement */); + var node = createNode(206 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183 /* ArrayLiteralExpression */); + var node = createNode(185 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19168,7 +19244,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 272 /* SpreadAssignment */; + node.kind = 275 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19195,7 +19271,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - node.kind = 271 /* ShorthandPropertyAssignment */; + node.kind = 274 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -19203,14 +19279,14 @@ var ts; } } else { - node.kind = 270 /* PropertyAssignment */; + node.kind = 273 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184 /* ObjectLiteralExpression */); + var node = createNode(186 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19229,7 +19305,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(192 /* FunctionExpression */); + var node = createNodeWithJSDoc(194 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19254,7 +19330,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(210 /* MetaProperty */, fullStart); + var node_2 = createNode(212 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19271,7 +19347,7 @@ var ts; } break; } - var node = createNode(188 /* NewExpression */, fullStart); + var node = createNode(190 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19281,7 +19357,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213 /* Block */); + var node = createNode(216 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19314,12 +19390,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215 /* EmptyStatement */); + var node = createNode(218 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(217 /* IfStatement */); + var node = createNode(220 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19329,7 +19405,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218 /* DoStatement */); + var node = createNode(221 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19344,7 +19420,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219 /* WhileStatement */); + var node = createNode(222 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19368,7 +19444,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(222 /* ForOfStatement */, pos); + var forOfStatement = createNode(225 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19376,14 +19452,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(221 /* ForInStatement */, pos); + var forInStatement = createNode(224 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220 /* ForStatement */, pos); + var forStatement = createNode(223 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19401,7 +19477,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19409,7 +19485,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225 /* ReturnStatement */); + var node = createNode(228 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19418,7 +19494,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226 /* WithStatement */); + var node = createNode(229 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19427,7 +19503,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266 /* CaseClause */); + var node = createNode(269 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19435,7 +19511,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267 /* DefaultClause */); + var node = createNode(270 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19445,12 +19521,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227 /* SwitchStatement */); + var node = createNode(230 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(241 /* CaseBlock */); + var caseBlock = createNode(244 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19465,7 +19541,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(229 /* ThrowStatement */); + var node = createNode(232 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19473,7 +19549,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(230 /* TryStatement */); + var node = createNode(233 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19486,7 +19562,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269 /* CatchClause */); + var result = createNode(272 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19500,7 +19576,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231 /* DebuggerStatement */); + var node = createNode(234 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19512,12 +19588,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 228 /* LabeledStatement */; + node.kind = 231 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216 /* ExpressionStatement */; + node.kind = 219 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19684,16 +19760,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19703,9 +19779,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(223 /* ContinueStatement */); + return parseBreakOrContinueStatement(226 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(224 /* BreakStatement */); + return parseBreakOrContinueStatement(227 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19802,7 +19878,7 @@ var ts; if (node.decorators || node.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 missing = createMissingNode(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -19825,16 +19901,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(206 /* OmittedExpression */); + return createNode(208 /* OmittedExpression */); } - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19850,14 +19926,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180 /* ObjectBindingPattern */); + var node = createNode(182 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181 /* ArrayBindingPattern */); + var node = createNode(183 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19879,7 +19955,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232 /* VariableDeclaration */); + var node = createNode(235 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19892,7 +19968,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233 /* VariableDeclarationList */); + var node = createNode(236 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19930,13 +20006,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 214 /* VariableStatement */; + node.kind = 217 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234 /* FunctionDeclaration */; + node.kind = 237 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -20118,7 +20194,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(212 /* SemicolonClassElement */); + var result = createNode(215 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -20155,10 +20231,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -20201,14 +20277,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(268 /* HeritageClause */); + var node = createNode(271 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -20225,7 +20301,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236 /* InterfaceDeclaration */; + node.kind = 239 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20234,7 +20310,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237 /* TypeAliasDeclaration */; + node.kind = 240 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20248,13 +20324,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 = createNodeWithJSDoc(273 /* EnumMember */); + var node = createNodeWithJSDoc(276 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238 /* EnumDeclaration */; + node.kind = 241 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20267,7 +20343,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240 /* ModuleBlock */); + var node = createNode(243 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20278,7 +20354,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; // 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 */; @@ -20290,7 +20366,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -20336,7 +20412,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 242 /* NamespaceExportDeclaration */; + node.kind = 245 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20354,7 +20430,7 @@ var ts; } } // Import statement - node.kind = 244 /* ImportDeclaration */; + node.kind = 247 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20369,7 +20445,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243 /* ImportEqualsDeclaration */; + node.kind = 246 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20383,7 +20459,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(245 /* ImportClause */, fullStart); + var importClause = createNode(248 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20393,7 +20469,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); } return finishNode(importClause); } @@ -20403,7 +20479,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(254 /* ExternalModuleReference */); + var node = createNode(257 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20426,7 +20502,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(246 /* NamespaceImport */); + var namespaceImport = createNode(249 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20441,14 +20517,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252 /* ExportSpecifier */); + return parseImportOrExportSpecifier(255 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248 /* ImportSpecifier */); + return parseImportOrExportSpecifier(251 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20473,19 +20549,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250 /* ExportDeclaration */; + node.kind = 253 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(254 /* 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. @@ -20498,7 +20574,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249 /* ExportAssignment */; + node.kind = 252 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20518,10 +20594,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ - || node.kind === 244 /* ImportDeclaration */ - || node.kind === 249 /* ExportAssignment */ - || node.kind === 250 /* ExportDeclaration */ + || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ + || node.kind === 247 /* ImportDeclaration */ + || node.kind === 252 /* ExportAssignment */ + || node.kind === 253 /* ExportDeclaration */ ? node : undefined; } @@ -20584,7 +20660,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20644,17 +20720,16 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var state = 1 /* SawAsterisk */; @@ -20740,9 +20815,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -20754,7 +20828,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286 /* JSDocComment */, start); + var result = createNode(289 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20871,6 +20945,16 @@ var ts; indent += whitespace.length; } break; + case 17 /* OpenBraceToken */: + state = 2 /* SavingComments */; + if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token @@ -20892,7 +20976,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289 /* JSDocTag */, atToken.pos); + var result = createNode(292 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20952,8 +21036,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(299 /* JSDocPropertyTag */, atToken.pos) : - createNode(293 /* JSDocParameterTag */, atToken.pos); + createNode(302 /* JSDocPropertyTag */, atToken.pos) : + createNode(296 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -20973,18 +21057,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 293 /* JSDocParameterTag */ || child.kind === 299 /* JSDocPropertyTag */) { + if (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -20995,27 +21079,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocReturnTag */, atToken.pos); + var result = createNode(297 /* 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 === 296 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296 /* JSDocTypeTag */, atToken.pos); + var result = createNode(299 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -21023,7 +21107,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -21035,7 +21119,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(185 /* PropertyAccessExpression */, node.pos); + var prop = createNode(187 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -21043,13 +21127,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291 /* JSDocClassTag */, atToken.pos); + var tag = createNode(294 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295 /* JSDocThisTag */, atToken.pos); + var tag = createNode(298 /* JSDocThisTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); @@ -21059,7 +21143,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(301 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21075,9 +21159,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 296 /* JSDocTypeTag */) { + if (child.kind === 299 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21109,7 +21193,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21123,7 +21207,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21132,7 +21216,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288 /* JSDocSignature */, start); + var jsdocSignature = createNode(291 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -21140,7 +21224,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 294 /* JSDocReturnTag */) { + if (tag && tag.kind === 297 /* JSDocReturnTag */) { return tag; } } @@ -21185,9 +21269,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 /* JSDocParameterTag */ && + if (child && (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -21261,7 +21345,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(300 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22065,6 +22149,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -23234,7 +23319,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 270 /* PropertyAssignment */) { + if (element.kind !== 273 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -23311,13 +23396,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -23334,7 +23419,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25422,24 +25507,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 238 /* EnumDeclaration */: - if (ts.isConst(node)) { + case 241 /* EnumDeclaration */: + if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 240 /* ModuleBlock */: { + case 243 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -25461,7 +25546,7 @@ var ts; }); return state_1; } - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -25620,7 +25705,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -25645,32 +25730,32 @@ var ts; return "__constructor" /* Constructor */; case 163 /* FunctionType */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return "__call" /* Call */; case 164 /* ConstructorType */: case 159 /* ConstructSignature */: return "__new" /* New */; case 160 /* IndexSignature */: return "__index" /* Index */; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 149 /* 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 === 284 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -25764,7 +25849,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 && - (node.kind === 249 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 252 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -25789,7 +25874,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -25856,7 +25941,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -25901,7 +25986,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -25950,8 +26035,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -25983,77 +26068,78 @@ var ts; return; } switch (node.kind) { - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: bindWhileStatement(node); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: bindDoStatement(node); break; - case 220 /* ForStatement */: + case 223 /* ForStatement */: bindForStatement(node); break; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: bindIfStatement(node); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: bindTryStatement(node); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: bindSwitchStatement(node); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: bindCaseBlock(node); break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: bindCaseClause(node); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: bindLabeledStatement(node); break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: bindCallExpressionFlow(node); break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 274 /* SourceFile */: + case 277 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213 /* Block */: - case 240 /* ModuleBlock */: + } + case 216 /* Block */: + case 243 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -26066,15 +26152,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return hasNarrowableArgument(expr); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -26083,7 +26169,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -26094,7 +26180,7 @@ var ts; } } } - if (expr.expression.kind === 185 /* PropertyAccessExpression */ && + if (expr.expression.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -26127,9 +26213,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -26207,33 +26293,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return parent.expression === node; - case 220 /* ForStatement */: - case 201 /* ConditionalExpression */: + case 223 /* ForStatement */: + case 203 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191 /* ParenthesizedExpression */) { + if (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 /* ParenthesizedExpression */ || - node.parent.kind === 198 /* PrefixUnaryExpression */ && + while (node.parent.kind === 193 /* ParenthesizedExpression */ || + node.parent.kind === 200 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -26275,7 +26361,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -26309,13 +26395,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222 /* ForOfStatement */) { + if (node.kind === 225 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233 /* VariableDeclarationList */) { + if (node.initializer.kind !== 236 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -26337,7 +26423,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225 /* ReturnStatement */) { + if (node.kind === 228 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -26357,7 +26443,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -26453,7 +26539,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* 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; @@ -26521,14 +26607,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -26539,10 +26625,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183 /* ArrayLiteralExpression */) { + else if (node.kind === 185 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204 /* SpreadElement */) { + if (e.kind === 206 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -26550,16 +26636,16 @@ var ts; } } } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270 /* PropertyAssignment */) { + if (p.kind === 273 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271 /* ShorthandPropertyAssignment */) { + else if (p.kind === 274 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272 /* SpreadAssignment */) { + else if (p.kind === 275 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -26615,7 +26701,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26626,7 +26712,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -26673,10 +26759,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 === 191 /* ParenthesizedExpression */) { + while (expr.kind === 193 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { + if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -26684,7 +26770,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26693,21 +26779,21 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 266 /* JsxAttributes */: return 1 /* IsContainer */; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 179 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -26715,32 +26801,32 @@ var ts; } // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: - case 284 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: case 163 /* FunctionType */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 269 /* CatchClause */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 241 /* CaseBlock */: + case 272 /* CatchClause */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 244 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 213 /* Block */: + case 216 /* 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 @@ -26773,20 +26859,20 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 184 /* ObjectLiteralExpression */: - case 236 /* InterfaceDeclaration */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 186 /* ObjectLiteralExpression */: + case 239 /* InterfaceDeclaration */: + case 266 /* 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 @@ -26797,21 +26883,21 @@ var ts; case 164 /* ConstructorType */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 160 /* IndexSignature */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 284 /* JSDocFunctionType */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 287 /* JSDocFunctionType */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 240 /* TypeAliasDeclaration */: + case 179 /* 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 @@ -26832,11 +26918,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { + var body = node.kind === 277 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { + if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { return true; } } @@ -26920,7 +27006,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -26932,7 +27018,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -26964,10 +27050,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -27108,8 +27194,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 274 /* SourceFile */ && - blockScopeContainer.kind !== 239 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 277 /* SourceFile */ && + blockScopeContainer.kind !== 242 /* 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. @@ -27205,7 +27291,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1 /* EndOfFileToken */) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -27263,11 +27353,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -27275,7 +27365,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -27303,19 +27393,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return checkStrictModeCatchClause(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkStrictModeWithStatement(node); - case 174 /* ThisType */: + case 176 /* ThisType */: seenThisKeyword = true; return; case 161 /* TypePredicate */: @@ -27324,18 +27414,18 @@ var ts; return bindTypeParameter(node); case 149 /* Parameter */: return bindParameter(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); case 158 /* CallSignature */: case 159 /* ConstructSignature */: @@ -27348,7 +27438,7 @@ var ts; // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 67208127 /* MethodExcludes */); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -27357,83 +27447,83 @@ var ts; case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 177 /* MappedType */: + case 290 /* JSDocTypeLiteral */: + case 179 /* MappedType */: return bindAnonymousTypeWorker(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return bindFunctionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return bindJsxAttributes(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return bindImportClause(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return bindExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return bindExportAssignment(node); - case 274 /* SourceFile */: + case 277 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213 /* Block */: + case 216 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 293 /* JSDocParameterTag */: - if (node.parent.kind === 288 /* JSDocSignature */) { + case 296 /* JSDocParameterTag */: + if (node.parent.kind === 291 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { break; } // falls through - case 299 /* JSDocPropertyTag */: + case 302 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -27465,7 +27555,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; ? 2097152 /* Alias */ // An export default clause with any other expression exports a value @@ -27479,7 +27569,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274 /* SourceFile */) { + if (node.parent.kind !== 277 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -27564,8 +27654,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -27592,7 +27682,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -27604,7 +27694,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -27661,9 +27751,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + : propertyAccess.parent.parent.kind === 277 /* SourceFile */; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; @@ -27757,7 +27847,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -27790,7 +27880,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); } @@ -27820,7 +27910,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { + if (node.kind === 296 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -27897,7 +27987,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 172 /* InferType */) { + else if (node.parent.kind === 174 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -27925,13 +28015,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || // report error on class declarations - node.kind === 235 /* ClassDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -27988,43 +28078,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); @@ -28035,11 +28125,11 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -28091,12 +28181,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* 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 === 58 /* EqualsToken */ && leftKind === 183 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -28145,8 +28235,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 === 208 /* AsExpression */ - || expressionKind === 190 /* TypeAssertionExpression */) { + if (expressionKind === 210 /* AsExpression */ + || expressionKind === 192 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -28523,13 +28613,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -28540,25 +28630,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 209 /* NonNullExpression */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 211 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: case 10 /* JsxText */: - case 258 /* JsxClosingElement */: - case 259 /* JsxFragment */: - case 260 /* JsxOpeningFragment */: - case 261 /* JsxClosingFragment */: - case 262 /* JsxAttribute */: - case 263 /* JsxAttributes */: - case 264 /* JsxSpreadAttribute */: - case 265 /* JsxExpression */: + case 261 /* JsxClosingElement */: + case 262 /* JsxFragment */: + case 263 /* JsxOpeningFragment */: + case 264 /* JsxClosingFragment */: + case 265 /* JsxAttribute */: + case 266 /* JsxAttributes */: + case 267 /* JsxSpreadAttribute */: + case 268 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -28566,11 +28656,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: - case 271 /* ShorthandPropertyAssignment */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 274 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -28584,14 +28674,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -28618,19 +28708,21 @@ var ts; case 166 /* TypeLiteral */: case 167 /* ArrayType */: case 168 /* TupleType */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 171 /* ConditionalType */: - case 172 /* InferType */: - case 173 /* ParenthesizedType */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 174 /* ThisType */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: - case 178 /* LiteralType */: - case 242 /* NamespaceExportDeclaration */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 174 /* InferType */: + case 175 /* ParenthesizedType */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: + case 245 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; @@ -28652,10 +28744,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -28667,18 +28759,18 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; @@ -28688,7 +28780,7 @@ var ts; // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -28706,8 +28798,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 183 /* ArrayLiteralExpression */: - case 188 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: + case 190 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -28715,26 +28807,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -28750,27 +28842,27 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 183 /* ArrayLiteralExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return 942011713 /* ClassExcludes */; case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; @@ -28792,24 +28884,24 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 269 /* CatchClause */: + case 272 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: - case 191 /* ParenthesizedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: + case 193 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -29098,6 +29190,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -29171,7 +29264,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -29269,6 +29361,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -29327,7 +29420,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -29384,6 +29477,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; /** @@ -29597,143 +29691,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); - }, - buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } - symbolToString(symbol, enclosingDeclaration, meaning, flags | 4 /* AllowAnyNodeKind */, emitTextWriterWrapper(writer)); - }, - buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildParameterDisplay: function (symbol, writer, enclosing, flags) { - var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { - var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 8192 /* OmitParameterModifiers */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896 /* TypeParameters */, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { - var printer = ts.createPrinter({ removeComments: true }); - var flags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */ | toNodeBuilderFlags(originalFlags); - var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; // TODO: GH#18217 - var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); // TODO: GH#18217 - printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForTypeParametersAndDelimiters: function (typeParameters, writer, enclosing, flags) { - var printer = ts.createPrinter({ removeComments: true }); - var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); // TODO: GH#18217 - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -29771,6 +29728,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -29896,22 +29878,57 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), 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 & 384 /* Enum */ || source.flags & 384 /* Enum */ + var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); + var isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 /* LessThan */ ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -29986,7 +30003,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -30044,17 +30061,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 182 /* BindingElement */) { + if (declaration.kind === 184 /* 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, 182 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 184 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || 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, 232 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235 /* VariableDeclaration */), usage); } - else if (declaration.kind === 232 /* VariableDeclaration */) { + else if (declaration.kind === 235 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -30072,12 +30089,12 @@ var ts; // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 249 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 252 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -30085,9 +30102,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214 /* VariableStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 217 /* VariableStatement */: + case 223 /* ForStatement */: + case 225 /* 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)) { @@ -30159,7 +30176,7 @@ 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 & 67901928 /* Type */ && lastLocation.kind !== 286 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -30179,7 +30196,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171 /* ConditionalType */) { + else if (location.kind === 173 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -30193,14 +30210,14 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 277 /* 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.get("default" /* Default */)) { @@ -30224,7 +30241,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { break; } } @@ -30238,7 +30255,7 @@ var ts; } } break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -30261,9 +30278,9 @@ var ts; } } break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -30279,7 +30296,7 @@ var ts; } break loop; } - if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -30287,7 +30304,7 @@ var ts; } } break; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -30309,7 +30326,7 @@ var ts; // case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -30322,14 +30339,14 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -30364,8 +30381,8 @@ var ts; location = location.parent; } break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -30384,7 +30401,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -30458,7 +30475,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67216319 /* Value */) === 67216319 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 242 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -30467,12 +30484,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 239 /* ModuleDeclaration */: // For `namespace N { N; }` + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -30540,9 +30557,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -30606,18 +30623,26 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238 /* EnumDeclaration */) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32 /* Class */) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256 /* RegularEnum */) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -30630,13 +30655,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 245 /* ImportClause */: + case 248 /* ImportClause */: return node.parent; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return node.parent.parent; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -30646,7 +30671,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -30834,20 +30859,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 249 /* ExportAssignment */: - case 200 /* BinaryExpression */: + case 252 /* ExportAssignment */: + case 202 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -30908,11 +30933,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 252 /* ExportSpecifier */) { + else if (node.kind === 255 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -30940,7 +30965,7 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -30964,7 +30989,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -31129,10 +31154,19 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages( + /*details*/ undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)) + : undefined; errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -31158,7 +31192,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -31391,6 +31425,12 @@ var ts; var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -31409,25 +31449,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -31443,12 +31477,12 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -31545,7 +31579,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -31657,10 +31691,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -31713,8 +31747,8 @@ var ts; // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || - entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || + entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -31796,64 +31830,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; // TODO: GH#18217 + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -31861,6 +31864,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -31978,7 +31983,7 @@ var ts; var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -32047,7 +32052,7 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -32085,7 +32090,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; + return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -32133,8 +32138,15 @@ var ts; } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -32348,7 +32360,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -32402,7 +32414,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -32410,7 +32422,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; - var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -32419,7 +32431,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; + var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -32429,7 +32442,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 182 /* BindingElement */) { + if (clone.kind === 184 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -32513,17 +32526,49 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + if (context.tracker.trackReferencedAmbientModule) { + var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); + if (ts.length(ambientDecls)) { + for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { + var decl = ambientDecls_1[_i]; + context.tracker.trackReferencedAmbientModule(decl, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= 16777216 /* InInitialEntityName */; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216 /* InInitialEntityName */; var isTypeOf = meaning === 67216319 /* Value */; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -32697,8 +32742,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173 /* ParenthesizedType */; }); - if (node.kind === 237 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); + if (node.kind === 240 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -32706,11 +32751,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 /* ModuleBlock */ && + node.parent.kind === 243 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -32730,42 +32775,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 - var file = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); - if (!file || !context.tracker.moduleResolverHost) { - if (context.tracker.trackReferencedAmbientModule) { - var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); - if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; - context.tracker.trackReferencedAmbientModule(decl); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205 /* ClassExpression */: - return "(Anonymous class)"; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - return "(Anonymous function)"; + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + context.encounteredError = true; + } + return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -32790,27 +32815,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 234 /* FunctionDeclaration */: - case 238 /* EnumDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 241 /* EnumDeclaration */: + case 246 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -32818,7 +32843,7 @@ var ts; 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 !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -32840,31 +32865,31 @@ var ts; case 158 /* CallSignature */: case 160 /* IndexSignature */: case 149 /* Parameter */: - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: case 162 /* TypeReference */: case 167 /* ArrayType */: case 168 /* TupleType */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 173 /* ParenthesizedType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 175 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: return false; // Type parameters are always visible case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 274 /* SourceFile */: - case 242 /* NamespaceExportDeclaration */: + case 277 /* SourceFile */: + case 245 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return false; default: return false; @@ -32873,10 +32898,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 252 /* ExportSpecifier */) { + else if (node.parent.kind === 255 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -32972,12 +32997,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232 /* VariableDeclaration */: - case 233 /* VariableDeclarationList */: - case 248 /* ImportSpecifier */: - case 247 /* NamedImports */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 235 /* VariableDeclaration */: + case 236 /* VariableDeclarationList */: + case 251 /* ImportSpecifier */: + case 250 /* NamedImports */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: return false; default: return true; @@ -33054,7 +33079,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180 /* ObjectBindingPattern */) { + if (pattern.kind === 182 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -33124,22 +33149,27 @@ var ts; // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); + // If the parent is a tuple type, the rest element has an array type with a union of the + // remaining tuple element types. Otherwise, the rest element has an array type with same + // element type as the parent type. + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -33150,7 +33180,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2 /* Subtype */) : type; } @@ -33167,7 +33197,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -33177,11 +33207,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* 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, @@ -33200,7 +33230,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // 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 @@ -33272,20 +33302,20 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : - declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : ts.getSpecialPropertyAssignmentKind(expression); if (special === 4 /* ThisProperty */) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. declarationInConstructor = thisContainer.kind === 155 /* Constructor */ || - thisContainer.kind === 234 /* FunctionDeclaration */ || - (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 /* FunctionDeclaration */ || + (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -33306,7 +33336,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { // If we don't have an explicit JSDoc type, get the type from the expression. var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 /* Anonymous */ && @@ -33388,7 +33418,7 @@ var ts; // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -33433,12 +33463,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } - // If the pattern has at least one element, and no rest element, then it should imply a tuple type. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -33455,7 +33486,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 /* ObjectBindingPattern */ + return pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -33524,7 +33555,7 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 249 /* ExportAssignment */) { + if (declaration.kind === 252 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -33728,8 +33759,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 202 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 187 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 202 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -33866,35 +33897,35 @@ var ts; return undefined; } switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 153 /* MethodSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 177 /* MappedType */: - case 171 /* ConditionalType */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 179 /* MappedType */: + case 173 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177 /* MappedType */) { + if (node.kind === 179 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171 /* ConditionalType */) { + else if (node.kind === 173 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && + (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -33902,7 +33933,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, 236 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -33911,9 +33942,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 235 /* ClassDeclaration */ || - node.kind === 205 /* ClassExpression */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || + node.kind === 207 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -33947,15 +33978,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - // Prefer an @augments tag because it may have type parameters. - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -33978,7 +34001,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -34011,7 +34034,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { if (type.symbol.flags & 32 /* Class */) { @@ -34074,7 +34097,7 @@ var ts; // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a // partial instantiation of the members without the base types fully resolved - type.members = undefined; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -34099,7 +34122,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -34135,7 +34158,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */) { + if (declaration.kind === 239 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -34193,7 +34216,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -34220,7 +34243,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 200 /* BinaryExpression */) { + else if (expr.kind === 202 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -34234,12 +34257,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 71 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -34253,7 +34276,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -34280,7 +34303,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 @@ -34370,7 +34393,7 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 178 /* LiteralType */: + case 180 /* LiteralType */: return true; case 167 /* ArrayType */: return isThislessType(node.elementType); @@ -34750,6 +34773,28 @@ var ts; return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 /* RestParameter */ : + i >= minLength_1 ? 4096 /* OptionalParameter */ : 0; + var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); @@ -34927,6 +34972,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); @@ -34935,6 +34981,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); @@ -35093,7 +35140,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 175 /* TypeOperator */ && + return constraintDeclaration.kind === 177 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -35213,6 +35260,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144 /* Union */)) { @@ -35670,10 +35728,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJavaScriptFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 283 /* JSDocOptionalType */ + node.type && node.type.kind === 286 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -35692,7 +35750,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -35707,7 +35765,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -35802,7 +35860,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178 /* LiteralType */) { + if (type && type.kind === 180 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -35850,9 +35908,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 8192 /* RestParameter */); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { // Replace the last parameter with a rest parameter. parameters.pop(); @@ -35958,9 +36015,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -36003,16 +36060,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1 /* Number */) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -36114,32 +36168,40 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - // When an 'infer T' declaration is immediately contained in a type reference node - // (such as 'Foo'), T's constraint is inferred from the constraint of the - // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are - // present, we form an intersection of the inferred constraint types. - if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - // Type parameter constraints can reference other type parameters so - // constraints need to be instantiated. If instantiation produces the - // type parameter itself, we discard that inference. For example, in - // type Foo = [T, U]; - // type Bar = T extends Foo ? Foo : T; - // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174 /* InferType */) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162 /* TypeReference */) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + // When an 'infer T' declaration is immediately contained in a rest parameter + // declaration, we infer an 'unknown[]' constraint. + else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -36234,7 +36296,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 290 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 293 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -36293,7 +36355,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -36386,9 +36448,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -36500,9 +36562,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return declaration; } } @@ -36623,18 +36685,26 @@ var ts; // // Note that the generic type created by this function has no symbol associated with it. The same // is true for each of the synthesized type parameters. - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536 /* TypeParameter */); - typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + if (i < maxLength) { + var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4 /* Property */, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; @@ -36652,21 +36722,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -37060,7 +37156,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -37125,7 +37221,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -37145,6 +37241,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { @@ -37155,7 +37257,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -37172,14 +37274,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } @@ -37285,7 +37395,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to 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 (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -37425,7 +37535,7 @@ var ts; return true; } while (node) { - if (node.kind === 171 /* ConditionalType */) { + if (node.kind === 173 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -37523,7 +37633,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } else { - error(node, targetMeaning === 67216319 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + var errorMessage = targetMeaning === 67216319 /* Value */ + ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here + : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -37729,7 +37842,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -37748,8 +37861,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return anyType; case 142 /* UnknownKeyword */: return unknownType; @@ -37771,16 +37884,16 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 162 /* TypeReference */: return getTypeFromTypeReference(node); case 161 /* TypePredicate */: return booleanType; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); @@ -37788,38 +37901,41 @@ var ts; return getTypeFromArrayTypeNode(node); case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return getTypeFromOptionalTypeNode(node); + case 171 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 173 /* ParenthesizedType */: - case 282 /* JSDocNonNullableType */: - case 278 /* JSDocTypeExpression */: + case 175 /* ParenthesizedType */: + case 170 /* RestType */: + case 285 /* JSDocNonNullableType */: + case 281 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 172 /* InferType */: + case 174 /* InferType */: return getTypeFromInferTypeNode(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode @@ -37968,7 +38084,7 @@ 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(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | (ts.getCheckFlags(symbol) & 1024 /* Late */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (1024 /* Late */ | 4096 /* OptionalParameter */ | 8192 /* RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -37979,11 +38095,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -38048,14 +38159,14 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 213 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -38193,32 +38304,32 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive); - case 262 /* JsxAttribute */: { + case 265 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265 /* JsxExpression */: { + case 268 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -38235,7 +38346,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -38245,7 +38356,7 @@ var ts; } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 213 /* Block */ ? false : isContextSensitive(body); + return body.kind === 216 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -38315,8 +38426,206 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268 /* JsxExpression */: + case 193 /* ParenthesizedExpression */: + return elaborateError(node.expression, source, target); + case 202 /* BinaryExpression */: + switch (node.operatorToken.kind) { + case 58 /* EqualsToken */: + case 26 /* CommaToken */: + return elaborateError(node.right, source, target); + } + break; + case 186 /* ObjectLiteralExpression */: + return elaborateObjectLiteral(node, source, target); + case 185 /* ArrayLiteralExpression */: + return elaborateArrayLiteral(node, source, target); + case 266 /* JsxAttributes */: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator, source, target) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + var resultObj = {}; + // Use the expression type, if available + var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + getIndexInfoOfType(target, 0 /* String */) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3 /*break*/, 3]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2 /*return*/]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3 /*break*/, 4]; + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3 /*break*/, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3 /*break*/, 3]; + nameType = getLiteralType(i); + return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3 /*break*/, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 32768 /* Never */)) { + return [3 /*break*/, 7]; + } + _b = prop.kind; + switch (_b) { + case 157 /* SetAccessor */: return [3 /*break*/, 2]; + case 156 /* GetAccessor */: return [3 /*break*/, 2]; + case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + } + return [3 /*break*/, 6]; + case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3 /*break*/, 7]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3 /*break*/, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** * This is *not* a bi-directional relationship. @@ -38337,13 +38646,20 @@ var ts; if (source === target) { return -1 /* True */; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0 /* False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0 /* False */; + } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; @@ -38364,14 +38680,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -38390,7 +38703,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0 /* False */; } @@ -38465,30 +38778,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - // If both have rest parameters, get the max and add 1 to - // compensate for the rest parameter. - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - // Return the count for whichever signature doesn't have rest parameters. - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -38509,11 +38798,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { + return relation === 1 /* Succeeded */; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, false); + enumRelation.set(id, 3 /* FailedAndReported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -38524,13 +38813,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); + enumRelation.set(id, 3 /* FailedAndReported */); + } + else { + enumRelation.set(id, 2 /* Failed */); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1 /* Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -38621,7 +38913,7 @@ var ts; * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -38651,12 +38943,16 @@ var ts; var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); // Cause the error to appear with the error that triggered it + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); // Cause the error to appear with the error that triggered it } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); // TODO: GH#18217 + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { @@ -38738,6 +39034,22 @@ var ts; if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); + if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + target = nullStrippedTarget; + } + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; @@ -38989,11 +39301,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } return 0 /* False */; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072 /* Object */) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4 /* Reference */) { + return source.target === target.target; + } + if (overlapObjFlags & 16 /* Anonymous */) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { var match; @@ -39125,9 +39455,8 @@ var ts; 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.set(id, 3 /* FailedAndReported */); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -39414,7 +39743,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -39437,6 +39766,33 @@ var ts; } } var result = -1 /* True */; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0 /* False */; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0 /* False */; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0 /* False */; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -39958,20 +40314,26 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); // A source signature matches a target signature if the two signatures have the same number of required, // optional, and rest parameters. - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } // A source signature partially matches a target signature if the target signature has no fewer required // parameters and no more overall parameters than the source signature (where a signature with a rest // parameter is always considered to have more overall parameters than one without). - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -40013,10 +40375,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0 /* False */; @@ -40036,9 +40398,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -40088,7 +40447,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); @@ -40135,6 +40499,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -40194,7 +40564,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -40407,7 +40777,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -40417,23 +40787,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 177 /* MappedType */: + case 179 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -40450,24 +40820,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -40606,10 +40974,14 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - // Two tuple types with different arity are definitely unrelated. + // Two tuple types with incompatible arities are definitely unrelated. // Two object types that each have a property that is unmatched in the other are definitely unrelated. - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) && !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false); } function getTypeFromInference(inference) { @@ -40892,12 +41264,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -41012,17 +41405,14 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + // If we have contravariant inferences we find the best common subtype and treat + // that as a single covariant candidate. + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { inferredType = getCovariantInference(inference, context, signature); - // If we have inferred 'never' but have contravariant candidates. To get a more specific type we - // infer from the contravariant candidates instead. - if (inferredType.flags & 32768 /* Never */ && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - // We only have contravariant inferences, infer the best common subtype of those - inferredType = getContravariantInference(inference); } else if (context.flags & 2 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -41099,13 +41489,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 185 /* PropertyAccessExpression */) { + if (node.kind === 187 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182 /* BindingElement */) { + if (node.kind === 184 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -41114,7 +41504,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180 /* ObjectBindingPattern */) { + if (parent.kind === 182 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: @@ -41137,26 +41527,26 @@ var ts; switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && + (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 185 /* PropertyAccessExpression */: - return target.kind === 185 /* PropertyAccessExpression */ && + case 187 /* PropertyAccessExpression */: + return target.kind === 187 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182 /* BindingElement */: - if (target.kind !== 185 /* PropertyAccessExpression */) + case 184 /* BindingElement */: + if (target.kind !== 187 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232 /* VariableDeclaration */) { + if (source.parent.parent.kind === 235 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -41164,7 +41554,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185 /* PropertyAccessExpression */) { + while (source.kind === 187 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -41177,7 +41567,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 === 185 /* PropertyAccessExpression */ && + return target.kind === 187 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -41185,7 +41575,7 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185 /* PropertyAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -41229,7 +41619,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -41355,7 +41745,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; } @@ -41363,15 +41753,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -41388,21 +41778,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return stringType; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return undefinedType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -41410,7 +41800,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 /* ObjectBindingPattern */ ? + var type = pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -41428,35 +41818,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221 /* ForInStatement */) { + if (node.parent.parent.kind === 224 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.parent.kind === 225 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 /* VariableDeclaration */ ? + return node.kind === 235 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? + return node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 /* VariableDeclaration */ && node.initializer && + return node.kind === 235 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && + node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -41468,13 +41858,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 191 /* ParenthesizedExpression */ || - parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 193 /* ParenthesizedExpression */ || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -41637,11 +42027,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 185 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 187 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 186 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 200 /* BinaryExpression */ && + parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -41689,7 +42079,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 = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -41760,7 +42150,7 @@ var ts; else if (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 !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 187 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -41816,7 +42206,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 /* CallExpression */ ? + var expr = node.kind === 189 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -41824,7 +42214,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -41989,7 +42379,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 /* PropertyAccessExpression */ && + return expr.kind === 187 /* PropertyAccessExpression */ && computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -42040,10 +42430,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 === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -42258,7 +42648,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -42278,15 +42668,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -42322,8 +42712,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 /* ModuleBlock */ || - node.kind === 274 /* SourceFile */ || + node.kind === 243 /* ModuleBlock */ || + node.kind === 277 /* SourceFile */ || node.kind === 152 /* PropertyDeclaration */; }); } @@ -42369,10 +42759,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 185 /* PropertyAccessExpression */ || - parent.kind === 187 /* CallExpression */ && parent.expression === node || - parent.kind === 186 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 182 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 187 /* PropertyAccessExpression */ || + parent.kind === 189 /* CallExpression */ && parent.expression === node || + parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); @@ -42406,7 +42796,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 */)) { @@ -42427,7 +42817,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.kind === 235 /* ClassDeclaration */ + if (declaration.kind === 238 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -42439,12 +42829,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205 /* ClassExpression */) { + else if (declaration.kind === 207 /* 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.kind !== 274 /* SourceFile */) { + while (container.kind !== 277 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; @@ -42494,23 +42884,23 @@ var ts; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - var isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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 === 192 /* FunctionExpression */ || - flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 /* FunctionExpression */ || + flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). - var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 252 /* ExportSpecifier */) || - node.parent.kind === 209 /* NonNullExpression */ || - declaration.kind === 232 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || + node.parent.kind === 211 /* NonNullExpression */ || + declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -42541,7 +42931,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -42566,8 +42956,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 === 220 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && + if (container.kind === 223 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -42581,7 +42971,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 191 /* ParenthesizedExpression */) { + while (current.parent.kind === 193 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -42589,7 +42979,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -42647,7 +43037,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); // If a containing class does not have extends clause or the class extends null // skip checking whether super statement is called before "this" accessing. if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -42674,17 +43064,17 @@ var ts; 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 === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 238 /* EnumDeclaration */: + case 241 /* 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; @@ -42722,8 +43112,8 @@ 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 === 192 /* FunctionExpression */ && - container.parent.kind === 200 /* BinaryExpression */ && + if (container.kind === 194 /* FunctionExpression */ && + container.parent.kind === 202 /* BinaryExpression */ && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.prototype.y = f @@ -42754,7 +43144,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -42771,12 +43161,12 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 /* 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 === 193 /* ArrowFunction */) { + while (container && container.kind === 195 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -42796,7 +43186,7 @@ var ts; 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 === 184 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -42884,7 +43274,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184 /* ObjectLiteralExpression */) { + if (container.parent.kind === 186 /* 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 errorType; @@ -42896,7 +43286,7 @@ var ts; } // at this point the only legal case for parent is ClassLikeDeclaration var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -42928,7 +43318,7 @@ 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 === 184 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 154 /* MethodDeclaration */ || container.kind === 153 /* MethodSignature */ || @@ -42952,8 +43342,8 @@ var ts; function getContainingObjectLiteral(func) { return (func.kind === 154 /* MethodDeclaration */ || func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 184 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 192 /* FunctionExpression */ && func.parent.kind === 270 /* PropertyAssignment */ ? func.parent.parent : + func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -42965,7 +43355,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193 /* ArrowFunction */) { + if (func.kind === 195 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -42992,7 +43382,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270 /* PropertyAssignment */) { + if (literal.parent.kind !== 273 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -43006,9 +43396,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { + if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -43031,27 +43421,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. @@ -43061,10 +43448,8 @@ var ts; return getTypeAtPosition(contextualSignature, indexOfParameter); } // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -43095,7 +43480,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182 /* BindingElement */) { + if (parentDeclaration.kind !== 184 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -43177,7 +43562,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189 /* TaggedTemplateExpression */) { + if (template.parent.kind === 191 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -43225,8 +43610,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504 /* StructuredType */) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, /*noReductions*/ true); } function getIndexTypeOfContextualType(type, kind) { @@ -43255,8 +43651,8 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -43322,8 +43718,8 @@ var ts; case 95 /* NullKeyword */: case 71 /* Identifier */: return true; - case 185 /* PropertyAccessExpression */: - case 191 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 193 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -43342,14 +43738,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270 /* PropertyAssignment */) + if (prop.kind !== 273 /* PropertyAssignment */) continue; if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine @@ -43390,52 +43786,52 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 193 /* ArrowFunction */: - case 225 /* ReturnStatement */: + case 195 /* ArrowFunction */: + case 228 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 183 /* ArrayLiteralExpression */: { + case 185 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 211 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); + case 214 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -43509,6 +43905,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -43519,8 +43916,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) @@ -43536,7 +43949,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -43581,11 +43995,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; + return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -43657,18 +44070,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 182 /* BindingElement */ && !!node.initializer) || - (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 184 /* BindingElement */ && !!node.initializer) || + (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -43693,13 +44107,17 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; + if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } @@ -43707,28 +44125,30 @@ 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 === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - if (patternElement.kind !== 206 /* OmittedExpression */) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { + if (e.kind !== 208 /* OmittedExpression */) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2 /* Subtype */); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2 /* Subtype */) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -43813,7 +44233,7 @@ var ts; var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -43827,11 +44247,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 /* PropertyAssignment */ || - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 273 /* PropertyAssignment */ || + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -43852,8 +44272,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -43878,7 +44298,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272 /* SpreadAssignment */) { + else if (memberDecl.kind === 275 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -43972,13 +44392,16 @@ var ts; type.flags & 131072 /* Object */ && !isGenericMappedType(type) || type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { + function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -43986,6 +44409,9 @@ var ts; else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -44008,16 +44434,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - // TODO (yuisu): comment - switch (tagName.kind) { - case 185 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: - return false; - case 71 /* Identifier */: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -44060,7 +44477,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -44083,7 +44500,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 255 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -44244,12 +44661,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -44286,6 +44715,10 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928 /* Type */); + } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -44692,7 +45125,7 @@ var ts; // 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, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. @@ -44713,31 +45146,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -44784,9 +45193,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? + var errorNode = node.kind === 187 /* PropertyAccessExpression */ || node.kind === 235 /* VariableDeclaration */ ? node.name : - node.kind === 179 /* ImportType */ ? + node.kind === 181 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -44956,7 +45365,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 !== 185 /* PropertyAccessExpression */ || + if (node.kind !== 187 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; @@ -44988,16 +45397,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && node.parent.kind !== 162 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -45005,7 +45419,7 @@ var ts; switch (node.kind) { case 152 /* PropertyDeclaration */: return true; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -45061,13 +45475,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319 /* Value */); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319 /* Value */); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -45126,16 +45546,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179 /* ImportType */: + case 181 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -45169,7 +45589,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer.kind === 236 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -45198,7 +45618,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 /* ForInStatement */ && + if (node.kind === 224 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -45216,7 +45636,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 190 /* 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); @@ -45283,7 +45703,7 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (node.kind !== 150 /* Decorator */) { @@ -45349,14 +45769,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204 /* SpreadElement */) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -45368,12 +45785,12 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { // 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 = node.typeArguments; - if (node.template.kind === 202 /* TemplateExpression */) { + if (node.template.kind === 204 /* 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 lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -45395,8 +45812,8 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 188 /* NewExpression */); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190 /* NewExpression */); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. @@ -45409,15 +45826,14 @@ var ts; } // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -45442,9 +45858,10 @@ var ts; // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1 /* InferUnionTypes */, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8 /* ReturnType */); @@ -45494,7 +45911,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -45509,11 +45926,13 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; 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 !== 206 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -45527,6 +45946,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) @@ -45544,6 +45967,35 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + // We are inferring from a spread expression in the last argument position, i.e. both the parameter + // and the argument are ...x forms. + return arg.kind === 213 /* SyntheticExpression */ ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -45603,7 +46055,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 190 /* 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. @@ -45617,24 +46069,32 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; 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 !== 206 /* OmittedExpression */) { - // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) - var paramType = getTypeAtPosition(signature, i); - // If the effective argument type is undefined, there is no synthetic type for the argument. - // In that case, we should check the argument. - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { + if (i === restIndex && (restType.flags & 65536 /* TypeParameter */ || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, /*context*/ undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) + var paramType = getTypeAtPosition(signature, i); + // If the effective argument type is undefined, there is no synthetic type for the argument. + // In that case, we should check the argument. + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } @@ -45644,9 +46104,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { + if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { return callee.expression; } } @@ -45661,10 +46121,10 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [undefined]; // TODO: GH#18217 - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -45681,7 +46141,28 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + // We have a spread argument in the last position and no other spread arguments. If the type + // of the argument is a tuple type, spread the tuple elements into the argument list. We can + // call checkExpressionCached because spread expressions never have a contextual type. + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213 /* SyntheticExpression */, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } /** @@ -45700,8 +46181,8 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; case 152 /* PropertyDeclaration */: @@ -45746,7 +46227,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* 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); @@ -45791,7 +46272,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -45846,7 +46327,7 @@ 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 === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -45895,7 +46376,7 @@ var ts; if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -45908,7 +46389,7 @@ 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 === 150 /* Decorator */ || - (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { + (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -45921,7 +46402,7 @@ var ts; // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -45941,7 +46422,7 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 189 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -46016,7 +46497,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 === 187 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 /* 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 @@ -46063,10 +46544,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -46181,11 +46662,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -46201,7 +46683,7 @@ var ts; if (superType !== errorType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -46380,8 +46862,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -46407,8 +46888,8 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -46484,16 +46965,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -46569,7 +47050,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -46583,7 +47065,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185 /* PropertyAccessExpression */) { + while (parent && parent.kind === 187 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -46615,7 +47097,7 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 188 /* NewExpression */) { + if (node.kind === 190 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 /* Constructor */ && @@ -46689,7 +47171,7 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -46746,9 +47228,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 234 /* FunctionDeclaration */ + ? 237 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 232 /* VariableDeclaration */ + ? 235 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -46826,10 +47308,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1 /* Number */) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536 /* TypeParameter */) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -46868,11 +47447,11 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -46937,7 +47516,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213 /* Block */) { + if (func.body.kind !== 216 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -47026,7 +47605,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -47051,7 +47630,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -47094,11 +47673,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; case 154 /* MethodDeclaration */: - return func.parent.kind === 184 /* ObjectLiteralExpression */; + return func.parent.kind === 186 /* ObjectLiteralExpression */; default: return false; } @@ -47122,7 +47701,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 (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -47162,7 +47741,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -47223,7 +47802,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213 /* Block */) { + if (node.body.kind === 216 /* Block */) { checkSourceElement(node.body); } else { @@ -47236,10 +47815,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -47269,7 +47848,7 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && + (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); @@ -47286,13 +47865,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 246 /* NamespaceImport */; + return !!declaration && declaration.kind === 249 /* NamespaceImport */; } } } @@ -47301,7 +47880,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -47310,7 +47889,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { + if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -47487,7 +48066,7 @@ 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 === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { var name = property.name; if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); @@ -47502,7 +48081,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 274 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -47514,7 +48093,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 272 /* SpreadAssignment */) { + else if (property.kind === 275 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -47549,27 +48128,23 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206 /* OmittedExpression */) { - if (element.kind !== 204 /* SpreadElement */) { + if (element.kind !== 208 /* OmittedExpression */) { + if (element.kind !== 206 /* SpreadElement */) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - // We still need to check element expression here because we may need to set appropriate flag on the expression - // such as NodeCheckFlags.LexicalThis on "this"expression. - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -47578,12 +48153,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -47592,7 +48170,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -47608,25 +48186,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184 /* ObjectLiteralExpression */) { + if (target.kind === 186 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183 /* ArrayLiteralExpression */) { + if (target.kind === 185 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 272 /* SpreadAssignment */ ? + var error = target.parent.kind === 275 /* 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)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -47644,35 +48222,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 189 /* TaggedTemplateExpression */: - case 202 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: - case 193 /* ArrowFunction */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 195 /* TypeOfExpression */: - case 209 /* NonNullExpression */: - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 197 /* TypeOfExpression */: + case 211 /* NonNullExpression */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: return true; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -47684,9 +48262,9 @@ var ts; } return false; // Some forms listed here for clarity - case 196 /* VoidExpression */: // Explicit opt-out - case 190 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 208 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 198 /* VoidExpression */: // Explicit opt-out + case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -47702,7 +48280,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -47901,7 +48479,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -47922,7 +48500,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34 /* EqualsEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -47979,7 +48573,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' return anyType; @@ -48004,7 +48598,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263 /* JsxAttributes */) { + if (node.kind === 266 /* JsxAttributes */) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -48040,7 +48634,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; + return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -48142,7 +48736,7 @@ var ts; function getTypeOfExpression(node, cache) { // 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 === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -48192,8 +48786,8 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { @@ -48229,74 +48823,76 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checkCallExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return checkClassExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return checkAssertion(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return checkNonNullAssertion(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return checkMetaProperty(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkDeleteExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return checkVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return checkAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return undefinedWideningType; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return checkYieldExpression(node); - case 265 /* JsxExpression */: + case 213 /* SyntheticExpression */: + return node.type; + case 268 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return checkJsxElement(node, checkMode); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -48325,6 +48921,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 /* Instantiable */ && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -48351,7 +48950,7 @@ var ts; } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -48412,10 +49011,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 158 /* CallSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 163 /* FunctionType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -48436,7 +49035,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { + else if (name.kind === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -48449,7 +49048,7 @@ var ts; checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + else if (node.kind === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -48514,7 +49113,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -48643,7 +49242,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* 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 @@ -48731,7 +49330,7 @@ var ts; // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -48753,7 +49352,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -48904,11 +49503,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170 /* RestType */) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169 /* OptionalType */) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -48922,7 +49538,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 186 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -48959,7 +49575,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -48975,9 +49591,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 !== 236 /* InterfaceDeclaration */ && - n.parent.kind !== 235 /* ClassDeclaration */ && - n.parent.kind !== 205 /* ClassExpression */ && + if (n.parent.kind !== 239 /* InterfaceDeclaration */ && + n.parent.kind !== 238 /* ClassDeclaration */ && + n.parent.kind !== 207 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported @@ -49107,7 +49723,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -49118,7 +49734,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 === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -49247,22 +49863,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -49270,17 +49886,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 234 /* FunctionDeclaration */: - case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 237 /* FunctionDeclaration */: + case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -49551,7 +50167,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -49614,12 +50230,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -49651,7 +50267,7 @@ var ts; } } return commonEntityName; - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); case 162 /* TypeReference */: return node.typeName; @@ -49684,7 +50300,7 @@ var ts; 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -49773,7 +50389,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -49785,7 +50401,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -49868,27 +50484,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274 /* SourceFile */: - case 239 /* ModuleDeclaration */: - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 242 /* ModuleDeclaration */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -49902,7 +50518,7 @@ var ts; case 159 /* ConstructSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -49915,10 +50531,7 @@ var ts; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -49948,7 +50561,7 @@ var ts; } break; case 160 /* IndexSignature */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: // Can't be private break; default: @@ -49964,7 +50577,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -49999,7 +50612,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -50017,9 +50630,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -50034,7 +50647,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0 /* Local */, unuseds.length === 1 @@ -50052,7 +50665,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -50073,7 +50686,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -50087,22 +50700,22 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; + return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 213 /* Block */) { + if (node.kind === 216 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -50197,7 +50810,7 @@ var ts; } // 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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 /* 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)); } @@ -50212,7 +50825,7 @@ var ts; } // 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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 277 /* 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)); } @@ -50247,7 +50860,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 === 232 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -50259,17 +50872,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 214 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 217 /* 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 === 213 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 240 /* ModuleBlock */ || - container.kind === 239 /* ModuleDeclaration */ || - container.kind === 274 /* SourceFile */); + (container.kind === 216 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 243 /* ModuleBlock */ || + container.kind === 242 /* ModuleDeclaration */ || + container.kind === 277 /* 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 @@ -50295,7 +50908,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 185 /* PropertyAccessExpression */) { + if (n.kind === 187 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -50315,7 +50928,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 182 /* BindingElement */) { + symbol.valueDeclaration.kind === 184 /* 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) { @@ -50368,8 +50981,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182 /* BindingElement */) { - if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 184 /* BindingElement */) { + if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -50390,7 +51003,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -50403,13 +51016,13 @@ var ts; // 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 !== 221 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -50426,8 +51039,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221 /* ForInStatement */) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -50442,7 +51055,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -50452,7 +51065,7 @@ var ts; if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -50467,8 +51080,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || - (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || + (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -50507,7 +51120,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215 /* EmptyStatement */) { + if (node.thenStatement.kind === 218 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -50527,12 +51140,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -50566,14 +51179,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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. @@ -50587,7 +51200,7 @@ var ts; // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -50605,7 +51218,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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); @@ -50619,7 +51232,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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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)) { @@ -50983,7 +51596,7 @@ var ts; } } else if (func.kind === 155 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -50999,7 +51612,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -51032,7 +51645,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 === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -51044,7 +51657,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -51073,7 +51686,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -51171,16 +51784,17 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } // perform property check if property or indexer is declared in 'type' // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || + if (propDeclaration && name && + (propDeclaration.kind === 202 /* BinaryExpression */ || + name.kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -51354,7 +51968,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); @@ -51366,6 +51980,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -51432,7 +52050,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -51451,7 +52069,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -51477,7 +52095,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; + return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -51516,7 +52134,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.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 205 /* ClassExpression */) { + if (derivedClassDecl.kind === 207 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -51630,7 +52248,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -51693,7 +52311,7 @@ var ts; } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -51708,7 +52326,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -51735,7 +52353,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -51745,7 +52363,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -51773,7 +52391,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: var identifier = expr; @@ -51781,14 +52399,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 185 /* PropertyAccessExpression */) { + if (ex.kind === 187 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -51820,8 +52438,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -51835,7 +52453,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304 /* Ambient */) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -51851,7 +52469,7 @@ var ts; if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -51859,7 +52477,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 !== 238 /* EnumDeclaration */) { + if (declaration.kind !== 241 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -51882,8 +52500,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 235 /* ClassDeclaration */ || - (declaration.kind === 234 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 238 /* ClassDeclaration */ || + (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -51946,7 +52564,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, 235 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -51996,23 +52614,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* 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 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -52023,12 +52641,12 @@ var ts; break; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 234 /* FunctionDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -52056,7 +52674,7 @@ var ts; node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -52073,9 +52691,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 250 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -52108,14 +52726,14 @@ var ts; (symbol.flags & 67901928 /* Type */ ? 67901928 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 252 /* ExportSpecifier */ ? + var message = node.kind === 255 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 252 /* ExportSpecifier */ + && node.kind === 255 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -52142,7 +52760,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -52166,7 +52784,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -52202,10 +52820,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -52222,7 +52840,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -52251,8 +52869,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -52340,7 +52958,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -52358,10 +52976,10 @@ 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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -52399,111 +53017,113 @@ var ts; return checkArrayType(node); case 168 /* TupleType */: return checkTupleType(node); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: + case 169 /* OptionalType */: + case 170 /* RestType */: return checkSourceElement(node.type); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return checkTypeOperator(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return checkConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return checkInferType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return checkImportType(node); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 282 /* JSDocNonNullableType */: - case 281 /* JSDocNullableType */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: - case 287 /* JSDocTypeLiteral */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: + case 290 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 278 /* JSDocTypeExpression */: + case 281 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return checkMappedType(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return checkBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return checkVariableStatement(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return checkExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return checkIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return checkDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return checkWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return checkForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return checkForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkForOfStatement(node); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return checkReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return checkSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return checkLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return checkThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return checkTryStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return checkBindingElement(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return checkClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return checkImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return checkExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return checkExportAssignment(node); - case 215 /* EmptyStatement */: - case 231 /* DebuggerStatement */: + case 218 /* EmptyStatement */: + case 234 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -52580,15 +53200,15 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -52597,11 +53217,17 @@ var ts; case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: checkClassExpressionDeferred(node); break; + case 259 /* JsxSelfClosingElement */: + checkJsxSelfClosingElementDeferred(node); + break; + case 258 /* JsxElement */: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -52636,7 +53262,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -52730,13 +53356,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -52744,8 +53370,8 @@ var ts; // falls 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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* 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. @@ -52754,7 +53380,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -52803,10 +53429,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148 /* TypeParameter */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -52820,10 +53446,10 @@ var ts; return node.parent.kind === 162 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185 /* PropertyAccessExpression */) { + while (node.parent.kind === 187 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 207 /* ExpressionWithTypeArguments */; + return node.parent.kind === 209 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -52854,10 +53480,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -52883,7 +53509,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -52893,7 +53519,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 /* PropertyAccessExpression */ && + entityName.parent.kind === 187 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -52901,7 +53527,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -52911,7 +53537,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 243 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -52929,7 +53555,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 === 207 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -52945,10 +53571,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293 /* JSDocParameterTag */) { + if (entityName.parent.kind === 296 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 297 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 300 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -52965,12 +53591,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185 /* PropertyAccessExpression */) { + if (entityName.kind === 187 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -52983,7 +53609,7 @@ var ts; var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 262 /* JsxAttribute */) { + else if (entityName.parent.kind === 265 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161 /* TypePredicate */) { @@ -52993,7 +53619,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -53013,8 +53639,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 /* BindingElement */ && - grandParent.kind === 180 /* ObjectBindingPattern */ && + else if (parent.kind === 184 /* BindingElement */ && + grandParent.kind === 182 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -53025,7 +53651,7 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: @@ -53040,7 +53666,7 @@ var ts; return checkExpression(node).symbol; } // falls through - case 174 /* ThisType */: + case 176 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; @@ -53058,7 +53684,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -53076,14 +53702,14 @@ var ts; case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -53156,28 +53782,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 222 /* ForOfStatement */) { + if (expr.parent.kind === 225 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 200 /* BinaryExpression */) { + if (expr.parent.kind === 202 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 270 /* PropertyAssignment */) { + if (expr.parent.kind === 273 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -53256,7 +53882,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -53312,7 +53938,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { var symbolFile = parentSymbol_1.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. @@ -53367,7 +53993,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 === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -53408,16 +54034,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -53427,7 +54053,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -53508,22 +54134,23 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273 /* EnumMember */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 276 /* EnumMember */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273 /* EnumMember */) { + if (node.kind === 276 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8 /* EnumMember */)) { // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -53661,7 +54288,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } @@ -53758,7 +54385,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; + return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -53770,7 +54397,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67901928 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -53821,7 +54448,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -53836,12 +54463,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 274 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 277 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -53849,10 +54476,14 @@ var ts; var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); // Initialize global symbol table var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -53926,6 +54557,32 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -54019,7 +54676,7 @@ var ts; } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { + if (node.kind !== 241 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -54039,7 +54696,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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -54062,7 +54719,7 @@ 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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149 /* Parameter */) { @@ -54098,7 +54755,7 @@ 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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149 /* Parameter */) { @@ -54107,8 +54764,8 @@ var ts; flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -54120,13 +54777,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 240 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -54136,14 +54793,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 238 /* ClassDeclaration */) { if (node.kind !== 154 /* MethodDeclaration */ && node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 156 /* GetAccessor */ && node.kind !== 157 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -54185,7 +54842,7 @@ var ts; } return false; } - else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -54220,29 +54877,29 @@ var ts; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 160 /* IndexSignature */: - case 239 /* ModuleDeclaration */: - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 242 /* ModuleDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 149 /* Parameter */: return false; default: - if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return false; } switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 236 /* InterfaceDeclaration */: - case 214 /* VariableStatement */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 217 /* VariableStatement */: + case 240 /* TypeAliasDeclaration */: return true; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -54256,9 +54913,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -54391,7 +55048,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206 /* OmittedExpression */) { + if (arg.kind === 208 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -54472,15 +55129,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 234 /* FunctionDeclaration */ || - node.kind === 192 /* FunctionExpression */ || + ts.Debug.assert(node.kind === 237 /* FunctionDeclaration */ || + node.kind === 194 /* FunctionExpression */ || node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -54504,7 +55161,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 /* SpreadAssignment */) { + if (prop.kind === 275 /* SpreadAssignment */) { continue; } var name = prop.name; @@ -54512,7 +55169,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 /* 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); @@ -54536,8 +55193,8 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -54587,7 +55244,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 264 /* JsxSpreadAttribute */) { + if (attr.kind === 267 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -54597,7 +55254,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -54606,12 +55263,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 233 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -54626,20 +55283,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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); @@ -54708,7 +55365,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 71 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -54746,7 +55403,7 @@ var ts; return true; } if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 184 /* ObjectLiteralExpression */) { + if (node.parent.kind === 186 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -54775,7 +55432,7 @@ var ts; return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (node.parent.kind === 166 /* TypeLiteral */) { @@ -54789,11 +55446,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 223 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 226 /* 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); @@ -54801,8 +55458,8 @@ var ts; return false; } break; - case 227 /* SwitchStatement */: - if (node.kind === 224 /* BreakStatement */ && !node.label) { + case 230 /* SwitchStatement */: + if (node.kind === 227 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -54817,13 +55474,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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 === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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); @@ -54836,7 +55493,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { + if (node.name.kind === 183 /* ArrayBindingPattern */ || node.name.kind === 182 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -54850,14 +55507,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { + if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -54868,7 +55525,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -54878,19 +55535,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -54945,15 +55602,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return false; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -54963,7 +55620,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -55030,7 +55687,7 @@ var ts; return true; } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -55067,13 +55724,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 237 /* TypeAliasDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 243 /* ImportEqualsDeclaration */ || - node.kind === 250 /* ExportDeclaration */ || - node.kind === 249 /* ExportAssignment */ || - node.kind === 242 /* NamespaceExportDeclaration */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 240 /* TypeAliasDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 253 /* ExportDeclaration */ || + node.kind === 252 /* ExportAssignment */ || + node.kind === 245 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -55082,7 +55739,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 === 214 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 217 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -55109,7 +55766,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 === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -55131,10 +55788,10 @@ var ts; 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, 178 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -55189,8 +55846,8 @@ var ts; /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -55198,14 +55855,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245 /* ImportClause */: // For default import - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: // For rename import `x as y` + case 248 /* ImportClause */: // For default import + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: // For rename import `x as y` return true; case 71 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 248 /* ImportSpecifier */; + return decl.parent.kind === 251 /* ImportSpecifier */; default: return false; } @@ -55221,8 +55878,12 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448 /* Literal */); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -55388,7 +56049,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 /* Node */ | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -55481,10 +56142,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 303 /* CommaListExpression */ ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147 /* ComputedPropertyName */); @@ -55847,14 +56507,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169 /* OptionalType */); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170 /* RestType */); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -55862,7 +56546,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -55881,7 +56565,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171 /* ConditionalType */); + var node = createSynthesizedNode(173 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -55899,7 +56583,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172 /* InferType */); + var node = createSynthesizedNode(174 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -55911,7 +56595,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179 /* ImportType */); + var node = createSynthesizedNode(181 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -55929,7 +56613,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173 /* ParenthesizedType */); + var node = createSynthesizedNode(175 /* ParenthesizedType */); node.type = type; return node; } @@ -55941,11 +56625,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174 /* ThisType */); + return createSynthesizedNode(176 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175 /* TypeOperator */); + var node = createSynthesizedNode(177 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -55956,7 +56640,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176 /* IndexedAccessType */); + var node = createSynthesizedNode(178 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -55970,7 +56654,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177 /* MappedType */); + var node = createSynthesizedNode(179 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -55988,7 +56672,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178 /* LiteralType */); + var node = createSynthesizedNode(180 /* LiteralType */); node.literal = literal; return node; } @@ -56001,7 +56685,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ObjectBindingPattern */); + var node = createSynthesizedNode(182 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56013,7 +56697,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181 /* ArrayBindingPattern */); + var node = createSynthesizedNode(183 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56025,7 +56709,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182 /* BindingElement */); + var node = createSynthesizedNode(184 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -56044,7 +56728,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -56058,7 +56742,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -56072,7 +56756,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185 /* PropertyAccessExpression */); + var node = createSynthesizedNode(187 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -56089,7 +56773,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186 /* ElementAccessExpression */); + var node = createSynthesizedNode(188 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -56103,7 +56787,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* CallExpression */); + var node = createSynthesizedNode(189 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -56119,7 +56803,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188 /* NewExpression */); + var node = createSynthesizedNode(190 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -56135,7 +56819,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -56158,7 +56842,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190 /* TypeAssertionExpression */); + var node = createSynthesizedNode(192 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -56172,7 +56856,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191 /* ParenthesizedExpression */); + var node = createSynthesizedNode(193 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -56184,7 +56868,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192 /* FunctionExpression */); + var node = createSynthesizedNode(194 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -56208,7 +56892,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193 /* ArrowFunction */); + var node = createSynthesizedNode(195 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -56242,7 +56926,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194 /* DeleteExpression */); + var node = createSynthesizedNode(196 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56254,7 +56938,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195 /* TypeOfExpression */); + var node = createSynthesizedNode(197 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56266,7 +56950,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196 /* VoidExpression */); + var node = createSynthesizedNode(198 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56278,7 +56962,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197 /* AwaitExpression */); + var node = createSynthesizedNode(199 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56290,7 +56974,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -56303,7 +56987,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -56316,7 +57000,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200 /* BinaryExpression */); + var node = createSynthesizedNode(202 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -56333,7 +57017,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201 /* ConditionalExpression */); + var node = createSynthesizedNode(203 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -56363,7 +57047,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202 /* TemplateExpression */); + var node = createSynthesizedNode(204 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -56401,7 +57085,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203 /* YieldExpression */); + var node = createSynthesizedNode(205 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -56415,7 +57099,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204 /* SpreadElement */); + var node = createSynthesizedNode(206 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -56427,7 +57111,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205 /* ClassExpression */); + var node = createSynthesizedNode(207 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56448,11 +57132,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206 /* OmittedExpression */); + return createSynthesizedNode(208 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -56466,7 +57150,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208 /* AsExpression */); + var node = createSynthesizedNode(210 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -56480,7 +57164,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209 /* NonNullExpression */); + var node = createSynthesizedNode(211 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -56492,7 +57176,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210 /* MetaProperty */); + var node = createSynthesizedNode(212 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -56506,7 +57190,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211 /* TemplateSpan */); + var node = createSynthesizedNode(214 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -56520,25 +57204,18 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212 /* SemicolonClassElement */); + return createSynthesizedNode(215 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213 /* Block */); + var block = createSynthesizedNode(216 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - /* @internal */ - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216 /* ExpressionStatement */); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -56546,7 +57223,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214 /* VariableStatement */); + var node = createSynthesizedNode(217 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -56561,21 +57238,27 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215 /* EmptyStatement */); + return createSynthesizedNode(218 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + ts.createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217 /* IfStatement */); + var node = createSynthesizedNode(220 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -56591,7 +57274,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218 /* DoStatement */); + var node = createSynthesizedNode(221 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -56605,7 +57288,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219 /* WhileStatement */); + var node = createSynthesizedNode(222 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -56619,7 +57302,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220 /* ForStatement */); + var node = createSynthesizedNode(223 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -56637,7 +57320,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForInStatement */); + var node = createSynthesizedNode(224 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -56653,7 +57336,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222 /* ForOfStatement */); + var node = createSynthesizedNode(225 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -56671,7 +57354,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223 /* ContinueStatement */); + var node = createSynthesizedNode(226 /* ContinueStatement */); node.label = asName(label); return node; } @@ -56683,7 +57366,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224 /* BreakStatement */); + var node = createSynthesizedNode(227 /* BreakStatement */); node.label = asName(label); return node; } @@ -56695,7 +57378,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225 /* ReturnStatement */); + var node = createSynthesizedNode(228 /* ReturnStatement */); node.expression = expression; return node; } @@ -56707,7 +57390,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226 /* WithStatement */); + var node = createSynthesizedNode(229 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -56721,7 +57404,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227 /* SwitchStatement */); + var node = createSynthesizedNode(230 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -56735,7 +57418,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228 /* LabeledStatement */); + var node = createSynthesizedNode(231 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -56749,7 +57432,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229 /* ThrowStatement */); + var node = createSynthesizedNode(232 /* ThrowStatement */); node.expression = expression; return node; } @@ -56761,7 +57444,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230 /* TryStatement */); + var node = createSynthesizedNode(233 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -56777,11 +57460,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231 /* DebuggerStatement */); + return createSynthesizedNode(234 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232 /* VariableDeclaration */); + var node = createSynthesizedNode(235 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -56798,7 +57481,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(233 /* VariableDeclarationList */); + var node = createSynthesizedNode(236 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -56811,7 +57494,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234 /* FunctionDeclaration */); + var node = createSynthesizedNode(237 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -56837,7 +57520,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* ClassDeclaration */); + var node = createSynthesizedNode(238 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56859,7 +57542,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236 /* InterfaceDeclaration */); + var node = createSynthesizedNode(239 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56881,7 +57564,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56901,7 +57584,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238 /* EnumDeclaration */); + var node = createSynthesizedNode(241 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56920,7 +57603,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* ModuleDeclaration */); + var node = createSynthesizedNode(242 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -56939,7 +57622,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240 /* ModuleBlock */); + var node = createSynthesizedNode(243 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -56951,7 +57634,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241 /* CaseBlock */); + var node = createSynthesizedNode(244 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -56963,7 +57646,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -56975,7 +57658,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56993,7 +57676,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244 /* ImportDeclaration */); + var node = createSynthesizedNode(247 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -57011,7 +57694,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245 /* ImportClause */); + var node = createSynthesizedNode(248 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -57025,7 +57708,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246 /* NamespaceImport */); + var node = createSynthesizedNode(249 /* NamespaceImport */); node.name = name; return node; } @@ -57037,7 +57720,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247 /* NamedImports */); + var node = createSynthesizedNode(250 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -57049,7 +57732,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248 /* ImportSpecifier */); + var node = createSynthesizedNode(251 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -57063,7 +57746,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249 /* ExportAssignment */); + var node = createSynthesizedNode(252 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -57080,7 +57763,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ExportDeclaration */); + var node = createSynthesizedNode(253 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -57098,7 +57781,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251 /* NamedExports */); + var node = createSynthesizedNode(254 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -57110,7 +57793,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252 /* ExportSpecifier */); + var node = createSynthesizedNode(255 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -57125,7 +57808,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254 /* ExternalModuleReference */); + var node = createSynthesizedNode(257 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -57138,7 +57821,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255 /* JsxElement */); + var node = createSynthesizedNode(258 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -57154,7 +57837,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57170,7 +57853,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257 /* JsxOpeningElement */); + var node = createSynthesizedNode(260 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57186,7 +57869,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258 /* JsxClosingElement */); + var node = createSynthesizedNode(261 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -57198,7 +57881,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259 /* JsxFragment */); + var node = createSynthesizedNode(262 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -57214,7 +57897,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262 /* JsxAttribute */); + var node = createSynthesizedNode(265 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -57228,7 +57911,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263 /* JsxAttributes */); + var node = createSynthesizedNode(266 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -57240,7 +57923,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -57252,7 +57935,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265 /* JsxExpression */); + var node = createSynthesizedNode(268 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -57266,7 +57949,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266 /* CaseClause */); + var node = createSynthesizedNode(269 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -57280,7 +57963,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267 /* DefaultClause */); + var node = createSynthesizedNode(270 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -57292,7 +57975,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268 /* HeritageClause */); + var node = createSynthesizedNode(271 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -57305,7 +57988,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269 /* CatchClause */); + var node = createSynthesizedNode(272 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -57320,7 +58003,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270 /* PropertyAssignment */); + var node = createSynthesizedNode(273 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -57335,7 +58018,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -57349,7 +58032,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272 /* SpreadAssignment */); + var node = createSynthesizedNode(275 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -57362,7 +58045,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273 /* EnumMember */); + var node = createSynthesizedNode(276 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -57383,7 +58066,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274 /* SourceFile */); + var updated = createSynthesizedNode(277 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -57467,7 +58150,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301 /* NotEmittedStatement */); + var node = createSynthesizedNode(304 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -57479,7 +58162,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(308 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57491,7 +58174,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(307 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57506,7 +58189,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(302 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(305 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -57522,7 +58205,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 303 /* CommaListExpression */) { + if (node.kind === 306 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -57532,7 +58215,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303 /* CommaListExpression */); + var node = createSynthesizedNode(306 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -57545,14 +58228,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275 /* Bundle */); + var node = ts.createNode(278 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276 /* UnparsedSource */); + var node = ts.createNode(279 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -57560,7 +58243,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277 /* InputFiles */); + var node = ts.createNode(280 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -57703,7 +58386,7 @@ var ts; // 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 === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -58214,7 +58897,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -58232,13 +58915,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -58265,7 +58948,7 @@ var ts; } else { switch (callee.kind) { - case 185 /* PropertyAccessExpression */: { + case 187 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58278,7 +58961,7 @@ var ts; } break; } - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58338,9 +59021,9 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -58665,7 +59348,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 191 /* ParenthesizedExpression */) { + if (skipped.kind === 193 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -58699,8 +59382,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(200 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -58709,7 +59392,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 203 /* YieldExpression */) { + && operand.kind === 205 /* YieldExpression */) { return false; } return true; @@ -58797,7 +59480,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -58812,7 +59495,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -58826,8 +59509,7 @@ var ts; // 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 var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 303 /* CommaListExpression */ + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } @@ -58845,10 +59527,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 /* ClassExpression */ || - check.kind === 192 /* FunctionExpression */ || - check.kind === 303 /* CommaListExpression */ || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) + return check.kind === 207 /* ClassExpression */ || + check.kind === 194 /* FunctionExpression */ || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -58862,9 +59543,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.createParen(expression); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -58887,7 +59568,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -58925,7 +59606,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -58936,27 +59617,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { + if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { + if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: return ts.createParenthesizedType(member); @@ -58967,8 +59648,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 172 /* InferType */: + case 177 /* TypeOperator */: + case 174 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -58994,25 +59675,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: node = node.operand; continue; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: node = node.left; continue; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: node = node.condition; continue; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: - node = node.expression; - continue; - case 302 /* PartiallyEmittedExpression */: + case 210 /* AsExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 211 /* NonNullExpression */: + case 305 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -59020,12 +59701,17 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || + node.kind === 306 /* CommaListExpression */; + } + ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; @@ -59036,13 +59722,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 209 /* NonNullExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 211 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -59067,7 +59753,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { node = node.expression; } return node; @@ -59075,11 +59761,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 191 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 208 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 209 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 302 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -59097,7 +59783,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 191 /* ParenthesizedExpression */ + return node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -59162,10 +59848,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -59284,7 +59970,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -59296,11 +59982,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -59333,11 +60019,11 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 204 /* SpreadElement */: - case 272 /* SpreadAssignment */: + case 206 /* SpreadElement */: + case 275 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -59349,7 +60035,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -59361,7 +60047,7 @@ var ts; : propertyName; } break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -59373,7 +60059,7 @@ var ts; : propertyName; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -59391,13 +60077,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -59437,11 +60123,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -59565,7 +60251,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -59602,7 +60288,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { return node; } switch (kind) { @@ -59657,217 +60343,221 @@ var ts; case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168 /* TupleType */: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* UnionType */: + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 169 /* OptionalType */: + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* RestType */: + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 172 /* InferType */: + case 174 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177 /* MappedType */: + case 179 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 213 /* Block */: + case 216 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 216 /* ExpressionStatement */: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* IfStatement */: + case 219 /* ExpressionStatement */: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForStatement */: + case 223 /* 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, ts.liftToBlock)); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -59913,17 +60603,17 @@ var ts; return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 212 /* SemicolonClassElement */: - case 215 /* EmptyStatement */: - case 206 /* OmittedExpression */: - case 231 /* DebuggerStatement */: - case 301 /* NotEmittedStatement */: + case 215 /* SemicolonClassElement */: + case 218 /* EmptyStatement */: + case 208 /* OmittedExpression */: + case 234 /* DebuggerStatement */: + case 304 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -59990,49 +60680,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* NewExpression */: + case 190 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -60040,123 +60730,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ArrowFunction */: + case 195 /* 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 191 /* ParenthesizedExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208 /* AsExpression */: + case 210 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 213 /* Block */: + case 216 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219 /* WhileStatement */: - case 226 /* WithStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60165,7 +60855,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60173,139 +60863,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -60378,7 +61068,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) && node.kind !== 207 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -60622,7 +61312,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -60769,7 +61458,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -60815,7 +61504,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -60823,13 +61512,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + case 246 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -60859,13 +61548,13 @@ var ts; } } break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -60873,7 +61562,7 @@ var ts; } } break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -60893,7 +61582,7 @@ var ts; } } break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -61509,13 +62198,14 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -61539,14 +62229,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -61574,16 +62264,18 @@ var ts; */ function saveStateAndInvoke(node, f) { // Save state - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } /** @@ -61593,15 +62285,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 240 /* ModuleBlock */: - case 213 /* Block */: - currentScope = node; + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 243 /* ModuleBlock */: + case 216 /* Block */: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -61613,7 +62306,11 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } + if (ts.isClassDeclaration(node)) { + // XXX: should probably also cover interfaces and type aliases that can have type variables? + currentNameScope = node; } break; } @@ -61657,10 +62354,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -61681,13 +62378,13 @@ var ts; return node; } switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -61707,11 +62404,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 250 /* ExportDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 245 /* ImportClause */ || - (node.kind === 243 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 254 /* ExternalModuleReference */)) { + if (node.kind === 253 /* ExportDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 248 /* ImportClause */ || + (node.kind === 246 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 257 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -61753,7 +62450,7 @@ var ts; case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -61794,6 +62491,8 @@ var ts; // TypeScript accessibility and readonly modifiers are elided. case 167 /* ArrayType */: case 168 /* TupleType */: + case 169 /* OptionalType */: + case 170 /* RestType */: case 166 /* TypeLiteral */: case 161 /* TypePredicate */: case 148 /* TypeParameter */: @@ -61809,36 +62508,36 @@ var ts; case 163 /* FunctionType */: case 165 /* TypeQuery */: case 162 /* TypeReference */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 171 /* ConditionalType */: - case 173 /* ParenthesizedType */: - case 174 /* ThisType */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: - case 178 /* LiteralType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 175 /* ParenthesizedType */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: // TypeScript type nodes are elided. case 160 /* IndexSignature */: // TypeScript index signatures are elided. case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; case 152 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; case 155 /* Constructor */: return visitConstructor(node); - case 236 /* InterfaceDeclaration */: + case 239 /* 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61849,7 +62548,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61860,13 +62559,13 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); case 154 /* MethodDeclaration */: @@ -61879,13 +62578,13 @@ var ts; case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case 149 /* Parameter */: @@ -61898,35 +62597,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -61962,7 +62661,7 @@ var ts; var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) @@ -62005,7 +62704,7 @@ var ts; var statements = [classStatement]; // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -62366,7 +63065,7 @@ var ts; // // super(...arguments); // - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } // Add the property initializers. Transforms this: @@ -62408,7 +63107,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -62445,7 +63144,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -62492,7 +63191,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -62795,7 +63494,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } /** @@ -62922,8 +63621,8 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -62945,8 +63644,8 @@ var ts; return serializeTypeNode(node.type); case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: @@ -63034,7 +63733,7 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return serializeTypeNode(node.type); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -63049,7 +63748,7 @@ var ts; return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -63069,18 +63768,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: return serializeUnionOrIntersectionType(node); case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: case 142 /* UnknownKeyword */: - case 174 /* ThisType */: - case 179 /* ImportType */: + case 176 /* ThisType */: + case 181 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63093,7 +63792,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -63132,7 +63831,7 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); @@ -63179,7 +63878,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. + name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -63513,7 +64212,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -63594,7 +64293,7 @@ var ts; * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -63618,7 +64317,7 @@ var ts; // enum body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63643,7 +64342,7 @@ var ts; // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63691,7 +64390,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } /** * Transforms the value of an enum member. @@ -63769,12 +64468,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentScope.kind === 274 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 238 /* EnumDeclaration */) { + if (node.kind === 241 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -63836,7 +64535,7 @@ var ts; // module body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63860,7 +64559,7 @@ var ts; // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63893,7 +64592,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240 /* ModuleBlock */) { + if (body.kind === 243 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -63939,13 +64638,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 !== 240 /* ModuleBlock */) { + if (body.kind !== 243 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -63986,7 +64685,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 246 /* NamespaceImport */) { + if (node.kind === 249 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -64141,17 +64840,17 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -64218,16 +64917,16 @@ 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(71 /* Identifier */); - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(239 /* ModuleDeclaration */); + context.enableEmitNotification(242 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; } /** * Hook for node emit. @@ -64288,9 +64987,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -64328,9 +65027,9 @@ 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 !== 274 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); + if (container && container.kind !== 277 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -64465,15 +65164,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -64482,27 +65181,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 213 /* Block */: - case 227 /* SwitchStatement */: - case 241 /* CaseBlock */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 230 /* TryStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 226 /* WithStatement */: - case 228 /* LabeledStatement */: + case 216 /* Block */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 229 /* WithStatement */: + case 231 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -64537,7 +65236,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -64703,7 +65402,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 === 193 /* ArrowFunction */; + var isArrowFunction = node.kind === 195 /* 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 @@ -64776,11 +65475,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -64824,11 +65523,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -64860,7 +65559,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -64959,25 +65658,25 @@ var ts; return node; } switch (node.kind) { - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitVoidExpression(node); case 155 /* Constructor */: return visitConstructorDeclaration(node); @@ -64987,19 +65686,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); case 149 /* Parameter */: return visitParameter(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -65033,7 +65732,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -65045,7 +65744,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 272 /* SpreadAssignment */) { + if (e.kind === 275 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -65054,7 +65753,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -65072,7 +65771,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 !== 184 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -65211,13 +65910,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -65385,11 +66084,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -65433,11 +66132,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -65469,7 +66168,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -65582,13 +66281,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -65598,13 +66297,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -65679,7 +66378,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265 /* JsxExpression */) { + else if (node.kind === 268 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -65773,7 +66472,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255 /* JsxElement */) { + if (node.kind === 258 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -66079,7 +66778,7 @@ var ts; return node; } switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66312,13 +67011,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 225 /* ReturnStatement */ + && node.kind === 228 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -66346,63 +67045,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return visitClassExpression(node); case 149 /* Parameter */: return visitParameter(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -66413,28 +67112,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitMetaProperty(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -66521,14 +67220,14 @@ 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 === 224 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -66539,7 +67238,7 @@ var ts; } } else { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -66656,7 +67355,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -66720,7 +67419,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), /*location*/ extendsClauseElement)); } } @@ -66839,11 +67538,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 225 /* ReturnStatement */) { + if (statement.kind === 228 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 217 /* IfStatement */) { + else if (statement.kind === 220 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -66851,7 +67550,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 213 /* Block */) { + else if (statement.kind === 216 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -66909,7 +67608,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -66919,8 +67618,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 /* BinaryExpression */ - || superCallExpression.left.kind !== 187 /* CallExpression */) { + if (superCallExpression.kind !== 202 /* BinaryExpression */ + || superCallExpression.left.kind !== 189 /* 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. @@ -67035,7 +67734,7 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -67049,7 +67748,7 @@ 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.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -67101,7 +67800,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) ]), 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 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) @@ -67117,7 +67816,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -67137,7 +67836,7 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return statements; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -67151,8 +67850,8 @@ var ts; // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -67183,7 +67882,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: @@ -67227,7 +67926,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -67245,7 +67944,7 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); + var statement = ts.createExpressionStatement(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. @@ -67388,7 +68087,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -67433,7 +68132,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193 /* ArrowFunction */); + ts.Debug.assert(node.kind === 195 /* 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 @@ -67501,10 +68200,10 @@ 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 191 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + case 193 /* ParenthesizedExpression */: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 202 /* BinaryExpression */: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); } @@ -67522,9 +68221,9 @@ var ts; // 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 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -67566,7 +68265,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -67725,14 +68424,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -67790,11 +68489,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -67883,13 +68582,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -67988,11 +68687,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -68156,7 +68855,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -68173,7 +68872,7 @@ var ts; ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { @@ -68282,10 +68981,10 @@ var ts; case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -68537,7 +69236,7 @@ var ts; statements.push(funcStatements[classBodyStart]); classBodyStart++; // Add the class alias following the declaration. - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } // Find the trailing 'return' statement (4) while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { @@ -68674,7 +69373,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -68941,9 +69640,9 @@ var ts; context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(193 /* ArrowFunction */); - context.enableEmitNotification(192 /* FunctionExpression */); - context.enableEmitNotification(234 /* FunctionDeclaration */); + context.enableEmitNotification(195 /* ArrowFunction */); + context.enableEmitNotification(194 /* FunctionExpression */); + context.enableEmitNotification(237 /* FunctionDeclaration */); } } /** @@ -68984,10 +69683,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 235 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -69069,11 +69768,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -69081,7 +69780,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -69134,15 +69833,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257 /* JsxOpeningElement */); - context.enableEmitNotification(258 /* JsxClosingElement */); - context.enableEmitNotification(256 /* JsxSelfClosingElement */); + context.enableEmitNotification(260 /* JsxOpeningElement */); + context.enableEmitNotification(261 /* JsxClosingElement */); + context.enableEmitNotification(259 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(270 /* PropertyAssignment */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(273 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -69161,9 +69860,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -69495,13 +70194,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -69514,24 +70213,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return visitBreakStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return visitContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -69552,21 +70251,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitConditionalExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69579,9 +70278,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -69757,7 +70456,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } /** @@ -69809,7 +70508,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -69821,7 +70520,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -69945,7 +70644,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* Statement */, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -70098,7 +70797,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -70197,35 +70896,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: return transformAndEmitBlock(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return transformAndEmitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return transformAndEmitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return transformAndEmitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return transformAndEmitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -70262,7 +70961,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -70413,7 +71112,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -70423,7 +71122,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -70484,7 +71183,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); @@ -70507,7 +71206,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -70655,7 +71354,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -70668,7 +71367,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -71531,7 +72230,7 @@ var ts; // indicate entry into a protected region by pushing the label numbers // for each block in the protected region. var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, [ ts.createArrayLiteral([ createLabel(startLabel), @@ -71545,7 +72244,7 @@ var ts; if (markLabelEnd) { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -71703,7 +72402,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -71897,11 +72596,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(277 /* 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. @@ -71994,7 +72693,7 @@ var ts; // // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, + ts.createExpressionStatement(ts.createCall(define, /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ // Add the dependency array argument: // @@ -72045,9 +72744,9 @@ var ts; 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.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(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"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -72071,7 +72770,7 @@ var ts; // } // })(function ...) var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, + ts.createExpressionStatement(ts.createCall(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // @@ -72150,7 +72849,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. @@ -72205,7 +72904,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); @@ -72223,23 +72922,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -72266,17 +72965,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -72370,7 +73069,7 @@ var ts; ts.createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; @@ -72465,7 +73164,7 @@ var ts; if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -72533,7 +73232,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( @@ -72546,7 +73245,7 @@ var ts; } else { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -72585,13 +73284,13 @@ var ts; 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)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { // export * from "mod"; - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } /** @@ -72697,7 +73396,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -72758,7 +73457,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -72813,10 +73512,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -72946,10 +73645,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), @@ -72970,7 +73669,7 @@ var ts; * @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); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -73015,7 +73714,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -73079,10 +73778,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -73103,7 +73802,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -73178,7 +73877,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -73254,11 +73953,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(277 /* 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. @@ -73320,7 +74019,7 @@ var ts; 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.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) @@ -73479,7 +74178,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -73504,7 +74203,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250 /* ExportDeclaration */) { + if (externalImport.kind !== 253 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -73558,9 +74257,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) ])), - ts.createStatement(ts.createCall(exportFunction, + ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) ], /*multiline*/ true)); } @@ -73582,19 +74281,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -73610,7 +74309,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { @@ -73619,7 +74318,7 @@ var ts; // emit as: // // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, /*typeArguments*/ undefined, [parameterName]))); } break; @@ -73644,15 +74343,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -73753,7 +74452,7 @@ 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.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -73790,7 +74489,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -73828,7 +74527,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 274 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 277 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -73892,7 +74591,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 === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -73954,10 +74653,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -74109,7 +74808,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -74137,43 +74836,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitDefaultClause(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitTryStatement(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -74356,7 +75055,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 200 /* BinaryExpression */) { + && node.kind === 202 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -74421,7 +75120,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274 /* SourceFile */; + return container !== undefined && container.kind === 277 /* SourceFile */; } else { return false; @@ -74454,7 +75153,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -74502,7 +75201,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -74538,10 +75237,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -74634,14 +75333,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 199 /* PostfixUnaryExpression */) { + if (node.kind === 201 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -74663,7 +75362,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -74702,7 +75401,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274 /* SourceFile */); + context.enableEmitNotification(277 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -74731,10 +75430,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -74841,7 +75540,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74870,7 +75569,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -74917,7 +75616,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { 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 : @@ -74936,7 +75635,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 === 235 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { 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 : @@ -75027,7 +75726,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -75041,7 +75740,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234 /* FunctionDeclaration */: + case 237 /* 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 : @@ -75097,7 +75796,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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 : @@ -75110,7 +75809,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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 163 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -75125,10 +75824,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159 /* ConstructSignature */: @@ -75142,17 +75841,17 @@ var ts; 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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -75167,7 +75866,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 235 /* ClassDeclaration */) { + if (node.parent.parent.kind === 238 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = node.parent.token === 108 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -75264,7 +75963,13 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + // If it is visible via `// `, then we should just use that + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -75319,10 +76024,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -75350,7 +76055,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -75448,7 +76153,7 @@ var ts; return name; } else { - if (name.kind === 181 /* ArrayBindingPattern */) { + if (name.kind === 183 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -75456,7 +76161,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206 /* OmittedExpression */) { + if (elem.kind === 208 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -75514,7 +76219,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 /* Parameter */ @@ -75536,20 +76241,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return false; } return false; @@ -75603,7 +76308,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -75615,7 +76320,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -75642,7 +76347,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -75747,14 +76452,14 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 207 /* ExpressionWithTypeArguments */: { + case 209 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -75808,7 +76513,7 @@ var ts; return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -75822,7 +76527,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171 /* ConditionalType */: { + case 173 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -75840,7 +76545,7 @@ var ts; case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179 /* ImportType */: { + case 181 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -75879,7 +76584,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250 /* ExportDeclaration */: { + case 253 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -75888,7 +76593,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -75918,10 +76623,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -75942,24 +76647,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 236 /* InterfaceDeclaration */: { + case 239 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 234 /* FunctionDeclaration */: { + case 237 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type return cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); } - case 239 /* ModuleDeclaration */: { + case 242 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240 /* ModuleBlock */) { + if (inner && inner.kind === 243 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -75980,7 +76685,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 235 /* ClassDeclaration */: { + case 238 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -76020,7 +76725,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 @@ -76050,10 +76755,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238 /* EnumDeclaration */: { + case 241 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -76072,7 +76777,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239 /* ModuleDeclaration */) { + if (input.kind === 242 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -76093,7 +76798,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206 /* OmittedExpression */) { + if (e.kind === 208 /* OmittedExpression */) { return; } if (e.name) { @@ -76147,7 +76852,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 274 /* SourceFile */; + var parentIsFile = node.parent.kind === 277 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -76168,7 +76873,7 @@ var ts; var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3 /* MultiLineCommentTrivia */) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -76182,7 +76887,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -76195,7 +76900,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* InterfaceDeclaration */) { return true; } return false; @@ -76224,7 +76929,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: @@ -76234,17 +76939,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: - case 214 /* VariableStatement */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 217 /* VariableStatement */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return true; } return false; @@ -76261,14 +76966,14 @@ var ts; case 153 /* MethodSignature */: case 158 /* CallSignature */: case 160 /* IndexSignature */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 148 /* TypeParameter */: - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: case 162 /* TypeReference */: - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 179 /* ImportType */: + case 181 /* ImportType */: return true; } return false; @@ -76344,7 +77049,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(306 /* Count */); + var enabledSyntaxKindFeatures = new Array(309 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -76679,7 +77384,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap @@ -76689,7 +77393,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 277 /* 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 = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -76780,7 +77484,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** * Emits a mapping. @@ -76840,6 +77543,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -76850,50 +77554,55 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { // empty } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); // First, decode the old component sourcemap - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); + } + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -76910,7 +77619,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -76965,13 +77674,15 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -77087,7 +77798,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 304 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 10 /* JsxText */; @@ -77108,7 +77819,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 === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -77450,7 +78161,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275 /* Bundle */) { + if (sourceFile.kind === 278 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; @@ -77585,6 +78296,11 @@ var ts; // Setup and perform the transformation to retrieve declarations from the input files var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + // Checker wont collect the linked aliases since thats only done when declaration is enabled. + // Do that here when emitting only dts files + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -77612,9 +78328,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71 /* Identifier */) { + resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -77714,9 +78443,9 @@ var ts; break; } switch (node.kind) { - case 274 /* SourceFile */: return printFile(node); - case 275 /* Bundle */: return printBundle(node); - case 276 /* UnparsedSource */: return printUnparsedSource(node); + case 277 /* SourceFile */: return printFile(node); + case 278 /* Bundle */: return printBundle(node); + case 279 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -77861,7 +78590,7 @@ var ts; } return pipelineEmitWithoutComments; case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { return pipelineEmitWithSourceMap; } // falls through @@ -77887,7 +78616,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); + ts.Debug.assert(hint !== 0 /* SourceFile */); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -77906,7 +78635,7 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 276 /* UnparsedSource */: + case 279 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: @@ -77951,7 +78680,7 @@ var ts; return emitTypeReference(node); case 163 /* FunctionType */: return emitFunctionType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 164 /* ConstructorType */: return emitConstructorType(node); @@ -77963,178 +78692,181 @@ var ts; return emitArrayType(node); case 168 /* TupleType */: return emitTupleType(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return emitOptionalType(node); + case 171 /* UnionType */: return emitUnionType(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return emitIntersectionType(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return emitConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return emitInferType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return emitParenthesizedType(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return emitThisType(); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return emitTypeOperator(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return emitMappedType(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return emitLiteralType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return emitImportTypeNode(node); - case 279 /* JSDocAllType */: + case 282 /* JSDocAllType */: write("*"); return; - case 280 /* JSDocUnknownType */: + case 283 /* JSDocUnknownType */: write("?"); return; - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 285 /* JSDocVariadicType */: - return emitJSDocVariadicType(node); + case 170 /* RestType */: + case 288 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return emitBindingElement(node); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return emitTemplateSpan(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 213 /* Block */: + case 216 /* Block */: return emitBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return emitVariableStatement(node); - case 215 /* EmptyStatement */: + case 218 /* EmptyStatement */: return emitEmptyStatement(); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return emitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return emitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return emitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return emitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return emitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return emitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return emitForOfStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return emitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return emitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return emitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return emitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return emitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return emitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return emitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return emitTryStatement(node); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return emitClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return emitModuleBlock(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return emitCaseBlock(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return emitImportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return emitImportClause(node); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return emitNamespaceImport(node); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return emitNamedImports(node); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return emitImportSpecifier(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return emitExportDeclaration(node); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return emitNamedExports(node); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return emitExportSpecifier(node); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return; // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 258 /* JsxClosingElement */: - case 261 /* JsxClosingFragment */: + case 261 /* JsxClosingElement */: + case 264 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return emitJsxAttribute(node); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return emitJsxAttributes(node); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return emitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return emitDefaultClause(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return emitHeritageClause(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -78169,71 +78901,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return emitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return emitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return emitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return emitArrowFunction(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return emitDeleteExpression(node); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return emitVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return emitAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return emitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return emitConditionalExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return emitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return emitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return emitSpreadExpression(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return emitClassExpression(node); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: return emitAsExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return emitNonNullExpression(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return emitJsxElement(node); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return emitCommaList(node); } } @@ -78250,7 +78982,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 /* Bundle */ ? node : undefined; + var bundle = node.kind === 278 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -78376,7 +79108,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -78545,7 +79277,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -78554,6 +79286,10 @@ var ts; emitList(node, node.elementTypes, 272 /* TupleTypeElements */); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260 /* UnionTypeConstituents */); } @@ -78835,7 +79571,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 === 198 /* PrefixUnaryExpression */ + return operand.kind === 200 /* PrefixUnaryExpression */ && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } @@ -78955,7 +79691,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217 /* IfStatement */) { + if (node.elseStatement.kind === 220 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -79026,7 +79762,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { emit(node); } else { @@ -79128,7 +79864,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272 /* VariableDeclarationList */); } @@ -79321,7 +80057,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239 /* ModuleDeclaration */) { + while (body.kind === 242 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -80246,7 +80982,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -80311,81 +81047,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: ts.forEach(node.statements, generateNames); break; - case 228 /* LabeledStatement */: - case 226 /* WithStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 231 /* LabeledStatement */: + case 229 /* WithStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: generateNames(node.statement); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: generateNames(node.declarationList); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: generateNames(node.importClause); break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -80394,8 +81130,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 152 /* PropertyDeclaration */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -80581,17 +81317,17 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 252 /* ExportAssignment */: return generateNameForExportDefault(); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return generateNameForClassExpression(); case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -81252,17 +81988,20 @@ var ts; } return context; } - function formatLocation(file, start, host) { + /* @internal */ + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -81281,11 +82020,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -82012,7 +82751,16 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + // Use local caches + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + // Before falling back to the host + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -82272,10 +83020,10 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: - case 232 /* VariableDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: + case 235 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -82283,41 +83031,41 @@ var ts; } } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -82330,25 +83078,25 @@ 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: // 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; } // falls through - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); } break; case 152 /* PropertyDeclaration */: @@ -82370,11 +83118,11 @@ var ts; return; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -83040,14 +83788,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -84701,11 +85449,12 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - // Note: fromSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + // Note: importingSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -84718,7 +85467,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); @@ -84736,13 +85485,13 @@ var ts; function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -84812,11 +85561,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0 /* EqualTo */) { resolvedParts.pop(); originalParts.pop(); } @@ -84850,17 +85600,16 @@ var ts; return [target]; } /** - * Looks for a existing imports that use symlinks to this module. + * Looks for existing imports that use symlinks to this module. * Only if no symlink is available, the real path will be used. */ - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -84936,7 +85685,7 @@ var ts; var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); @@ -85344,7 +86093,7 @@ var ts; } var trace = host.trace && (function (s) { host.trace(s + newLine); }); var watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? ts.WatchLogLevel.Verbose : - compilerOptions.diagnostis ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; // TODO: GH#18217 var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -85876,16 +86625,20 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */) ? ".jsx" /* Jsx */ : ".js" /* Js */); + var newExtension = ts.fileExtensionIs(inputFileName, ".json" /* Json */) ? ".json" /* Json */ : + ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -86057,9 +86810,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -86109,7 +86859,7 @@ var ts; // Everything is broken - we don't even know what to watch. Give up. return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { // Watch this file @@ -86136,7 +86886,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -86341,14 +87091,18 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -86356,7 +87110,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -86652,12 +87410,12 @@ var ts; } // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -86726,7 +87484,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; @@ -87184,7 +87942,7 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ - ts.defaultPreferences = {}; + ts.emptyOptions = {}; var TextChange = /** @class */ (function () { function TextChange() { } @@ -87420,35 +88178,35 @@ var ts; function getMeaningFromDeclaration(node) { switch (node.kind) { case 149 /* Parameter */: - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 269 /* CatchClause */: - case 262 /* JsxAttribute */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 272 /* CatchClause */: + case 265 /* JsxAttribute */: return 1 /* Value */; case 148 /* TypeParameter */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: case 166 /* TypeLiteral */: return 2 /* Type */; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 273 /* EnumMember */: - case 235 /* ClassDeclaration */: + case 276 /* EnumMember */: + case 238 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -87458,26 +88216,26 @@ var ts; else { return 4 /* Namespace */; } - case 238 /* EnumDeclaration */: - case 247 /* NamedImports */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 241 /* EnumDeclaration */: + case 250 /* NamedImports */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 249 /* ExportAssignment */) { + else if (node.parent.kind === 252 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -87510,7 +88268,7 @@ var ts; // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 243 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + return name && name.parent.kind === 246 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { while (node.parent.kind === 146 /* QualifiedName */) { @@ -87536,16 +88294,16 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 185 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { + if (root.parent.kind === 187 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 187 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 209 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 271 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 238 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 239 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -87556,25 +88314,25 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return true; } switch (node.parent.kind) { case 162 /* TypeReference */: return true; - case 179 /* ImportType */: + case 181 /* ImportType */: return !node.parent.isTypeOf; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 189 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 190 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -87587,7 +88345,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 231 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -87612,11 +88370,11 @@ var ts; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 242 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -87628,20 +88386,20 @@ var ts; switch (node.parent.kind) { case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 270 /* PropertyAssignment */: - case 273 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 276 /* EnumMember */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return node.parent.argumentExpression === node; case 147 /* ComputedPropertyName */: return true; - case 178 /* LiteralType */: - return node.parent.parent.kind === 176 /* IndexedAccessType */; + case 180 /* LiteralType */: + return node.parent.parent.kind === 178 /* IndexedAccessType */; default: return false; } @@ -87665,17 +88423,17 @@ var ts; return undefined; } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return node; } } @@ -87683,26 +88441,26 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return "class" /* classElement */; - case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 237 /* TypeAliasDeclaration */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 239 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 240 /* TypeAliasDeclaration */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 238 /* EnumDeclaration */: return "enum" /* enumElement */; - case 232 /* VariableDeclaration */: + case 241 /* EnumDeclaration */: return "enum" /* enumElement */; + case 235 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return "function" /* functionElement */; case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; @@ -87717,15 +88475,14 @@ var ts; case 158 /* CallSignature */: return "call" /* callSignatureElement */; case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 273 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 276 /* EnumMember */: return "enum member" /* enumMemberElement */; case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: - case 252 /* ExportSpecifier */: - case 246 /* NamespaceImport */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: + case 249 /* NamespaceImport */: return "alias" /* alias */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -87749,11 +88506,13 @@ var ts; return "" /* unknown */; } } + case 71 /* Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; } function getKindOfVariableDeclaration(v) { - return ts.isConst(v) + return ts.isVarConst(v) ? "const" /* constElement */ : ts.isLet(v) ? "let" /* letElement */ @@ -87786,6 +88545,10 @@ var ts; return startEndContainsRange(r1.pos, r1.end, r2); } ts.rangeContainsRange = rangeContainsRange; + function rangeContainsRangeExclusive(r1, r2) { + return rangeContainsPositionExclusive(r1, r2.pos) && rangeContainsPositionExclusive(r1, r2.end); + } + ts.rangeContainsRangeExclusive = rangeContainsRangeExclusive; function rangeContainsPosition(r, pos) { return r.pos <= pos && pos <= r.end; } @@ -87806,6 +88569,10 @@ var ts; return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); } ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function nodeOverlapsWithStartEnd(node, sourceFile, start, end) { + return startEndOverlapsWithStartEnd(node.getStart(sourceFile), node.end, start, end); + } + ts.nodeOverlapsWithStartEnd = nodeOverlapsWithStartEnd; function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { var start = Math.max(start1, start2); var end = Math.min(end1, end2); @@ -87825,28 +88592,28 @@ var ts; return false; } switch (n.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: - case 180 /* ObjectBindingPattern */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: case 166 /* TypeLiteral */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 241 /* CaseBlock */: - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 244 /* CaseBlock */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 188 /* NewExpression */: + case 190 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 187 /* CallExpression */: - case 191 /* ParenthesizedExpression */: - case 173 /* ParenthesizedType */: + case 189 /* CallExpression */: + case 193 /* ParenthesizedExpression */: + case 175 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -87854,13 +88621,13 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 159 /* ConstructSignature */: case 158 /* CallSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -87870,19 +88637,19 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 183 /* ArrayLiteralExpression */: - case 181 /* ArrayBindingPattern */: - case 186 /* ElementAccessExpression */: + case 185 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 188 /* ElementAccessExpression */: case 147 /* ComputedPropertyName */: case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); @@ -87891,44 +88658,44 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); case 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 195 /* TypeOfExpression */: - case 194 /* DeleteExpression */: - case 196 /* VoidExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: + case 197 /* TypeOfExpression */: + case 196 /* DeleteExpression */: + case 198 /* VoidExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -87992,38 +88759,30 @@ var ts; * position >= start and (position < end or (position === end && token is literal or keyword or identifier)) */ function getTouchingPropertyName(sourceFile, position) { - return getTouchingToken(sourceFile, position, /*includeJsDocComment*/ true, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); + return getTouchingToken(sourceFile, position, function (n) { return ts.isPropertyNameLiteral(n) || ts.isKeyword(n.kind); }); } ts.getTouchingPropertyName = getTouchingPropertyName; /** * Returns the token if position is in [start, end). * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true */ - function getTouchingToken(sourceFile, position, includeJsDocComment, includePrecedingTokenAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false, includeJsDocComment); + function getTouchingToken(sourceFile, position, includePrecedingTokenAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includePrecedingTokenAtEndPosition, /*includeEndPosition*/ false); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile, position, includeJsDocComment, includeEndPosition) { - if (includeEndPosition === void 0) { includeEndPosition = false; } - return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, includeEndPosition, includeJsDocComment); + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, /*includeEndPosition*/ false); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition, includeJsDocComment) { + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition) { var current = sourceFile; outer: while (true) { - if (ts.isToken(current)) { - // exit early - return current; - } // find the child that contains 'position' for (var _i = 0, _a = current.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; - if (!includeJsDocComment && ts.isJSDocNode(child)) { - continue; - } - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { // If this child begins after position, then all subsequent children will as well. break; @@ -88054,7 +88813,7 @@ var ts; function findTokenOnLeftOfPosition(file, position) { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. - var tokenAtPosition = getTokenAtPosition(file, position, /*includeJsDocComment*/ false); + var tokenAtPosition = getTokenAtPosition(file, position); if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } @@ -88068,19 +88827,14 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - var children = n.getChildren(); - for (var _i = 0, children_3 = children; _i < children_3.length; _i++) { - var child = children_3[_i]; + return ts.firstDefined(n.getChildren(), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || // previous token ends exactly at the beginning of child (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child, sourceFile)) { - return find(child); - } - } - return undefined; + return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find(child) : undefined; + }); } } ts.findNextToken = findNextToken; @@ -88088,7 +88842,7 @@ var ts; * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - function findPrecedingToken(position, sourceFile, startNode, includeJsDoc) { + function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) { var result = find(startNode || sourceFile); ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; @@ -88105,7 +88859,7 @@ var ts; // we need to find the last token in a previous child. // 2) `position` is within the same span: we recurse on `child`. if (position < child.end) { - var start = child.getStart(sourceFile, includeJsDoc); + var start = child.getStart(sourceFile, /*includeJsDoc*/ !excludeJsdoc); var lookInPreviousChild = (start >= position) || // cursor in the leading trivia !nodeHasTokens(child, sourceFile) || isWhiteSpaceOnlyJsxText(child); @@ -88120,7 +88874,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 277 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); // 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. @@ -88180,7 +88934,7 @@ var ts; * returns true if the position is in between the open and close elements of an JSX expression. */ function isInsideJsxElementOrAttribute(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); if (!token) { return false; } @@ -88192,17 +88946,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 268 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 261 /* JsxClosingElement */) { return true; } return false; @@ -88212,7 +88966,7 @@ var ts; return ts.isJsxText(node) && node.containsOnlyWhiteSpaces; } function isInTemplateString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = getTokenAtPosition(sourceFile, position); return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); } ts.isInTemplateString = isInTemplateString; @@ -88254,7 +89008,7 @@ var ts; if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { - return { called: token, nTypeArguments: nTypeArguments }; + return ts.isDeclarationName(token) ? undefined : { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -88324,19 +89078,13 @@ var ts; * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - function isInComment(sourceFile, position, tokenAtPosition, predicate) { - return !!ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); + function isInComment(sourceFile, position, tokenAtPosition) { + return ts.formatting.getRangeOfEnclosingComment(sourceFile, position, /*precedingToken*/ undefined, tokenAtPosition); } ts.isInComment = isInComment; function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*"; - } + var token = getTokenAtPosition(sourceFile, position); + return !!ts.findAncestor(token, ts.isJSDoc); } ts.hasDocComment = hasDocComment; function nodeHasTokens(n, sourceFile) { @@ -88345,7 +89093,7 @@ var ts; return n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node) { - var flags = ts.getCombinedModifierFlags(node); + var flags = ts.isDeclaration(node) ? ts.getCombinedModifierFlags(node) : 0 /* None */; var result = []; if (flags & 8 /* Private */) result.push("private" /* privateMemberModifier */); @@ -88365,10 +89113,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 189 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 238 /* ClassDeclaration */ || node.kind === 239 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -88413,18 +89161,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 183 /* ArrayLiteralExpression */ || - node.kind === 184 /* ObjectLiteralExpression */) { + if (node.kind === 185 /* ArrayLiteralExpression */ || + node.kind === 186 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 200 /* BinaryExpression */ && + if (node.parent.kind === 202 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 222 /* ForOfStatement */ && + if (node.parent.kind === 225 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -88432,7 +89180,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 273 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -88440,19 +89188,17 @@ var ts; } ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; function isInReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ true); } ts.isInReferenceComment = isInReferenceComment; function isInNonReferenceComment(sourceFile, position) { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, function (c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ false); } ts.isInNonReferenceComment = isInNonReferenceComment; + function isInReferenceCommentWorker(sourceFile, position, shouldBeReference) { + var range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined); + return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); + } function createTextSpanFromNode(node, sourceFile) { return ts.createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); } @@ -88566,13 +89312,17 @@ var ts; QuotePreference[QuotePreference["Single"] = 0] = "Single"; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); + function quotePreferenceFromString(str, sourceFile) { + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + } + ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference) { return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; } else { - var firstModuleSpecifier = ts.firstOrUndefined(sourceFile.imports); - return !!firstModuleSpecifier && !ts.isStringDoubleQuoted(firstModuleSpecifier, sourceFile) ? 0 /* Single */ : 1 /* Double */; + var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, ts.isStringLiteral); + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; } } ts.getQuotePreference = getQuotePreference; @@ -88652,6 +89402,37 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + var NodeMap = /** @class */ (function () { + function NodeMap() { + this.map = ts.createMap(); + } + NodeMap.prototype.get = function (node) { + var res = this.map.get(String(ts.getNodeId(node))); + return res && res.value; + }; + NodeMap.prototype.getOrUpdate = function (node, setValue) { + var res = this.get(node); + if (res) + return res; + var value = setValue(); + this.set(node, value); + return value; + }; + NodeMap.prototype.set = function (node, value) { + this.map.set(String(ts.getNodeId(node)), { node: node, value: value }); + }; + NodeMap.prototype.has = function (node) { + return this.map.has(String(ts.getNodeId(node))); + }; + NodeMap.prototype.forEach = function (cb) { + this.map.forEach(function (_a) { + var node = _a.node, value = _a.value; + return cb(value, node); + }); + }; + return NodeMap; + }()); + ts.NodeMap = NodeMap; function getParentNodeInSpan(node, file, span) { if (!node) return undefined; @@ -88667,6 +89448,10 @@ var ts; return ts.textSpanContainsPosition(span, node.getStart(file)) && node.getEnd() <= ts.textSpanEnd(span); } + function findModifier(node, kind) { + return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); + } + ts.findModifier = findModifier; /* @internal */ function insertImport(changes, sourceFile, importDecl) { var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); @@ -88879,7 +89664,7 @@ var ts; ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { return !!location.parent && - (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && + (location.parent.kind === 251 /* ImportSpecifier */ || location.parent.kind === 255 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -89308,7 +90093,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_5 = dense[i + 1]; + var length_6 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -89317,8 +90102,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_5, classification: convertClassification(type) }); - lastEnd = start + length_5; + entries.push({ length: length_6, classification: convertClassification(type) }); + lastEnd = start + length_6; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -89497,10 +90282,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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -89712,18 +90497,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -89810,22 +90595,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -89854,17 +90639,17 @@ var ts; var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 232 /* VariableDeclaration */ || + if (parent.kind === 235 /* VariableDeclaration */ || parent.kind === 152 /* PropertyDeclaration */ || parent.kind === 149 /* Parameter */ || - parent.kind === 262 /* JsxAttribute */) { + parent.kind === 265 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 200 /* BinaryExpression */ || - parent.kind === 198 /* PrefixUnaryExpression */ || - parent.kind === 199 /* PostfixUnaryExpression */ || - parent.kind === 201 /* ConditionalExpression */) { + if (parent.kind === 202 /* BinaryExpression */ || + parent.kind === 200 /* PrefixUnaryExpression */ || + parent.kind === 201 /* PostfixUnaryExpression */ || + parent.kind === 203 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -89875,7 +90660,7 @@ var ts; } else if (tokenKind === 9 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 265 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -89891,7 +90676,7 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } @@ -89901,17 +90686,17 @@ var ts; return 15 /* typeParameterName */; } return; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } @@ -89963,12 +90748,12 @@ var ts; }); } function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker)); + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); } PathCompletions.getStringLiteralCompletionsFromModuleNames = getStringLiteralCompletionsFromModuleNames; - function getStringLiteralCompletionsFromModuleNamesWorker(node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; + var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { var extensions = getSupportedExtensionsForModuleResolution(compilerOptions); @@ -89980,7 +90765,6 @@ var ts; } } else { - // Check for node modules return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } } @@ -90097,7 +90881,7 @@ var ts; for (var path in paths) { var patterns = paths[path]; if (paths.hasOwnProperty(path) && patterns) { - var _loop_13 = function (name, kind) { + var _loop_12 = function (name, kind) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind)); @@ -90105,7 +90889,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind; - _loop_13(name, kind); + _loop_12(name, kind); } } } @@ -90121,7 +90905,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_14 = function (moduleName) { + var _loop_13 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */)); @@ -90129,7 +90913,7 @@ var ts; }; for (var _e = 0, _f = enumerateNodeModulesVisibleToScript(host, scriptPath); _e < _f.length; _e++) { var moduleName = _f[_e]; - _loop_14(moduleName); + _loop_13(moduleName); } } if (!foundGlobal) { @@ -90146,14 +90930,16 @@ var ts; function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") && ts.startsWith(path, fragment) ? [{ name: path, kind: "directory" /* directory */ }] : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); - if (!ts.startsWith(fragment, pathPrefix)) { - return [{ name: pathPrefix, kind: "directory" /* directory */ }]; + var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); + return remainingFragment === undefined ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { + return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); + }); + function justPathMappingName(name) { + return ts.startsWith(name, fragment) ? [{ name: name, kind: "directory" /* directory */ }] : ts.emptyArray; } - var remainingFragment = fragment.slice(pathPrefix.length); - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); } function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { if (!host.readDirectory) { @@ -90210,7 +90996,7 @@ var ts; return nonRelativeModuleNames; } function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { - var token = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, position); var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); var range = commentRanges && ts.find(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end; }); if (!range) { @@ -90683,11 +91469,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.parent.parent.kind) { case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent)), isNewIdentifier: false }; - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -90695,12 +91481,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 179 /* ImportType */: + case 181 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(node.parent.parent) && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -90717,7 +91503,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -90730,8 +91516,8 @@ var ts; } return undefined; } - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -90740,9 +91526,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 254 /* ExternalModuleReference */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 257 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -90819,7 +91605,7 @@ var ts; || ts.codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) : symbol.name; } - function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, getCanonicalFileName, preferences, cancellationToken) { + function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); var name = entryId.name; @@ -90848,7 +91634,7 @@ var ts; } case "symbol": { var symbol = symbolCompletion.symbol, location = symbolCompletion.location, symbolToOriginInfoMap = symbolCompletion.symbolToOriginInfoMap, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -90891,14 +91677,14 @@ var ts; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; } - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, allSourceFiles, preferences) { + function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, previousToken, formatContext, allSourceFiles, preferences) { var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; if (!symbolOriginInfo || symbolOriginInfo.type !== "export") { return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; + var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, allSourceFiles, formatContext, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { @@ -90939,11 +91725,11 @@ var ts; return getContextualTypeFromParent(previousToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -90953,7 +91739,7 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 258 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo @@ -90968,15 +91754,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checker.getContextualType(parent); - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 266 /* CaseClause */: + case 269 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -90992,16 +91778,15 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 274 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 277 /* SourceFile */; }); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); - var currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // TODO: GH#15853 + var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) log("getCompletionData: Get current token: " + (ts.timestamp() - start)); start = ts.timestamp(); - // Completion not allowed inside comments, bail out if this is the case var insideComment = ts.isInComment(sourceFile, position, currentToken); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); var insideJsDocTagTypeExpression = false; @@ -91044,11 +91829,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { - currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 281 /* JSDocTypeExpression */) { + currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 299 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 302 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -91066,7 +91851,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); // The decision to provide completion depends on the contextToken, which is determined through the previousToken. // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file @@ -91075,7 +91860,7 @@ var ts; // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { var start_4 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); } // Find the node where completion is requested on. @@ -91098,15 +91883,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; case 146 /* QualifiedName */: node = parent.left; break; - case 179 /* ImportType */: - case 210 /* MetaProperty */: + case 181 /* ImportType */: + case 212 /* MetaProperty */: node = parent; break; default: @@ -91119,7 +91904,7 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 185 /* PropertyAccessExpression */) { + if (parent && parent.kind === 187 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -91127,39 +91912,38 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 258 /* JsxElement */ || currentToken.parent.kind === 260 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 259 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 200 /* BinaryExpression */: - if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { - // It has a left-hand side, so we're not in an opening JSX tag. + case 202 /* BinaryExpression */: + if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: + case 260 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -91212,11 +91996,11 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, literals: literals, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: - case 294 /* JSDocReturnTag */: - case 296 /* JSDocTypeTag */: - case 298 /* JSDocTypedefTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: + case 297 /* JSDocReturnTag */: + case 299 /* JSDocTypeTag */: + case 301 /* JSDocTypedefTag */: return true; default: return false; @@ -91250,7 +92034,7 @@ var ts; } } // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 277 /* SourceFile */ && d.kind !== 242 /* ModuleDeclaration */ && d.kind !== 241 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; @@ -91274,27 +92058,31 @@ var ts; // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker, /*isForAccess*/ true)); + symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker)); } else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 181 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } } } function addPropertySymbol(symbol) { + // For a computed property with an accessible name like `Symbol.iterator`, + // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. - var symbolSymbol = ts.firstDefined(symbol.declarations, function (decl) { - var name = ts.getNameOfDeclaration(decl); - var leftName = name.kind === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; - return leftName && typeChecker.getSymbolAtLocation(leftName); - }); - if (symbolSymbol) { - symbols.push(symbolSymbol); - symbolToOriginInfoMap[ts.getSymbolId(symbolSymbol)] = { type: "symbol-member" }; + var computedPropertyName = ts.firstDefined(symbol.declarations, function (decl) { return ts.tryCast(ts.getNameOfDeclaration(decl), ts.isComputedPropertyName); }); + if (computedPropertyName) { + var leftMostName = getLeftMostName(computedPropertyName.expression); // The completion is for `Symbol`, not `iterator`. + var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); + // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. + var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); + if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + symbols.push(firstAccessibleSymbol); + symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = { type: "symbol-member" }; + } } else { symbols.push(symbol); @@ -91378,10 +92166,10 @@ var ts; var symbolMeanings = 67901928 /* Type */ | 67216319 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 274 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 277 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { - for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { + for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { type: "this-type" }; symbols.push(symbol); @@ -91414,10 +92202,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 274 /* SourceFile */: - case 202 /* TemplateExpression */: - case 265 /* JsxExpression */: - case 213 /* Block */: + case 277 /* SourceFile */: + case 204 /* TemplateExpression */: + case 268 /* JsxExpression */: + case 216 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -91464,12 +92252,12 @@ var ts; return parentKind === 152 /* PropertyDeclaration */ || parentKind === 151 /* PropertySignature */ || parentKind === 149 /* Parameter */ || - parentKind === 232 /* VariableDeclaration */ || + parentKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 237 /* TypeAliasDeclaration */; + return parentKind === 240 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 208 /* AsExpression */; + return parentKind === 210 /* AsExpression */; } } return false; @@ -91572,11 +92360,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 260 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; + if (contextToken.parent.kind === 261 /* JsxClosingElement */ || contextToken.parent.kind === 259 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 258 /* JsxElement */; } } return false; @@ -91586,36 +92374,36 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 187 /* CallExpression */ // func( a, | + return containingNodeKind === 189 /* CallExpression */ // func( a, | || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 188 /* NewExpression */ // new C(a, | - || containingNodeKind === 183 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 200 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 190 /* NewExpression */ // new C(a, | + || containingNodeKind === 185 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 202 /* BinaryExpression */ // const x = (a, | || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 187 /* CallExpression */ // func( | + return containingNodeKind === 189 /* CallExpression */ // func( | || containingNodeKind === 155 /* Constructor */ // constructor( | - || containingNodeKind === 188 /* NewExpression */ // new C(a| - || containingNodeKind === 191 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 173 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + || containingNodeKind === 190 /* NewExpression */ // new C(a| + || containingNodeKind === 193 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 175 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + return containingNodeKind === 185 /* ArrayLiteralExpression */ // [ | || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 129 /* ModuleKeyword */: // module | case 130 /* NamespaceKeyword */: // namespace | return true; case 23 /* DotToken */: - return containingNodeKind === 239 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 242 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 238 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 200 /* BinaryExpression */; // x = a| + return containingNodeKind === 235 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 202 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 204 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 214 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: @@ -91653,16 +92441,16 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 186 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = hasIndexSignature(typeForObject); - typeMembers = getPropertiesForCompletion(typeForObject, typeChecker, /*isForAccess*/ false); + typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 182 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -91673,7 +92461,7 @@ var ts; // through type declaration or inference. // 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 = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 222 /* ForOfStatement */; + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 225 /* ForOfStatement */; if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); @@ -91720,7 +92508,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 250 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -91764,8 +92552,8 @@ var ts; if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented var baseSymbols = ts.flatMap(ts.getAllSuperTypeNodes(decl), function (baseTypeNode) { - var type = typeChecker.getTypeAtLocation(baseTypeNode); // TODO: GH#18217 - return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); + var type = typeChecker.getTypeAtLocation(baseTypeNode); + return type && typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); } @@ -91835,14 +92623,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: - case 263 /* JsxAttributes */: - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { + case 187 /* PropertyAccessExpression */: + case 266 /* JsxAttributes */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 259 /* JsxSelfClosingElement */ || parent.kind === 260 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 262 /* JsxAttribute */) { + else if (parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91854,7 +92642,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent && ((parent.kind === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 265 /* JsxAttribute */) || (parent.kind === 267 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91864,8 +92652,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 265 /* JsxExpression */ && - parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { + parent.kind === 268 /* JsxExpression */ && + parent.parent && parent.parent.kind === 265 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91873,7 +92661,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 267 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -91893,49 +92681,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 232 /* VariableDeclaration */ || - containingNodeKind === 233 /* VariableDeclarationList */ || - containingNodeKind === 214 /* VariableStatement */ || - containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 235 /* VariableDeclaration */ || + containingNodeKind === 236 /* VariableDeclarationList */ || + containingNodeKind === 217 /* VariableStatement */ || + containingNodeKind === 241 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 182 /* BindingElement */; // var {x :html| + return containingNodeKind === 184 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 183 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 269 /* CatchClause */ || + return containingNodeKind === 272 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 241 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | - containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 238 /* ClassDeclaration */ || // class A< | + containingNodeKind === 207 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 239 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 240 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: return containingNodeKind === 149 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| + (!!parent.parent && parent.parent.kind === 183 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 248 /* ImportSpecifier */ || - containingNodeKind === 252 /* ExportSpecifier */ || - containingNodeKind === 246 /* NamespaceImport */; + return containingNodeKind === 251 /* ImportSpecifier */ || + containingNodeKind === 255 /* ExportSpecifier */ || + containingNodeKind === 249 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -92019,9 +92807,9 @@ 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 !== 270 /* PropertyAssignment */ && - m.kind !== 271 /* ShorthandPropertyAssignment */ && - m.kind !== 182 /* BindingElement */ && + if (m.kind !== 273 /* PropertyAssignment */ && + m.kind !== 274 /* ShorthandPropertyAssignment */ && + m.kind !== 184 /* BindingElement */ && m.kind !== 154 /* MethodDeclaration */ && m.kind !== 156 /* GetAccessor */ && m.kind !== 157 /* SetAccessor */) { @@ -92043,7 +92831,7 @@ var ts; // NOTE: if one only performs this step when m.name is an identifier, // things like '__proto__' are not filtered out. var name = ts.getNameOfDeclaration(m); - existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; + existingName = name && ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } @@ -92102,7 +92890,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 262 /* JsxAttribute */) { + if (attr.kind === 265 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -92209,47 +92997,28 @@ var ts; } /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node, position) { - var jsDoc = getJsDocHavingNode(node).jsDoc; - if (!jsDoc) - return undefined; - for (var _i = 0, jsDoc_1 = jsDoc; _i < jsDoc_1.length; _i++) { - var _a = jsDoc_1[_i], pos = _a.pos, end = _a.end, tags = _a.tags; - if (!tags || position < pos || position > end) - continue; - for (var i = tags.length - 1; i >= 0; i--) { - var tag = tags[i]; - if (position >= tag.pos) { - return tag; - } - } - } + var jsdoc = ts.findAncestor(node, ts.isJSDoc); + return jsdoc && jsdoc.tags && (ts.rangeContainsPosition(jsdoc, position) ? ts.findLast(jsdoc.tags, function (tag) { return tag.pos < position; }) : undefined); } - function getJsDocHavingNode(node) { - if (!ts.isToken(node)) - return node; - switch (node.kind) { - case 104 /* VarKeyword */: - case 110 /* LetKeyword */: - case 76 /* ConstKeyword */: - // if the current token is var, let or const, skip the VariableDeclarationList - return node.parent.parent; - default: - return node.parent; - } + function getPropertiesForObjectExpression(contextualType, obj, checker) { + return contextualType.isUnion() + ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(function (memberType) { + // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. + return !(memberType.flags & 32764 /* Primitive */ || + checker.isArrayLikeType(memberType) || + ts.typeHasCallOrConstructSignatures(memberType, checker) || + checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); + })) + : contextualType.getApparentProperties(); } /** * Gets all properties on a type, but if that type is a union of several types, * excludes array-like types or callable/constructable types. */ - function getPropertiesForCompletion(type, checker, isForAccess) { - if (!(type.isUnion())) { - return ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); - } - // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - var filteredTypes = isForAccess ? type.types : type.types.filter(function (memberType) { - return !(memberType.flags & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); - }); - return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); + function getPropertiesForCompletion(type, checker) { + return type.isUnion() + ? ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") + : ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } /** * Returns the immediate owning class declaration of a context token, @@ -92258,7 +93027,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 300 /* SyntaxList */: + case 303 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -92305,7 +93074,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -92314,12 +93083,16 @@ var ts; return ts.Debug.assertNever(triggerCharacter); } } + function binaryExpressionMayBeOpenTag(_a) { + var left = _a.left; + return ts.nodeIsMissing(left); + } function isStringLiteralOrTemplate(node) { switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: return true; default: return false; @@ -92453,7 +93226,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 277 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -92485,16 +93258,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 227 /* SwitchStatement */: - if (statement.kind === 223 /* ContinueStatement */) { + case 230 /* SwitchStatement */: + if (statement.kind === 226 /* ContinueStatement */) { return false; } // falls through - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -92504,24 +93277,17 @@ var ts; }); } function getModifierOccurrences(modifier, declaration) { - var modifierFlag = ts.modifierToFlag(modifier); - return ts.mapDefined(getNodesToSearchForModifier(declaration, modifierFlag), function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - var mod = ts.find(node.modifiers, function (m) { return m.kind === modifier; }); - ts.Debug.assert(!!mod); - return mod; - } - }); + return ts.mapDefined(getNodesToSearchForModifier(declaration, ts.modifierToFlag(modifier)), function (node) { return ts.findModifier(node, modifier); }); } function getNodesToSearchForModifier(declaration, modifierFlag) { // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: - case 213 /* Block */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: + case 216 /* Block */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -92531,10 +93297,10 @@ var ts; } case 155 /* Constructor */: case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: var 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. @@ -92567,7 +93333,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 218 /* DoStatement */) { + if (loopNode.kind === 221 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -92587,13 +93353,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -92965,12 +93731,13 @@ var ts; if (!markSeenDirectImport(direct)) { continue; } - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 235 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -92983,20 +93750,20 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 249 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -93006,7 +93773,7 @@ var ts; directImports.push(direct); } break; - case 179 /* ImportType */: + case 181 /* ImportType */: directImports.push(direct); break; default: @@ -93023,7 +93790,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 277 /* SourceFile */ || sourceFileLike.kind === 242 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -93078,7 +93845,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 243 /* ImportEqualsDeclaration */) { + if (decl.kind === 246 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -93088,7 +93855,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 179 /* ImportType */) { + if (decl.kind === 181 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -93103,17 +93870,17 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 250 /* ExportDeclaration */) { + if (decl.kind === 253 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -93163,7 +93930,7 @@ var ts; } } else { - var localSymbol = element.kind === 252 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 255 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -93192,7 +93959,7 @@ var ts; for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { var referencingFile = sourceFiles_5[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 274 /* SourceFile */) { + if (searchSourceFile.kind === 277 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -93222,7 +93989,8 @@ var ts; var map = ts.createMap(); for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { var sourceFile = sourceFiles_6[_i]; - cancellationToken.throwIfCancellationRequested(); + if (cancellationToken) + cancellationToken.throwIfCancellationRequested(); forEachImport(sourceFile, function (importDecl, moduleSpecifier) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { @@ -93239,7 +94007,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 277 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -93254,15 +94022,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 250 /* ExportDeclaration */: - case 244 /* ImportDeclaration */: { + case 253 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -93286,7 +94054,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 185 /* PropertyAccessExpression */) { + if (parent.kind === 187 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -93408,10 +94176,10 @@ var ts; // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 232 /* VariableDeclaration */) { + if (parent.kind === 235 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 272 /* CatchClause */ ? undefined : p.parent.parent.kind === 217 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -93420,15 +94188,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -93461,21 +94229,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 274 /* SourceFile */) { + if (parent.kind === 277 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 243 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 242 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 257 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -93510,13 +94278,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // 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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var result_6 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_6.push(nodeEntry(node)); }); return result_6; @@ -93532,8 +94300,7 @@ var ts; return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true }); } } - function findReferencedEntries(program, cancellationToken, sourceFiles, sourceFile, position, options) { - var node = ts.getTouchingPropertyName(sourceFile, position); + function findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options) { return ts.map(flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options)), toReferenceEntry); } FindAllReferences.findReferencedEntries = findReferencedEntries; @@ -93620,13 +94387,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 205 /* ClassExpression */) { + else if (node.kind === 207 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -93739,10 +94506,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -93900,7 +94667,7 @@ var ts; this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; - /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ + /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { if (searchOptions === void 0) { searchOptions = {}; } // Note: if this is an external module symbol, the name doesn't include quotes. @@ -93983,6 +94750,24 @@ var ts; } } } + function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { + var importTracker = FindAllReferences.createImportTracker(sourceFiles, ts.arrayToSet(sourceFiles, function (f) { return f.fileName; }), checker, cancellationToken); + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers; + for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { + var importLocation = importSearches_2[_i][0]; + cb(importLocation); + } + for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) { + var indirectUser = indirectUsers_2[_b]; + for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { + var node = _d[_c]; + if (ts.isIdentifier(node) && checker.getSymbolAtLocation(node) === exportSymbol) { + cb(node); + } + } + } + } + Core.eachExportReference = eachExportReference; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; @@ -94015,9 +94800,9 @@ var ts; : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 184 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 182 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -94039,7 +94824,7 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 194 /* FunctionExpression */ || valueDeclaration.kind === 207 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -94049,7 +94834,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 235 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 238 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -94078,7 +94863,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -94117,6 +94902,28 @@ var ts; } } Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; + function eachSignatureCall(signature, sourceFiles, checker, cb) { + if (!signature.name || !ts.isIdentifier(signature.name)) + return; + var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { + var name = _b[_a]; + if (!ts.isIdentifier(name) || name === signature.name || name.escapedText !== signature.name.escapedText) + continue; + var called = ts.climbPastPropertyAccess(name); + var call = called.parent; + if (!ts.isCallExpression(call) || call.expression !== called) + continue; + var referenceSymbol = checker.getSymbolAtLocation(name); + if (referenceSymbol && checker.getRootSymbols(referenceSymbol).some(function (s) { return s === symbol; })) { + cb(call); + } + } + } + } + Core.eachSignatureCall = eachSignatureCall; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos); }); @@ -94341,6 +95148,7 @@ var ts; function getReferenceForShorthandProperty(_a, search, state) { var flags = _a.flags, valueDeclaration = _a.valueDeclaration; var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + var name = valueDeclaration && ts.getNameOfDeclaration(valueDeclaration); /* * 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 @@ -94348,8 +95156,8 @@ var ts; * 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. */ - if (!(flags & 33554432 /* Transient */) && search.includes(shorthandValueSymbol)) { - addReference(ts.getNameOfDeclaration(valueDeclaration), shorthandValueSymbol, state); + if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { @@ -94457,7 +95265,7 @@ var ts; if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 274 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -94477,7 +95285,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 213 /* Block */) { + if (body.kind === 216 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -94505,13 +95313,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 183 /* ArrayLiteralExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 185 /* ArrayLiteralExpression */: return true; default: return false; @@ -94609,20 +95417,20 @@ var ts; staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 = ts.flatMap(searchSpaceNode.kind === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 277 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -94630,19 +95438,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 274 /* SourceFile */: - return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); + case 277 /* SourceFile */: + return container.kind === 277 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -94844,16 +95652,17 @@ var ts; }); } ts.getEditsForFileRename = getEditsForFileRename; + // exported for tests function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return function (path) { - var canonicalPath = getCanonicalFileName(path); - if (canonicalPath === canonicalOldPath) + if (getCanonicalFileName(path) === canonicalOldPath) return newFileOrDirPath; - var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + var suffix = ts.tryRemoveDirectoryPrefix(path, canonicalOldPath, getCanonicalFileName); return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; }; } + ts.getPathUpdater = getPathUpdater; function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { var configFile = program.getCompilerOptions().configFile; if (!configFile) @@ -94924,9 +95733,10 @@ var ts; } } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { - var _loop_15 = function (sourceFile) { - var newFromOld = oldToNew(sourceFile.fileName); - var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.fileName; + var allFiles = program.getSourceFiles(); + var _loop_14 = function (sourceFile) { + var newFromOld = oldToNew(sourceFile.path); + var newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.path; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); var oldFromNew = newToOld(sourceFile.fileName); var oldImportFromPath = oldFromNew || sourceFile.fileName; @@ -94939,20 +95749,24 @@ var ts; var newAbsolute = oldToNew(oldAbsolute); return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); }, function (importLiteral) { + var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + // No need to update if it's an ambient module^M + if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. // TODO:GH#18217 ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) - : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); - // If neither the importing source file nor the imported file moved, do nothing. - return toImport === undefined || !toImport.updated && !importingSourceFileMoved - ? undefined - : ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, preferences); + : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew); + // Need an update if the imported file moved, or the importing file moved and was using a relative path. + return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text))) + ? ts.moduleSpecifiers.getModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, host, allFiles, preferences) + : undefined; }); }; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - _loop_15(sourceFile); + for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { + var sourceFile = allFiles_1[_i]; + _loop_14(sourceFile); } } function combineNormal(pathA, pathB) { @@ -94961,12 +95775,10 @@ var ts; function combinePathsSafe(pathA, pathB) { return ts.ensurePathIsNonModuleName(combineNormal(pathA, pathB)); } - function getSourceFileToImport(importLiteral, importingSourceFile, program, host, oldToNew) { - var symbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); - if (symbol) { - if (symbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) - return undefined; // No need to update if it's an ambient module - var oldFileName = ts.find(symbol.declarations, ts.isSourceFile).fileName; + function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) { + if (importedModuleSymbol) { + // `find` should succeed because we checked for ambient modules before calling this function. + var oldFileName = ts.find(importedModuleSymbol.declarations, ts.isSourceFile).fileName; var newFileName = oldToNew(oldFileName); return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true }; } @@ -95042,7 +95854,8 @@ var ts; return getDefinitionInfoForIndexSignatures(node, typeChecker); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); - if (calledDeclaration) { + // Don't go to the component constructor definition for a JSX element, just go to the component definition. + if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && ts.isConstructorDeclaration(calledDeclaration))) { var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. @@ -95062,7 +95875,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 === 271 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 274 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -95111,7 +95924,7 @@ var ts; */ function symbolMatchesSignature(s, calledDeclaration) { return s === calledDeclaration.symbol || s === calledDeclaration.symbol.parent || - ts.isVariableDeclaration(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; + !ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol; } function getReferenceAtPosition(sourceFile, position, program) { var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); @@ -95204,11 +96017,11 @@ var ts; return true; } switch (declaration.kind) { - case 245 /* ImportClause */: - case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: return true; - case 248 /* ImportSpecifier */: - return declaration.parent.kind === 247 /* NamedImports */; + case 251 /* ImportSpecifier */: + return declaration.parent.kind === 250 /* NamedImports */; default: return false; } @@ -95262,7 +96075,7 @@ var ts; return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); } function findReferenceInPosition(refs, pos) { - return ts.find(refs, function (ref) { return ref.pos <= pos && pos <= ref.end; }); + return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; function getDefinitionInfoForFileReference(name, targetFileName) { @@ -95367,11 +96180,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: return [declaration]; - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -95392,16 +96205,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return withNode(tag.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -95531,7 +96344,7 @@ var ts; if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { return undefined; } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; @@ -95549,10 +96362,7 @@ var ts; var singleLineResult = "/** */"; return { newText: singleLineResult, caretOffset: 3 }; } - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - // replace non-whitespace characters in prefix with spaces. - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); + var indentationStr = getIndentationStringAtPosition(sourceFile, position); // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -95560,8 +96370,7 @@ var ts; // * TODO: other tags. // * the closing comment line // * if the caret was directly in front of the object, then we add an extra line and indentation. - var preamble = "/**" + newLine + - indentationStr + " * "; + var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + @@ -95569,6 +96378,14 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function getIndentationStringAtPosition(sourceFile, position) { + var text = sourceFile.text; + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + var pos = lineStart; + for (; pos <= position && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) + ; + return text.slice(lineStart, pos); + } function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; @@ -95580,20 +96397,21 @@ var ts; function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: case 151 /* PropertySignature */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 237 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 240 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -95601,14 +96419,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 274 /* SourceFile */: + case 277 /* SourceFile */: return undefined; - case 239 /* ModuleDeclaration */: + case 242 /* 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 { }'. - return commentOwner.parent.kind === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 200 /* BinaryExpression */: { + return commentOwner.parent.kind === 242 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 202 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -95628,14 +96446,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 193 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return rightHandSide.parameters; - case 205 /* ClassExpression */: { + case 207 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -95654,7 +96472,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_16 = function (sourceFile) { + var _loop_15 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { return "continue"; @@ -95664,15 +96482,12 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; - _loop_16(sourceFile); + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + _loop_15(sourceFile); } rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - return rawItems.map(createNavigateToItem); + return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } NavigateTo.getNavigateToItems = getNavigateToItems; function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { @@ -95687,23 +96502,23 @@ var ts; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 + // If the pattern has dots in it, then also see if the declaration container matches as well. + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } } else { - // If the pattern has dots in it, then also see if the declaration container matches as well. rawItems.push({ name: name, fileName: fileName, matchKind: match.kind, isCaseSensitive: match.isCaseSensitive, declaration: declaration }); } } } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 245 /* ImportClause */: - case 248 /* ImportSpecifier */: - case 243 /* ImportEqualsDeclaration */: - var importer = checker.getSymbolAtLocation(declaration.name); + case 248 /* ImportClause */: + case 251 /* ImportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; default: @@ -95748,14 +96563,14 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; + if (name && name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + return ts.emptyArray; } // Now, walk up our containers, adding all their names to the container array. var container = ts.getContainerNode(declaration); while (container) { if (!tryAddSingleDeclarationName(container, containers)) { - return undefined; + return ts.emptyArray; } container = ts.getContainerNode(container); } @@ -95780,7 +96595,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ // TODO: GH#18217 Just use `container ? ...` + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -95941,19 +96756,19 @@ var ts; addLeafNode(node); } break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addLeafNode(importClause); + addLeafNode(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -95964,8 +96779,8 @@ var ts; } } break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -95986,12 +96801,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -96001,9 +96816,9 @@ var ts; } endNode(); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -96011,18 +96826,18 @@ var ts; } endNode(); break; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 252 /* ExportSpecifier */: - case 243 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: case 160 /* IndexSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -96030,7 +96845,7 @@ var ts; case 3 /* PrototypeProperty */: case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); - break; + return; case 4 /* ThisProperty */: case 5 /* Property */: case 0 /* None */: @@ -96106,7 +96921,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -96116,7 +96931,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 242 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -96146,7 +96961,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -96154,16 +96969,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 239 /* ModuleDeclaration */) { + if (node.kind === 242 /* ModuleDeclaration */) { return getModuleName(node); } if (name) { @@ -96173,16 +96988,16 @@ var ts; } } switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -96220,25 +97035,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 274 /* SourceFile */: - case 237 /* TypeAliasDeclaration */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 277 /* SourceFile */: + case 240 /* TypeAliasDeclaration */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return true; case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 193 /* ArrowFunction */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -96248,8 +97063,8 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 240 /* ModuleBlock */: - case 274 /* SourceFile */: + case 243 /* ModuleBlock */: + case 277 /* SourceFile */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; @@ -96260,7 +97075,7 @@ var ts; function hasSomeImportantChild(item) { return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; + return childKind !== 235 /* VariableDeclaration */ && childKind !== 184 /* BindingElement */; }); } } @@ -96317,7 +97132,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -96328,16 +97143,16 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 + return decl.body.kind === 242 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 277 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 235 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -96347,16 +97162,16 @@ var ts; return ts.declarationNameToString(node.name); } // See if it is a var initializer. If so, use the var name. - else if (node.parent.kind === 232 /* VariableDeclaration */) { + else if (node.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (node.parent.kind === 200 /* BinaryExpression */ && + else if (node.parent.kind === 202 /* BinaryExpression */ && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name - else if (node.parent.kind === 270 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 273 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -96369,9 +97184,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 193 /* ArrowFunction */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: return true; default: return false; @@ -96427,10 +97242,7 @@ var ts; }); // Delete or replace the first import. if (newImportDecls.length === 0) { - changeTracker.deleteNode(sourceFile, oldImportDecls[0], { - useNonAdjustedStartPosition: true, - useNonAdjustedEndPosition: false, - }); + changeTracker.delete(sourceFile, oldImportDecls[0]); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. @@ -96442,7 +97254,7 @@ var ts; } // Delete any subsequent imports. for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + changeTracker.delete(sourceFile, oldImportDecls[i]); } } } @@ -96738,7 +97550,7 @@ var ts; var currentLineStart = lineStarts[i]; var lineEnd = i + 1 === lineStarts.length ? sourceFile.getEnd() : lineStarts[i + 1] - 1; var lineText = sourceFile.text.substring(currentLineStart, lineEnd); - var result = lineText.match(/^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/); + var result = isRegionDelimiter(lineText); if (!result || ts.isInComment(sourceFile, currentLineStart)) { continue; } @@ -96756,6 +97568,10 @@ var ts; } } } + var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + function isRegionDelimiter(lineText) { + return regionDelimiterRegExp.exec(lineText); + } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); if (!comments) @@ -96763,11 +97579,19 @@ var ts; var firstSingleLineCommentStart = -1; var lastSingleLineCommentEnd = -1; var singleLineCommentCount = 0; - for (var _i = 0, comments_3 = comments; _i < comments_3.length; _i++) { - var _a = comments_3[_i], kind = _a.kind, pos = _a.pos, end = _a.end; + var sourceText = sourceFile.getFullText(); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var _a = comments_2[_i], kind = _a.kind, pos = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { case 2 /* SingleLineCommentTrivia */: + // never fold region delimiters into single-line comment regions + var commentText = sourceText.slice(pos, end); + if (isRegionDelimiter(commentText)) { + combineAndAddMultipleSingleLineComments(); + singleLineCommentCount = 0; + break; + } // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (singleLineCommentCount === 0) { @@ -96798,24 +97622,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 195 /* ArrowFunction */); } // 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. switch (n.parent.kind) { - case 218 /* DoStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 269 /* CatchClause */: + case 221 /* DoStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 272 /* CatchClause */: return spanForNode(n.parent); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -96830,16 +97654,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanForNode(n.parent); - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 241 /* CaseBlock */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 244 /* CaseBlock */: return spanForNode(n); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -96913,7 +97737,6 @@ var ts; if (!candidateMatch) { return undefined; } - candidateContainers = candidateContainers || []; // -1 because the last part was checked against the name, and only the rest // of the parts are checked against the container. if (dotSeparatedSegments.length - 1 > candidateContainers.length) { @@ -97150,13 +97973,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_17 = function (start) { + var _loop_16 = function (start) { if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) { return { value: start }; } }; for (var start = 0; start <= n; start++) { - var state_4 = _loop_17(start); + var state_4 = _loop_16(start); if (typeof state_4 === "object") return state_4.value; } @@ -97672,21 +98495,12 @@ var ts; (function (ts) { var Rename; (function (Rename) { - function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var getCanonicalDefaultLibName = ts.memoize(function () { return getCanonicalFileName(ts.normalizePath(defaultLibFileName)); }); + function getRenameInfo(program, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }) : undefined; return renameInfo || getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); - function isDefinedInLibraryFile(declaration) { - if (!defaultLibFileName) { - return false; - } - var sourceFile = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName)); - return canonicalName === getCanonicalDefaultLibName(); - } } Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { @@ -97780,7 +98594,7 @@ var ts; InvocationKind[InvocationKind["Call"] = 0] = "Call"; InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; })(InvocationKind || (InvocationKind = {})); - function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { + function getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -97788,6 +98602,12 @@ var ts; // We are at the beginning of the file return undefined; } + if (shouldCarefullyCheckContext(triggerReason)) { + // In the middle of a string, don't provide signature help unless the user explicitly requested it. + if (ts.isInString(sourceFile, position, startingToken)) { + return undefined; + } + } var argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); if (!argumentInfo) return undefined; @@ -97806,6 +98626,10 @@ var ts; return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + function shouldCarefullyCheckContext(reason) { + // Only need to be careful if the user typed a character and signature help wasn't showing. + return !!reason && reason.kind === "characterTyped"; + } function getCandidateInfo(argumentInfo, checker) { var invocation = argumentInfo.invocation; if (invocation.kind === 0 /* Call */) { @@ -97828,11 +98652,11 @@ var ts; return undefined; } var typeChecker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_17 = function (sourceFile) { var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - var _loop_19 = function (declaration) { + var _loop_18 = function (declaration) { var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -97846,7 +98670,7 @@ var ts; }; for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { var declaration = declarations_13[_i]; - var state_6 = _loop_19(declaration); + var state_6 = _loop_18(declaration); if (typeof state_6 === "object") return state_6; } @@ -97854,7 +98678,7 @@ var ts; }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - var state_5 = _loop_18(sourceFile); + var state_5 = _loop_17(sourceFile); if (typeof state_5 === "object") return state_5.value; } @@ -97923,10 +98747,10 @@ var ts; return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 191 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 204 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -98075,7 +98899,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 === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -98084,7 +98908,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - var _loop_20 = function (n) { + var _loop_19 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); }); @@ -98094,7 +98918,7 @@ var ts; } }; for (var n = node; !ts.isBlock(n) && !ts.isSourceFile(n); n = n.parent) { - var state_7 = _loop_20(n); + var state_7 = _loop_19(n); if (typeof state_7 === "object") return state_7.value; } @@ -98239,7 +99063,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var decl = ts.getDeclarationOfJSInitializer(node); if (decl) { var symbol_3 = decl.symbol; @@ -98249,7 +99073,7 @@ var ts; } } // falls through if no diagnostic was created - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -98279,11 +99103,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); // TODO: GH#18217 - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -98300,12 +99124,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 249 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -98328,7 +99152,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 207 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -98373,7 +99197,7 @@ var ts; if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return "parameter" /* parameterElement */; } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { return "const" /* constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { @@ -98416,11 +99240,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 257 /* JsxOpeningElement */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -98460,7 +99284,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 185 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 187 /* 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)) { @@ -98481,7 +99305,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 190 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* 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 @@ -98568,7 +99392,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 207 /* 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 @@ -98602,7 +99426,7 @@ var ts; } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } @@ -98612,7 +99436,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 242 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -98650,7 +99474,7 @@ var ts; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 237 /* TypeAliasDeclaration */) { + else if (declaration.kind === 240 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -98667,7 +99491,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 273 /* EnumMember */) { + if (declaration.kind === 276 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -98697,17 +99521,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); break; - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -98716,7 +99540,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 243 /* ImportEqualsDeclaration */) { + if (declaration.kind === 246 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -98794,10 +99618,10 @@ var ts; // For some special property access expressions like `exports.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 === 274 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 277 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 202 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -98909,16 +99733,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 192 /* FunctionExpression */) { + if (declaration.kind === 194 /* FunctionExpression */) { return true; } - if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* FunctionDeclaration */) { + if (declaration.kind !== 235 /* VariableDeclaration */ && declaration.kind !== 237 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { + if (parent.kind === 277 /* SourceFile */ || parent.kind === 243 /* ModuleBlock */) { return false; } } @@ -99031,7 +99855,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_21 = function (opt) { + var _loop_20 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -99050,7 +99874,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_21(opt); + _loop_20(opt); } return options; } @@ -99227,10 +100051,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 262 /* JsxAttribute */: - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 265 /* JsxAttribute */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. return ts.isKeyword(node.kind) || node.kind === 71 /* Identifier */; } @@ -99711,44 +100535,44 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 220 /* ForStatement */; + return context.contextNode.kind === 223 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 171 /* ConditionalType */: - case 208 /* AsExpression */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 173 /* ConditionalType */: + case 210 /* AsExpression */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 161 /* TypePredicate */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 182 /* BindingElement */: + case 184 /* BindingElement */: // equals in type X = ... - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: // equal in p = 0; case 149 /* Parameter */: - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] case 148 /* TypeParameter */: return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; @@ -99764,19 +100588,19 @@ var ts; return contextKind === 152 /* PropertyDeclaration */ || contextKind === 151 /* PropertySignature */ || contextKind === 149 /* Parameter */ || - contextKind === 232 /* VariableDeclaration */ || + contextKind === 235 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 201 /* ConditionalExpression */ || - context.contextNode.kind === 171 /* ConditionalType */; + return context.contextNode.kind === 203 /* ConditionalExpression */ || + context.contextNode.kind === 173 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 180 /* ObjectBindingPattern */ || - context.contextNode.kind === 177 /* MappedType */ || + return context.contextNode.kind === 182 /* ObjectBindingPattern */ || + context.contextNode.kind === 179 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -99802,17 +100626,17 @@ var ts; return true; } switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 184 /* ObjectLiteralExpression */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 186 /* ObjectLiteralExpression */: + case 243 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: @@ -99820,13 +100644,13 @@ var ts; case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: case 158 /* CallSignature */: - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: case 155 /* Constructor */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 239 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -99835,40 +100659,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; + return context.contextNode.kind === 237 /* FunctionDeclaration */ || context.contextNode.kind === 194 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: case 166 /* TypeLiteral */: - case 239 /* ModuleDeclaration */: - case 250 /* ExportDeclaration */: - case 251 /* NamedExports */: - case 244 /* ImportDeclaration */: - case 247 /* NamedImports */: + case 242 /* ModuleDeclaration */: + case 253 /* ExportDeclaration */: + case 254 /* NamedExports */: + case 247 /* ImportDeclaration */: + case 250 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 269 /* CatchClause */: - case 240 /* ModuleBlock */: - case 227 /* SwitchStatement */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 272 /* CatchClause */: + case 243 /* ModuleBlock */: + case 230 /* SwitchStatement */: return true; - case 213 /* Block */: { + case 216 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 195 /* ArrowFunction */ && blockParent.kind !== 194 /* FunctionExpression */) { return true; } } @@ -99877,31 +100701,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 217 /* IfStatement */: - case 227 /* SwitchStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 219 /* WhileStatement */: - case 230 /* TryStatement */: - case 218 /* DoStatement */: - case 226 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 229 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 269 /* CatchClause */: + case 272 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 184 /* ObjectLiteralExpression */; + return context.contextNode.kind === 186 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 187 /* CallExpression */; + return context.contextNode.kind === 189 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 188 /* NewExpression */; + return context.contextNode.kind === 190 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -99913,28 +100737,28 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 193 /* ArrowFunction */; + return context.contextNode.kind === 195 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 179 /* ImportType */; + return context.contextNode.kind === 181 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; + return context.contextNode.kind !== 258 /* JsxElement */ && context.contextNode.kind !== 262 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; + return context.contextNode.kind === 268 /* JsxExpression */ || context.contextNode.kind === 267 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 262 /* JsxAttribute */; + return context.nextTokenParent.kind === 265 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 262 /* JsxAttribute */; + return context.contextNode.kind === 265 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 256 /* JsxSelfClosingElement */; + return context.contextNode.kind === 259 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -99952,14 +100776,14 @@ var ts; return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 236 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 239 /* ModuleDeclaration */; + return context.contextNode.kind === 242 /* ModuleDeclaration */; } function isObjectTypeContext(context) { return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; @@ -99973,21 +100797,21 @@ var ts; } switch (parent.kind) { case 162 /* TypeReference */: - case 190 /* TypeAssertionExpression */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 192 /* TypeAssertionExpression */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -99998,16 +100822,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 190 /* TypeAssertionExpression */; + return context.contextNode.kind === 192 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 198 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 205 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 209 /* NonNullExpression */; + return context.contextNode.kind === 211 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -100241,17 +101065,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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 274 /* SourceFile */: - case 213 /* Block */: - case 240 /* ModuleBlock */: + return !!body && body.kind === 243 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 277 /* SourceFile */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -100474,10 +101298,10 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 235 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 236 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 234 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 238 /* EnumDeclaration */: return 238 /* EnumDeclaration */; + case 238 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 239 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 237 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 241 /* EnumDeclaration */: return 241 /* EnumDeclaration */; case 156 /* GetAccessor */: return 125 /* GetKeyword */; case 157 /* SetAccessor */: return 136 /* SetKeyword */; case 154 /* MethodDeclaration */: @@ -100487,7 +101311,10 @@ var ts; // falls through case 152 /* PropertyDeclaration */: case 149 /* Parameter */: - return ts.getNameOfDeclaration(node).kind; + var name = ts.getNameOfDeclaration(node); + if (name) { + return name.kind; + } } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { @@ -100531,15 +101358,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 177 /* MappedType */) { + if (container.kind !== 179 /* MappedType */) { return false; } break; @@ -100639,7 +101466,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 185 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -101007,56 +101834,47 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition, predicate) { - if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); } + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword + tokenAtPosition) { + if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } + var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); + if (jsdoc) + tokenAtPosition = jsdoc.parent; var tokenStart = tokenAtPosition.getStart(sourceFile); if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } - if (precedingToken === undefined) { - precedingToken = ts.findPrecedingToken(position, sourceFile); - } + precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). var trailingRangesOfPreviousToken = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); var leadingCommentRangesOfNextToken = ts.getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); - var commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? - trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : - trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; - if (commentRanges) { - for (var _i = 0, commentRanges_1 = commentRanges; _i < commentRanges_1.length; _i++) { - var range = commentRanges_1[_i]; - // The end marker of a single-line comment does not include the newline character. - // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for closed multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // However, unterminated multi-line comments *do* contain their end. - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - // - if ((range.pos < position && position < range.end || - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()))) { - return (range.kind === 3 /* MultiLineCommentTrivia */ || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; - } - } - } - return undefined; + var commentRanges = ts.concatenate(trailingRangesOfPreviousToken, leadingCommentRangesOfNextToken); + return commentRanges && ts.find(commentRanges, function (range) { return ts.rangeContainsPositionExclusive(range, position) || + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -101064,8 +101882,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -101170,9 +101988,9 @@ var ts; if (options.indentStyle === ts.IndentStyle.None) { return 0; } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword - if (enclosingCommentRange) { + var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -101190,7 +102008,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 202 /* 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 */) { @@ -101346,7 +102164,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 === 274 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 277 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -101394,7 +102212,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 220 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -101412,13 +102230,13 @@ var ts; switch (node.parent.kind) { case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.parent.properties; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return node.parent.elements; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 158 /* CallSignature */: @@ -101429,21 +102247,21 @@ var ts; return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 188 /* NewExpression */: - case 187 /* CallExpression */: { + case 190 /* NewExpression */: + case 189 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -101483,10 +102301,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: node = node.expression; break; default: @@ -101551,82 +102369,82 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 216 /* ExpressionStatement */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 183 /* ArrayLiteralExpression */: - case 213 /* Block */: - case 240 /* ModuleBlock */: - case 184 /* ObjectLiteralExpression */: + case 219 /* ExpressionStatement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 185 /* ArrayLiteralExpression */: + case 216 /* Block */: + case 243 /* ModuleBlock */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 177 /* MappedType */: + case 179 /* MappedType */: case 168 /* TupleType */: - case 241 /* CaseBlock */: - case 267 /* DefaultClause */: - case 266 /* CaseClause */: - case 191 /* ParenthesizedExpression */: - case 185 /* PropertyAccessExpression */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 214 /* VariableStatement */: - case 249 /* ExportAssignment */: - case 225 /* ReturnStatement */: - case 201 /* ConditionalExpression */: - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: - case 256 /* JsxSelfClosingElement */: - case 265 /* JsxExpression */: + case 244 /* CaseBlock */: + case 270 /* DefaultClause */: + case 269 /* CaseClause */: + case 193 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 217 /* VariableStatement */: + case 252 /* ExportAssignment */: + case 228 /* ReturnStatement */: + case 203 /* ConditionalExpression */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: + case 259 /* JsxSelfClosingElement */: + case 268 /* JsxExpression */: case 153 /* MethodSignature */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 149 /* Parameter */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 173 /* ParenthesizedType */: - case 189 /* TaggedTemplateExpression */: - case 197 /* AwaitExpression */: - case 251 /* NamedExports */: - case 247 /* NamedImports */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: + case 175 /* ParenthesizedType */: + case 191 /* TaggedTemplateExpression */: + case 199 /* AwaitExpression */: + case 254 /* NamedExports */: + case 250 /* NamedImports */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: case 152 /* PropertyDeclaration */: return true; - case 232 /* VariableDeclaration */: - case 270 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 235 /* VariableDeclaration */: + case 273 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 186 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } return true; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 217 /* IfStatement */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 220 /* IfStatement */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - return childKind !== 213 /* Block */; - case 250 /* ExportDeclaration */: - return childKind !== 251 /* NamedExports */; - case 244 /* ImportDeclaration */: - return childKind !== 245 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 247 /* NamedImports */); - case 255 /* JsxElement */: - return childKind !== 258 /* JsxClosingElement */; - case 259 /* JsxFragment */: - return childKind !== 261 /* JsxClosingFragment */; - case 170 /* IntersectionType */: - case 169 /* UnionType */: + return childKind !== 216 /* Block */; + case 253 /* ExportDeclaration */: + return childKind !== 254 /* NamedExports */; + case 247 /* ImportDeclaration */: + return childKind !== 248 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 250 /* NamedImports */); + case 258 /* JsxElement */: + return childKind !== 261 /* JsxClosingElement */; + case 262 /* JsxFragment */: + return childKind !== 264 /* JsxClosingFragment */; + case 172 /* IntersectionType */: + case 171 /* UnionType */: if (childKind === 166 /* TypeLiteral */) { return false; } @@ -101638,17 +102456,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: { - if (parent.kind !== 213 /* Block */) { + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: { + if (parent.kind !== 216 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 194 /* FunctionExpression */ || grandParent.kind === 237 /* FunctionDeclaration */); } - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return true; default: return false; @@ -101777,7 +102595,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 184 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 186 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -101793,8 +102611,8 @@ var ts; this.formatContext = formatContext; this.changes = []; this.newFiles = []; - this.deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. this.classesWithNodesInsertedAtStart = ts.createMap(); // Set implemented as Map + this.deletedNodes = []; } ChangeTracker.fromContext = function (context) { return new ChangeTracker(ts.getNewLineOrDefaultFromHost(context.host, context.formatContext.options), context.formatContext); @@ -101808,13 +102626,11 @@ var ts; this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); return this; }; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { - if (options === void 0) { options = {}; } - var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); - var endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); - return this; + ChangeTracker.prototype.delete = function (sourceFile, node) { + this.deletedNodes.push({ sourceFile: sourceFile, node: node, }); + }; + ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { + this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { if (options === void 0) { options = {}; } @@ -101829,30 +102645,6 @@ var ts; var endPosition = afterEndNode === undefined ? sourceFile.text.length : getAdjustedStartPosition(sourceFile, afterEndNode, options, Position.FullStart); this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); }; - ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { - var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); - if (!containingList) { - ts.Debug.fail("node is not a list element"); - return this; - } - var index = ts.indexOfNode(containingList, node); - if (index < 0) { - return this; - } - if (containingList.length === 1) { - this.deleteNode(sourceFile, node); - return this; - } - // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. - // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. - ts.Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice"); - this.deletedNodesInLists.add(node); - this.deleteRange(sourceFile, { - pos: startPositionToDeleteNodeInList(sourceFile, node), - end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), - }); - return this; - }; ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { if (options === void 0) { options = {}; } this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile: sourceFile, range: range, options: options, node: newNode }); @@ -101918,7 +102710,7 @@ var ts; // If so, we do not want to separate the node from its comment if we can. // Otherwise, add an extra new line immediately before the error span. var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); - var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; this.insertText(sourceFile, token.getStart(sourceFile), text); @@ -101942,7 +102734,7 @@ var ts; } } else { - endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 235 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -101961,6 +102753,9 @@ var ts; else if (ts.isParameter(before)) { return {}; } + else if (ts.isStringLiteral(before) && ts.isImportDeclaration(before.parent) || ts.isNamedImports(before)) { + return { suffix: ", " }; + } return ts.Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { @@ -102020,6 +102815,9 @@ var ts; var endPosition = this.insertNodeAfterWorker(sourceFile, after, newNode); this.insertNodeAt(sourceFile, endPosition, newNode, this.getInsertNodeAfterOptions(sourceFile, after)); }; + ChangeTracker.prototype.insertNodeAtEndOfList = function (sourceFile, list, newNode) { + this.insertNodeAt(sourceFile, list.end, newNode, { prefix: ", " }); + }; ChangeTracker.prototype.insertNodesAfter = function (sourceFile, after, newNodes) { var endPosition = this.insertNodeAfterWorker(sourceFile, after, ts.first(newNodes)); this.insertNodesAt(sourceFile, endPosition, newNodes, this.getInsertNodeAfterOptions(sourceFile, after)); @@ -102040,32 +102838,34 @@ var ts; return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { - if (ts.isClassDeclaration(node) || ts.isModuleDeclaration(node)) { - return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - } - else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { - return { suffix: this.newLineCharacter }; - } - else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { - return { prefix: ", " }; - } - else if (ts.isPropertyAssignment(node)) { - return { suffix: "," + this.newLineCharacter }; - } - else if (ts.isParameter(node)) { - return {}; + switch (node.kind) { + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; + case 235 /* VariableDeclaration */: + case 9 /* StringLiteral */: + case 71 /* Identifier */: + return { prefix: ", " }; + case 273 /* PropertyAssignment */: + return { suffix: "," + this.newLineCharacter }; + case 84 /* ExportKeyword */: + return { prefix: " " }; + case 149 /* Parameter */: + return {}; + default: + ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it + return { suffix: this.newLineCharacter }; } - return ts.Debug.failBadSyntaxKind(node); // We haven't handled this kind of node yet -- add it }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 193 /* ArrowFunction */) { + if (node.kind === 195 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(89 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); - this.deleteNode(sourceFile, arrow); + deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` @@ -102073,14 +102873,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); } - if (node.body.kind !== 213 /* Block */) { + if (node.body.kind !== 216 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 194 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -102106,7 +102906,7 @@ var ts; if (index !== containingList.length - 1) { // any element except the last one // use next sibling as an anchor - var nextToken = ts.getTokenAtPosition(sourceFile, after.end, /*includeJsDocComment*/ false); + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); if (nextToken && isSeparator(after, nextToken)) { // for list // a, b, c @@ -102211,14 +103011,25 @@ var ts; } }); }; - ChangeTracker.prototype.finishTrailingCommaAfterDeletingNodesInList = function () { + ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; - this.deletedNodesInLists.forEach(function (node) { + var deletedNodesInLists = new ts.NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + var _loop_21 = function (sourceFile, node) { + if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { + deleteDeclaration.deleteDeclaration(this_1, deletedNodesInLists, sourceFile, node); + } + }; + var this_1 = this; + for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { + var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; + _loop_21(sourceFile, node); + } + deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); var list = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (node !== ts.last(list)) return; - var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !_this.deletedNodesInLists.has(n); }, list.length - 2); + var lastNonDeletedIndex = ts.findLastIndex(list, function (n) { return !deletedNodesInLists.has(n); }, list.length - 2); if (lastNonDeletedIndex !== -1) { _this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) }); } @@ -102231,8 +103042,8 @@ var ts; * so we can only call this once and can't get the non-formatted text separately. */ ChangeTracker.prototype.getChanges = function (validate) { + this.finishDeleteDeclarations(); this.finishClassesWithNodesInsertedAtStart(); - this.finishTrailingCommaAfterDeletingNodesInList(); var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) { var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements; @@ -102329,8 +103140,8 @@ var ts; })(changesToText || (changesToText = {})); function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { - var change = changes[i]; - text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + var _a = changes[i], span = _a.span, newText = _a.newText; + text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); } return text; } @@ -102532,6 +103343,177 @@ var ts; return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } + var deleteDeclaration; + (function (deleteDeclaration_1) { + function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { + switch (node.kind) { + case 149 /* Parameter */: { + var oldFunction = node.parent; + if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { + // Lambdas with exactly one parameter are special because, after removal, there + // must be an empty parameter list (i.e. `()`) and this won't necessarily be the + // case if the parameter is simply removed (e.g. in `x => 1`). + var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, + /*parameters*/ undefined, // TODO: GH#18217 + oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); + // Drop leading and trailing trivia of the new function because we're only going + // to replace the span (vs the full span) of the old function - the old leading + // and trailing trivia will remain. + ts.suppressLeadingAndTrailingTrivia(newFunction); + changes.replaceNode(sourceFile, oldFunction, newFunction); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 247 /* ImportDeclaration */: + deleteNode(changes, sourceFile, node, + // For first import, leave header comment in place + node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); + break; + case 184 /* BindingElement */: + var pattern = node.parent; + var preserveComma = pattern.kind === 183 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + if (preserveComma) { + deleteNode(changes, sourceFile, node); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 235 /* VariableDeclaration */: + deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); + break; + case 148 /* TypeParameter */: { + var typeParameters = ts.getEffectiveTypeParameterDeclarations(node.parent); + if (typeParameters.length === 1) { + var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; + var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1); + var nextToken = ts.getTokenAtPosition(sourceFile, end); + ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); + ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); + changes.deleteNodeRange(sourceFile, previousToken, nextToken); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + } + case 251 /* ImportSpecifier */: + var namedImports = node.parent; + if (namedImports.elements.length === 1) { + deleteImportBinding(changes, sourceFile, namedImports); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + break; + case 249 /* NamespaceImport */: + deleteImportBinding(changes, sourceFile, node); + break; + default: + if (ts.isImportClause(node.parent) && node.parent.name === node) { + deleteDefaultImport(changes, sourceFile, node.parent); + } + else if (ts.isCallLikeExpression(node.parent)) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + else { + deleteNode(changes, sourceFile, node, node.kind === 25 /* SemicolonToken */ ? { useNonAdjustedEndPosition: true } : undefined); + } + } + } + deleteDeclaration_1.deleteDeclaration = deleteDeclaration; + function deleteDefaultImport(changes, sourceFile, importClause) { + if (!importClause.namedBindings) { + // Delete the whole import + deleteNode(changes, sourceFile, importClause.parent); + } + else { + // import |d,| * as ns from './file' + var start = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26 /* CommaToken */) { + // shift first non-whitespace position after comma to the start position of the node + var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); + changes.deleteRange(sourceFile, { pos: start, end: end }); + } + else { + deleteNode(changes, sourceFile, importClause.name); + } + } + } + function deleteImportBinding(changes, sourceFile, node) { + if (node.parent.name) { + // Delete named imports while preserving the default import + // import d|, * as ns| from './file' + // import d|, { a }| from './file' + var previousToken = ts.Debug.assertDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1)); + changes.deleteRange(sourceFile, { pos: previousToken.getStart(sourceFile), end: node.end }); + } + else { + // Delete the entire import declaration + // |import * as ns from './file'| + // |import { a } from './file'| + var importDecl = ts.getAncestor(node, 247 /* ImportDeclaration */); + deleteNode(changes, sourceFile, importDecl); + } + } + function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { + var parent = node.parent; + if (parent.kind === 272 /* CatchClause */) { + // TODO: There's currently no unused diagnostic for this, could be a suggestion + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 19 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 20 /* CloseParenToken */, sourceFile)); + return; + } + if (parent.declarations.length !== 1) { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + return; + } + var gp = parent.parent; + switch (gp.kind) { + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: + changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); + break; + case 223 /* ForStatement */: + deleteNode(changes, sourceFile, parent); + break; + case 217 /* VariableStatement */: + deleteNode(changes, sourceFile, gp); + break; + default: + ts.Debug.assertNever(gp); + } + } + })(deleteDeclaration || (deleteDeclaration = {})); + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + // Exported for tests only! (TODO: improve tests to not need this) + function deleteNode(changes, sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + changes.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + textChanges_3.deleteNode = deleteNode; + function deleteNodeInList(changes, deletedNodesInLists, sourceFile, node) { + var containingList = ts.Debug.assertDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile)); + var index = ts.indexOfNode(containingList, node); + ts.Debug.assert(index !== -1); + if (containingList.length === 1) { + deleteNode(changes, sourceFile, node); + return; + } + // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. + // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. + ts.Debug.assert(!deletedNodesInLists.has(node), "Deleting a node twice"); + deletedNodesInLists.add(node); + changes.deleteRange(sourceFile, { + pos: startPositionToDeleteNodeInList(sourceFile, node), + end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), + }); + } })(textChanges = ts.textChanges || (ts.textChanges = {})); })(ts || (ts = {})); /* @internal */ @@ -102587,15 +103569,14 @@ var ts; function createCombinedCodeActions(changes, commands) { return { changes: changes, commands: commands }; } + codefix.createCombinedCodeActions = createCombinedCodeActions; function createFileTextChanges(fileName, textChanges) { return { fileName: fileName, textChanges: textChanges }; } codefix.createFileTextChanges = createFileTextChanges; function codeFixAll(context, errorCodes, use) { var commands = []; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { - return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); - }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return eachDiagnostic(context, errorCodes, function (diag) { return use(t, diag, commands); }); }); return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } codefix.codeFixAll = codeFixAll; @@ -102608,6 +103589,7 @@ var ts; } } } + codefix.eachDiagnostic = eachDiagnostic; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -102658,7 +103640,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start); }); }, }); function makeChange(changeTracker, sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var decorator = ts.findAncestor(token, ts.isDecorator); ts.Debug.assert(!!decorator, "Expected position to be owned by a decorator."); var replacement = ts.createCall(decorator.expression, /*typeArguments*/ undefined, /*argumentsArray*/ undefined); @@ -102690,7 +103672,7 @@ var ts; }); }, }); function getDeclaration(file, pos) { - var name = ts.getTokenAtPosition(file, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(file, pos); // For an arrow function with no name, 'name' lands on the first parameter. return ts.tryCast(ts.isParameter(name.parent) ? name.parent.parent : name.parent, parameterShouldGetTypeFromJSDoc); } @@ -102737,24 +103719,24 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 232 /* VariableDeclaration */ || + node.kind === 235 /* VariableDeclaration */ || node.kind === 151 /* PropertySignature */ || node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return transformJSDocFunctionType(node); case 162 /* TypeReference */: return transformJSDocTypeReference(node); @@ -102778,7 +103760,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 288 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -102844,8 +103826,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, err) { return doChange(changes, err.file, err.start, context.program.getTypeChecker()); }); }, }); function doChange(changes, sourceFile, position, checker) { - var deletedNodes = []; - var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false)); + var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; @@ -102854,20 +103835,20 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); + changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { ts.copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 - deleteNode(precedingNode); + changes.delete(sourceFile, precedingNode); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + changes.delete(sourceFile, ctorDeclaration); } break; } @@ -102877,22 +103858,6 @@ var ts; ts.copyComments(ctorDeclaration, newClassDeclaration, sourceFile); // Because the preceding node could be touched, we need to insert nodes before delete nodes. changes.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration); - for (var _i = 0, deletedNodes_1 = deletedNodes; _i < deletedNodes_1.length; _i++) { - var _a = deletedNodes_1[_i], node = _a.node, inList = _a.inList; - if (inList) { - changes.deleteNodeInList(sourceFile, node); - } - else { - changes.deleteNode(sourceFile, node); - } - } - function deleteNode(node, inList) { - if (inList === void 0) { inList = false; } - // If parent node has already been deleted, do nothing - if (!deletedNodes.some(function (n) { return ts.isNodeDescendantOf(node, n.node); })) { - deletedNodes.push({ node: node, inList: inList }); - } - } function createClassElementsFromSymbol(symbol) { var memberElements = []; // all instance members are stored in the "member" array of symbol @@ -102930,15 +103895,15 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 216 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 219 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); + changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -102946,12 +103911,12 @@ var ts; ts.copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 193 /* ArrowFunction */: { + case 195 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 213 /* Block */) { + if (arrowFunctionBody.kind === 216 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -102979,7 +103944,7 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 194 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { @@ -103043,10 +104008,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -103099,20 +104064,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 187 /* CallExpression */: { + case 189 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -103154,8 +104119,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: { + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -103178,7 +104143,7 @@ var ts; if (ts.isExportsOrModuleExportsOrAlias(sourceFile, left)) { if (ts.isExportsOrModuleExportsOrAlias(sourceFile, right)) { // `const alias = module.exports;` or `module.exports = alias;` can be removed. - changes.deleteNode(sourceFile, assignment.parent); + changes.delete(sourceFile, assignment.parent); } else { var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right) @@ -103209,10 +104174,10 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 271 /* ShorthandPropertyAssignment */: - case 272 /* SpreadAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 275 /* SpreadAssignment */: return undefined; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); @@ -103269,7 +104234,7 @@ var ts; changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 25 /* SemicolonToken */, sourceFile); if (semi) - changes.deleteNode(sourceFile, semi, { useNonAdjustedEndPosition: true }); + changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` @@ -103280,7 +104245,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 192 /* FunctionExpression */: { + case 194 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -103288,10 +104253,10 @@ var ts; } } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -103309,7 +104274,7 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: { + case 182 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -103320,7 +104285,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 181 /* ArrayBindingPattern */: { + case 183 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -103403,11 +104368,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node; - case 182 /* BindingElement */: + case 184 /* BindingElement */: return parent.propertyName !== node; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -103466,7 +104431,7 @@ var ts; }); }, }); function getQualifiedName(sourceFile, pos) { - var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ true), ts.isQualifiedName); + var qualifiedName = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), ts.isQualifiedName); ts.Debug.assert(!!qualifiedName, "Expected position to be owned by a qualified name."); return ts.isIdentifier(qualifiedName.left) ? qualifiedName : undefined; } @@ -103511,7 +104476,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -103539,7 +104504,7 @@ var ts; } } function getHeritageClauseSymbolTable(classDeclaration, checker) { - var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var heritageClauseNode = ts.getEffectiveBaseTypeNode(classDeclaration); if (!heritageClauseNode) return ts.createSymbolTable(); var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); @@ -103553,42 +104518,109 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var ChangeTracker = ts.textChanges.ChangeTracker; + codefix.importFixId = "fixMissingImport"; + var errorCodes = [ + ts.Diagnostics.Cannot_find_name_0.code, + ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.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, + ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, + ]; codefix.registerCodeFix({ - errorCodes: [ - ts.Diagnostics.Cannot_find_name_0.code, - ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.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, - ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, - ], - getCodeActions: function (context) { return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(context) - : getActionsForNonUMDImport(context); }, - // TODO: GH#20315 - fixIds: [], - getAllCodeActions: ts.notImplemented, + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span; + var info = getFixesInfo(context, errorCode, span.start); + if (!info) + return undefined; + var fixes = info.fixes, symbolName = info.symbolName; + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference); }); + }, + fixIds: [codefix.importFixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, preferences = context.preferences; + // Namespace fixes don't conflict, so just build a list. + var addToNamespace = []; + // Keys are import clause node IDs. + var addToExisting = ts.createMap(); + // Keys are module specifiers. + var newImports = ts.createMap(); + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getFixesInfo(context, diag.code, diag.start); + if (!info || !info.fixes.length) + return; + var fixes = info.fixes, symbolName = info.symbolName; + var fix = ts.first(fixes); + switch (fix.kind) { + case 0 /* UseNamespace */: + addToNamespace.push(fix); + break; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + var key = String(ts.getNodeId(importClause)); + var entry = addToExisting.get(key); + if (!entry) { + addToExisting.set(key, entry = { importClause: importClause, defaultImport: undefined, namedImports: [] }); + } + if (importKind === 0 /* Named */) { + ts.pushIfUnique(entry.namedImports, symbolName); + } + else { + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + } + break; + } + case 2 /* AddNew */: { + var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind; + var entry = newImports.get(moduleSpecifier); + if (!entry) { + newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined }); + } + switch (importKind) { + case 1 /* Default */: + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + break; + case 0 /* Named */: + ts.pushIfUnique(entry.namedImports, symbolName); + break; + case 3 /* Equals */: + case 2 /* Namespace */: + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; + break; + } + break; + } + default: + ts.Debug.assertNever(fix); + } + }); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) { + var fix = addToNamespace_1[_i]; + addNamespaceQualifier(changes, sourceFile, fix); + } + addToExisting.forEach(function (_a) { + var importClause = _a.importClause, defaultImport = _a.defaultImport, namedImports = _a.namedImports; + doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports); + }); + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + newImports.forEach(function (imports, moduleSpecifier) { + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports); + }); + })); + }, }); - function createCodeAction(descriptionDiagnostic, diagnosticArgs, changes) { - // TODO: GH#20315 - return codefix.createCodeFixActionNoFixId("import", changes, [descriptionDiagnostic].concat(diagnosticArgs)); - } - function convertToImportCodeFixContext(context, symbolToken, symbolName) { - var program = context.program; - var checker = program.getTypeChecker(); - return { - host: context.host, - formatContext: context.formatContext, - sourceFile: context.sourceFile, - program: program, - checker: checker, - compilerOptions: program.getCompilerOptions(), - getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), - symbolName: symbolName, - symbolToken: symbolToken, - preferences: context.preferences, - }; - } + // Sorted with the preferred fix coming first. + var ImportFixKind; + (function (ImportFixKind) { + ImportFixKind[ImportFixKind["UseNamespace"] = 0] = "UseNamespace"; + ImportFixKind[ImportFixKind["AddToExisting"] = 1] = "AddToExisting"; + ImportFixKind[ImportFixKind["AddNew"] = 2] = "AddNew"; + })(ImportFixKind || (ImportFixKind = {})); var ImportKind; (function (ImportKind) { ImportKind[ImportKind["Named"] = 0] = "Named"; @@ -103596,13 +104628,13 @@ var ts; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; })(ImportKind || (ImportKind = {})); - function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, symbolToken, preferences) { + function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, checker, allSourceFiles, formatContext, symbolToken, preferences) { var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, checker, allSourceFiles); ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, exportInfos, host, preferences)).moduleSpecifier; - var ctx = { host: host, program: program, checker: checker, compilerOptions: compilerOptions, sourceFile: sourceFile, formatContext: formatContext, symbolName: symbolName, getCanonicalFileName: getCanonicalFileName, symbolToken: symbolToken, preferences: preferences }; - return { moduleSpecifier: moduleSpecifier, codeAction: ts.first(getCodeActionsForImport(exportInfos, ctx)) }; + var fix = ts.first(getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences)); + return { moduleSpecifier: moduleSpecifier, codeAction: codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences)) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, checker, allSourceFiles) { @@ -103622,23 +104654,16 @@ var ts; }); return result; } - function getCodeActionsForImport(exportInfos, context) { - var result = []; - getCodeActionsForImport_separateExistingAndNew(exportInfos, context, result, result); - return result; - } - function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, context.checker, context.sourceFile); }); - ts.append(useExisting, tryUseExistingNamespaceImport(existingImports, context, context.symbolToken, context.checker)); - var addToExisting = tryAddToExistingImport(existingImports, context); - if (addToExisting) { - useExisting.push(addToExisting); - } - else { // Don't bother providing an action to add a new import if we can add to an existing one. - getCodeActionsForAddImport(exportInfos, context, existingImports, addNew); - } - } - function tryUseExistingNamespaceImport(existingImports, context, symbolToken, checker) { + function getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences) { + var checker = program.getTypeChecker(); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var useNamespace = tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker); + var addToExisting = tryAddToExistingImport(existingImports); + // Don't bother providing an action to add a new import if we can add to an existing one. + var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); + return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + } + function tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -103655,29 +104680,31 @@ var ts; var declaration = _a.declaration; var namespace = getNamespaceImportName(declaration); if (namespace) { - var moduleSymbol = namespace && checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); - if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { - return getCodeActionForUseExistingNamespaceImport(namespace.text, context, symbolToken); + var moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { + return { kind: 0 /* UseNamespace */, namespacePrefix: namespace.text, symbolToken: symbolToken }; } } }); } - function tryAddToExistingImport(existingImports, context) { + function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 244 /* ImportDeclaration */ && declaration.importClause) { - var changes = tryUpdateExistingImport(context, declaration.importClause, importKind); - if (changes) { - var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); - return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [context.symbolName, moduleSpecifierWithoutQuotes], changes); - } - } + if (declaration.kind !== 247 /* ImportDeclaration */) + return undefined; + var importClause = declaration.importClause; + if (!importClause) + return undefined; + var name = importClause.name, namedBindings = importClause.namedBindings; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 250 /* NamedImports */) + ? { kind: 1 /* AddToExisting */, importClause: importClause, importKind: importKind } + : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 244 /* ImportDeclaration */) { + if (declaration.kind === 247 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 249 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -103688,141 +104715,61 @@ var ts; var imports = _b.imports; return ts.mapDefined(imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + return (i.kind === 247 /* ImportDeclaration */ || i.kind === 246 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } - function getCodeActionForNewImport(context, _a) { - var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; - var sourceFile = context.sourceFile, symbolName = context.symbolName, preferences = context.preferences; - var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); - var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifierWithoutQuotes, ts.getQuotePreference(sourceFile, preferences)); - var importDecl = importKind !== 3 /* Equals */ - ? ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, createImportClauseOfKind(importKind, symbolName), quotedModuleSpecifier) - : ts.createImportEqualsDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createIdentifier(symbolName), ts.createExternalModuleReference(quotedModuleSpecifier)); - var changes = ChangeTracker.with(context, function (t) { return ts.insertImport(t, sourceFile, importDecl); }); - // 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 separating code and import statements. - return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); - } - function createImportClauseOfKind(kind, symbolName) { - var id = ts.createIdentifier(symbolName); - switch (kind) { - case 1 /* Default */: - return ts.createImportClause(id, /*namedBindings*/ undefined); - case 2 /* Namespace */: - return ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(id)); - case 0 /* Named */: - return ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, id)])); - default: - ts.Debug.assertNever(kind); - } - } function getNewImportInfos(program, sourceFile, moduleSymbols, host, preferences) { var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var modulePathsGroups = ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences); - return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); + return modulePathsGroups.map(function (group) { return group.map(function (moduleSpecifier) { return ({ kind: 2 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }); }); }); }); // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together return ts.flatten(choicesForEachExportingModule.sort(function (a, b) { return ts.first(a).moduleSpecifier.length - ts.first(b).moduleSpecifier.length; })); } - function getCodeActionsForAddImport(exportInfos, ctx, existingImports, addNew) { + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); - var newImportInfos = existingDeclaration - ? [existingDeclaration] - : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.host, ctx.preferences); - for (var _i = 0, newImportInfos_1 = newImportInfos; _i < newImportInfos_1.length; _i++) { - var info = newImportInfos_1[_i]; - addNew.push(getCodeActionForNewImport(ctx, info)); - } + return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 244 /* ImportDeclaration */ + var expression = declaration.kind === 247 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 257 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; - return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; - } - function tryUpdateExistingImport(context, importClause, importKind) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - var name = importClause.name; - var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 - switch (importKind) { - case 1 /* Default */: - return name ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(ts.createIdentifier(symbolName), namedBindings)); - }); - case 0 /* Named */: { - var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - if (namedBindings && namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length !== 0) { - // There are already named imports; add another. - return ChangeTracker.with(context, function (t) { return t.insertNodeInListAfter(sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier_1); }); - } - if (!namedBindings || namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length === 0) { - return ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); - }); - } - return undefined; - } - case 2 /* Namespace */: - return namedBindings ? undefined : ChangeTracker.with(context, function (t) { - return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamespaceImport(ts.createIdentifier(symbolName)))); - }); - case 3 /* Equals */: - return undefined; - default: - ts.Debug.assertNever(importKind); - } + return expression && ts.isStringLiteral(expression) ? { kind: 2 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix, context, symbolToken) { - var symbolName = context.symbolName, sourceFile = context.sourceFile; - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - var changes = ChangeTracker.with(context, function (tracker) { - return tracker.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); - }); - return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); + function getFixesInfo(context, errorCode, pos) { + var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos); + var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getFixesInfoForUMDImport(context, symbolToken) + : getFixesInfoForNonUMDImport(context, symbolToken); + return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } - function getActionsForUMDImport(context) { - var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); - var checker = context.program.getTypeChecker(); - var umdSymbol; - if (ts.isIdentifier(token)) { - // try the identifier to see if it is the umd symbol - umdSymbol = checker.getSymbolAtLocation(token); - } - if (!ts.isUMDExportSymbol(umdSymbol)) { - // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. - var parent = token.parent; - var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(parent); - if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 260 /* JsxOpeningFragment */) { - umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); - } - } - if (ts.isUMDExportSymbol(umdSymbol)) { - var symbol = checker.getAliasedSymbol(umdSymbol); - if (symbol) { - return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(context.program.getCompilerOptions()) }], convertToImportCodeFixContext(context, token, umdSymbol.name)); - } - } - return undefined; + function getFixesInfoForUMDImport(_a, token) { + var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; + var checker = program.getTypeChecker(); + var umdSymbol = getUmdSymbol(token, checker); + if (!umdSymbol) + return undefined; + var symbol = checker.getAliasedSymbol(umdSymbol); + var symbolName = umdSymbol.name; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()) }]; + var fixes = getFixForImport(exportInfos, symbolName, token, program, sourceFile, host, preferences); + return { fixes: fixes, symbolName: symbolName }; + } + function getUmdSymbol(token, checker) { + // try the identifier to see if it is the umd symbol + var umdSymbol = ts.isIdentifier(token) ? checker.getSymbolAtLocation(token) : undefined; + if (ts.isUMDExportSymbol(umdSymbol)) + return umdSymbol; + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + var parent = token.parent; + return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67216319 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + : undefined; } function getUmdImportKind(compilerOptions) { // Import a synthetic `default` if enabled. @@ -103846,11 +104793,10 @@ var ts; return ts.Debug.assertNever(moduleKind); } } - function getActionsForNonUMDImport(context) { + function getFixesInfoForNonUMDImport(_a, symbolToken) { + var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. - var sourceFile = context.sourceFile, span = context.span, program = context.program, cancellationToken = context.cancellationToken; var checker = program.getTypeChecker(); - var symbolToken = ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false); // If we're at ``, we must check if `Foo` is already in scope, and if so, get an import for `React` instead. var symbolName = ts.isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken @@ -103860,14 +104806,14 @@ var ts; if (!symbolName) return undefined; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default"); - var addToExistingDeclaration = []; - var addNewDeclaration = []; - getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).forEach(function (exportInfos) { - getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); - }); - return addToExistingDeclaration.concat(addNewDeclaration); + ts.Debug.assert(symbolName !== "default" /* Default */); + var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + var _ = _a[0], exportInfos = _a[1]; + return getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences); + })); + return { fixes: fixes, symbolName: symbolName }; } + // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). @@ -103880,35 +104826,121 @@ var ts; // check the default export var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) { - var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); - if ((localSymbol && localSymbol.escapedName === symbolName || - getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target) === symbolName) && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { - addSymbol(moduleSymbol, localSymbol || defaultExport, 1 /* Default */); + var info = getDefaultExportInfo(defaultExport, moduleSymbol, program); + if (info && info.name === symbolName && symbolHasMeaning(info.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultExport, 1 /* Default */); } } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } - function getEscapedNameForExportDefault(symbol) { - return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { - if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.escapedText; - } + }); + return originalSymbolToExportInfos; + } + function getDefaultExportInfo(defaultExport, moduleSymbol, program) { + var checker = program.getTypeChecker(); + var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) + return { symbolForMeaning: localSymbol, name: localSymbol.name }; + var name = getNameForExportDefault(defaultExport); + if (name !== undefined) + return { symbolForMeaning: defaultExport, name: name }; + if (defaultExport.flags & 2097152 /* Alias */) { + var aliased = checker.getAliasedSymbol(defaultExport); + return getDefaultExportInfo(aliased, ts.Debug.assertDefined(aliased.parent), program); + } + else { + var moduleName = moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target); + return moduleName === undefined ? undefined : { symbolForMeaning: defaultExport, name: moduleName }; + } + } + function getNameForExportDefault(symbol) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + if (ts.isExportAssignment(declaration)) { + if (ts.isIdentifier(declaration.expression)) { + return declaration.expression.text; + } + } + else if (ts.isExportSpecifier(declaration)) { + ts.Debug.assert(declaration.name.text === "default" /* Default */); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } + function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) { + var diag; + var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { + diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference); + }); + return codefix.createCodeFixAction("import", changes, diag, codefix.importFixId, ts.Diagnostics.Add_all_missing_imports); + } + function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) { + switch (fix.kind) { + case 0 /* UseNamespace */: + addNamespaceQualifier(changes, sourceFile, fix); + return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; + case 1 /* AddToExisting */: { + var importClause = fix.importClause, importKind = fix.importKind; + doAddExistingFix(changes, sourceFile, importClause, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(importClause.parent.moduleSpecifier.getText()); + return [ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; + } + case 2 /* AddNew */: { + var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier; + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === 1 /* Default */ ? { defaultImport: symbolName, namedImports: ts.emptyArray, namespaceLikeImport: undefined } + : importKind === 0 /* Named */ ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined } + : { defaultImport: undefined, namedImports: ts.emptyArray, namespaceLikeImport: { importKind: importKind, name: symbolName } }); + return [ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; + } + default: + return ts.Debug.assertNever(fix); + } + } + function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { + if (defaultImport) { + ts.Debug.assert(!clause.name); + changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); + } + if (namedImports.length) { + var specifiers = namedImports.map(function (name) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); }); + if (clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements.length) { + for (var _i = 0, specifiers_1 = specifiers; _i < specifiers_1.length; _i++) { + var spec = specifiers_1[_i]; + changes.insertNodeInListAfter(sourceFile, ts.last(ts.cast(clause.namedBindings, ts.isNamedImports).elements), spec); + } + } + else { + if (specifiers.length) { + var namedImports_1 = ts.createNamedImports(specifiers); + if (clause.namedBindings) { + changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } - else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - return declaration.propertyName && declaration.propertyName.escapedText; + else { + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); } - }); + } } - }); - return originalSymbolToExportInfos; + } + } + function addNamespaceQualifier(changes, sourceFile, _a) { + var namespacePrefix = _a.namespacePrefix, symbolToken = _a.symbolToken; + changes.replaceNode(sourceFile, symbolToken, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), symbolToken)); + } + function addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, _a) { + var defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport; + var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); + if (defaultImport !== undefined || namedImports.length) { + ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); + } + if (namespaceLikeImport) { + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ + ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) + : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + } } - function checkSymbolHasMeaning(_a, meaning) { + function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } @@ -104009,7 +105041,7 @@ var ts; // This is the identifier of the misspelled word. eg: // this.speling = 1; // ^^^^^^^ - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); // TODO: GH#15852 + var node = ts.getTokenAtPosition(sourceFile, pos); var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { @@ -104081,46 +105113,99 @@ var ts; var info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, context.preferences); + if (info.kind === InfoKind.enum) { + var token_1 = info.token, parentDeclaration_1 = info.parentDeclaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), token_1, parentDeclaration_1); }); + return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_missing_enum_member_0, token_1.text], fixId, ts.Diagnostics.Add_all_missing_members)]; + } + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + var methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); var addMember = inJs ? - ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, token.text, makeStatic)) : - getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, classDeclaration, token, makeStatic); + ts.singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic)) : + getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, parentDeclaration, token, makeStatic); return ts.concatenate(ts.singleElementArray(methodCodeAction), addMember); }, fixIds: [fixId], getAllCodeActions: function (context) { - var seenNames = ts.createMap(); - return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var program = context.program, preferences = context.preferences; - var info = getInfo(diag.file, diag.start, program.getTypeChecker()); - if (!info) - return; - var classDeclaration = info.classDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - if (!ts.addToSeen(seenNames, token.text)) { - return; - } - // Always prefer to add a method declaration if possible. - if (call) { - addMethodDeclaration(changes, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, preferences); - } - else { - if (inJs) { - addMissingMemberInJs(changes, classDeclarationSourceFile, classDeclaration, token.text, makeStatic); + var program = context.program, preferences = context.preferences; + var checker = program.getTypeChecker(); + var seen = ts.createMap(); + var classToMembers = new ts.NodeMap(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(diag.file, diag.start, checker); + if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { + return; + } + if (info.kind === InfoKind.enum) { + var token = info.token, parentDeclaration = info.parentDeclaration; + addEnumMemberDeclaration(changes, checker, token, parentDeclaration); } else { - var typeNode = getTypeNode(program.getTypeChecker(), classDeclaration, token); - addPropertyDeclaration(changes, classDeclarationSourceFile, classDeclaration, token.text, typeNode, makeStatic); + var parentDeclaration = info.parentDeclaration, token_2 = info.token; + var infos = classToMembers.getOrUpdate(parentDeclaration, function () { return []; }); + if (!infos.some(function (i) { return i.token.text === token_2.text; })) + infos.push(info); } - } - }); + }); + classToMembers.forEach(function (infos, classDeclaration) { + var superClasses = getAllSuperClasses(classDeclaration, checker); + var _loop_23 = function (info) { + // If some superclass added this property, don't add it again. + if (superClasses.some(function (superClass) { + var superInfos = classToMembers.get(superClass); + return !!superInfos && superInfos.some(function (_a) { + var token = _a.token; + return token.text === info.token.text; + }); + })) + return "continue"; + var parentDeclaration = info.parentDeclaration, classDeclarationSourceFile = info.classDeclarationSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; + // Always prefer to add a method declaration if possible. + if (call) { + addMethodDeclaration(context, changes, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + } + else { + if (inJs) { + addMissingMemberInJs(changes, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic); + } + else { + var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token); + addPropertyDeclaration(changes, classDeclarationSourceFile, parentDeclaration, token.text, typeNode, makeStatic); + } + } + }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + _loop_23(info); + } + }); + })); }, }); + function getAllSuperClasses(cls, checker) { + var res = []; + while (cls) { + var superElement = ts.getClassExtendsHeritageElement(cls); + var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); + var superDecl = superSymbol && ts.find(superSymbol.declarations, ts.isClassLike); + if (superDecl) { + res.push(superDecl); + } + cls = superDecl; + } + return res; + } + var InfoKind; + (function (InfoKind) { + InfoKind[InfoKind["enum"] = 0] = "enum"; + InfoKind[InfoKind["class"] = 1] = "class"; + })(InfoKind || (InfoKind = {})); function getInfo(tokenSourceFile, tokenPos, checker) { // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ - var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(tokenSourceFile, tokenPos); if (!ts.isIdentifier(token)) { return undefined; } @@ -104129,14 +105214,21 @@ var ts; return undefined; var leftExpressionType = ts.skipConstraint(checker.getTypeAtLocation(parent.expression)); var symbol = leftExpressionType.symbol; - var classDeclaration = symbol && symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); - if (!classDeclaration) + if (!symbol || !symbol.declarations) return undefined; - var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); - var classDeclarationSourceFile = classDeclaration.getSourceFile(); - var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); - var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { token: token, classDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); + if (classDeclaration) { + var makeStatic = leftExpressionType.target !== checker.getDeclaredTypeOfSymbol(symbol); + var classDeclarationSourceFile = classDeclaration.getSourceFile(); + var inJs = ts.isSourceFileJavaScript(classDeclarationSourceFile); + var call = ts.tryCast(parent.parent, ts.isCallExpression); + return { kind: InfoKind.class, token: token, parentDeclaration: classDeclaration, makeStatic: makeStatic, classDeclarationSourceFile: classDeclarationSourceFile, inJs: inJs, call: call }; + } + var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); + if (enumDeclaration) { + return { kind: InfoKind.enum, token: token, parentDeclaration: enumDeclaration }; + } + return undefined; } function getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic); }); @@ -104145,7 +105237,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 205 /* ClassExpression */) { + if (classDeclaration.kind === 207 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -104171,7 +105263,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 200 /* BinaryExpression */) { + if (token.parent.parent.kind === 202 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); // TODO: GH#18217 @@ -104225,11 +105317,11 @@ var ts; return codefix.createCodeFixActionNoFixId(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]); } function getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, token.text], fixId, ts.Diagnostics.Add_all_missing_members); } - function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { - var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); + function addMethodDeclaration(context, changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { + var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences); var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); @@ -104238,6 +105330,19 @@ var ts; changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); } } + function addEnumMemberDeclaration(changes, checker, token, enumDeclaration) { + /** + * create initializer only literal enum that has string initializer. + * value of initializer is a string literal that equal to name of enum member. + * numeric enum or empty enum will not create initializer. + */ + var hasStringInitializer = ts.some(enumDeclaration.members, function (member) { + var type = checker.getTypeAtLocation(member); + return !!(type && type.flags & 68 /* StringLike */); + }); + var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); + changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104271,7 +105376,7 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function getTypesPackageNameToInstall(host, sourceFile, pos, diagCode) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), ts.isStringLiteral).text; + var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) @@ -104312,11 +105417,11 @@ var ts; function getClass(sourceFile, pos) { // Token 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, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.cast(token.parent, ts.isClassLike); } function addMissingMembers(classDeclaration, sourceFile, checker, changeTracker, preferences) { - var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var extendsNode = ts.getEffectiveBaseTypeNode(classDeclaration); var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. @@ -104366,10 +105471,10 @@ var ts; }); function doChange(changes, sourceFile, constructor, superCall) { changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall); - changes.deleteNode(sourceFile, superCall); + changes.delete(sourceFile, superCall); } function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); if (token.kind !== 99 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); @@ -104408,7 +105513,7 @@ var ts; }); }, }); function getNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 123 /* ConstructorKeyword */); return token.parent; } @@ -104444,7 +105549,7 @@ var ts; }); }, }); function getNodes(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); return extendsToken.kind === 85 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; @@ -104500,7 +105605,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos, diagCode) { - var node = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(node)) return undefined; return { node: node, className: diagCode === didYouMeanStaticMemberCode ? ts.getContainingClass(node).name.text : undefined }; @@ -104534,25 +105639,30 @@ var ts; getCodeActions: function (context) { var errorCode = context.errorCode, sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); - var startToken = ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); - var importDecl = tryGetFullImport(startToken); + var sourceFiles = program.getSourceFiles(); + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var importDecl = tryGetFullImport(token); if (importDecl) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, importDecl); }); return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteFullDestructure(token, t, sourceFile, checker, sourceFiles, /*isFixAll*/ false); + }); if (delDestructure.length) { return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(t, sourceFile, startToken, /*deleted*/ undefined); }); + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(sourceFile, token, t); }); if (delVar.length) { return [codefix.createCodeFixAction(fixName, delVar, ts.Diagnostics.Remove_variable_statement, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var token = getToken(sourceFile, ts.textSpanEnd(context.span)); var result = []; - var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { + return tryDeleteDeclaration(sourceFile, token, t, checker, sourceFiles, /*isFixAll*/ false); + }); if (deletion.length) { - result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); + var name = ts.isComputedPropertyName(token.parent) ? token.parent : token; + result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, name.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } var prefix = ts.textChanges.ChangeTracker.with(context, function (t) { return tryPrefixDeclaration(t, errorCode, sourceFile, token); }); if (prefix.length) { @@ -104562,32 +105672,28 @@ var ts; }, fixIds: [fixIdPrefix, fixIdDelete], getAllCodeActions: function (context) { - // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors. - var deleted = new ts.NodeSet(); var sourceFile = context.sourceFile, program = context.program; var checker = program.getTypeChecker(); + var sourceFiles = program.getSourceFiles(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); - var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); + var token = ts.getTokenAtPosition(sourceFile, diag.start); switch (context.fixId) { case fixIdPrefix: if (ts.isIdentifier(token) && canPrefix(token)) { tryPrefixDeclaration(changes, diag.code, sourceFile, token); } break; - case fixIdDelete: - // Ignore if this range was already deleted. - if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) - break; - var importDecl = tryGetFullImport(startToken); + case fixIdDelete: { + var importDecl = tryGetFullImport(token); if (importDecl) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } - else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && - !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); + else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(sourceFile, token, changes)) { + tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, /*isFixAll*/ true); } break; + } default: ts.Debug.fail(JSON.stringify(context.fixId)); } @@ -104595,49 +105701,29 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(startToken) { - return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; + function tryGetFullImport(token) { + return token.kind === 91 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { - if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) + function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { + if (token.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; - var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; - switch (decl.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(decl, checker, isFixAll)) - break; - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNodeInList(sourceFile, decl); - break; - case 182 /* BindingElement */: - if (deletedAncestors) - deletedAncestors.add(decl); - changes.deleteNode(sourceFile, decl); - break; - default: - return ts.Debug.assertNever(decl); + var decl = token.parent.parent; + if (decl.kind === 149 /* Parameter */) { + tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); + } + else { + changes.delete(sourceFile, decl); } return true; } - function tryDeleteFullVariableStatement(changes, sourceFile, startToken, deletedAncestors) { - var declarationList = ts.tryCast(startToken.parent, ts.isVariableDeclarationList); - if (declarationList && declarationList.getChildren(sourceFile)[0] === startToken) { - if (deletedAncestors) - deletedAncestors.add(declarationList); - changes.deleteNode(sourceFile, declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList); + function tryDeleteFullVariableStatement(sourceFile, token, changes) { + var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { + changes.delete(sourceFile, declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; } - function getToken(sourceFile, pos) { - var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true); - // this handles var ["computed"] = 12; - return token.kind === 22 /* CloseBracketToken */ ? ts.findPrecedingToken(pos - 1, sourceFile) : token; - } function tryPrefixDeclaration(changes, errorCode, sourceFile, token) { // Don't offer to prefix a property. if (errorCode !== ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code && ts.isIdentifier(token) && canPrefix(token)) { @@ -104648,209 +105734,61 @@ var ts; switch (token.parent.kind) { case 149 /* Parameter */: return true; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { - tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll); + function tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, isFixAll) { + tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll); if (ts.isIdentifier(token)) deleteAssignments(changes, sourceFile, token, checker); } function deleteAssignments(changes, sourceFile, token, checker) { ts.FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, function (ref) { - if (ref.parent.kind === 185 /* PropertyAccessExpression */) + if (ref.parent.kind === 187 /* PropertyAccessExpression */) ref = ref.parent; - if (ref.parent.kind === 200 /* BinaryExpression */ && ref.parent.parent.kind === 216 /* ExpressionStatement */) { - changes.deleteNode(sourceFile, ref.parent.parent); + if (ref.parent.kind === 202 /* BinaryExpression */ && ref.parent.parent.kind === 219 /* ExpressionStatement */) { + changes.delete(sourceFile, ref.parent.parent); } }); } - function tryDeleteDeclarationWorker(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { + function tryDeleteDeclarationWorker(token, changes, sourceFile, checker, sourceFiles, isFixAll) { var parent = token.parent; - switch (parent.kind) { - case 232 /* VariableDeclaration */: - tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); - break; - case 148 /* TypeParameter */: - var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent); - if (typeParameters.length === 1) { - var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; - var previousToken = ts.getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false); - var nextToken = ts.getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false); - ts.Debug.assert(previousToken.kind === 27 /* LessThanToken */); - ts.Debug.assert(nextToken.kind === 29 /* GreaterThanToken */); - changes.deleteNodeRange(sourceFile, previousToken, nextToken); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 149 /* Parameter */: - if (!mayDeleteParameter(parent, checker, isFixAll)) - break; - var oldFunction = parent.parent; - if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { - // Lambdas with exactly one parameter are special because, after removal, there - // must be an empty parameter list (i.e. `()`) and this won't necessarily be the - // case if the parameter is simply removed (e.g. in `x => 1`). - var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, // TODO: GH#18217 - oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); - // Drop leading and trailing trivia of the new function because we're only going - // to replace the span (vs the full span) of the old function - the old leading - // and trailing trivia will remain. - ts.suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceNode(sourceFile, oldFunction, newFunction); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 182 /* BindingElement */: { - var pattern = parent.parent; - var preserveComma = pattern.kind === 181 /* ArrayBindingPattern */ && parent !== ts.last(pattern.elements); - if (preserveComma) { - changes.deleteNode(sourceFile, parent); - } - else { - changes.deleteNodeInList(sourceFile, parent); - } - break; - } - // handle case where 'import a = A;' - case 243 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(token, 243 /* ImportEqualsDeclaration */); - changes.deleteNode(sourceFile, importEquals); - break; - case 248 /* ImportSpecifier */: - var namedImports = parent.parent; - if (namedImports.elements.length === 1) { - tryDeleteNamedImportBinding(changes, sourceFile, namedImports); - } - else { - // delete import specifier - changes.deleteNodeInList(sourceFile, parent); - } - break; - case 245 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' - var importClause = parent; - if (!importClause.namedBindings) { // |import d from './file'| - changes.deleteNode(sourceFile, ts.getAncestor(importClause, 244 /* ImportDeclaration */)); - } - else { - // import |d,| * as ns from './file' - var start = importClause.name.getStart(sourceFile); - var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end, /*includeJsDocComment*/ false); - if (nextToken && nextToken.kind === 26 /* CommaToken */) { - // shift first non-whitespace position after comma to the start position of the node - var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); - changes.deleteRange(sourceFile, { pos: start, end: end }); - } - else { - changes.deleteNode(sourceFile, importClause.name); - } - } - break; - case 246 /* NamespaceImport */: - tryDeleteNamedImportBinding(changes, sourceFile, parent); - break; - default: - if (ts.isDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent); - changes.deleteNode(sourceFile, token.parent); - } - else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - if (deletedAncestors) - deletedAncestors.add(token.parent.parent); - changes.deleteNode(sourceFile, token.parent.parent); - } - break; - } - } - function tryDeleteNamedImportBinding(changes, sourceFile, namedBindings) { - if (namedBindings.parent.name) { - // Delete named imports while preserving the default import - // import d|, * as ns| from './file' - // import d|, { a }| from './file' - var previousToken = ts.getTokenAtPosition(sourceFile, namedBindings.pos - 1, /*includeJsDocComment*/ false); - if (previousToken && previousToken.kind === 26 /* CommaToken */) { - changes.deleteRange(sourceFile, { pos: previousToken.getStart(), end: namedBindings.end }); - } + if (ts.isParameter(parent)) { + tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, isFixAll); } else { - // Delete the entire import declaration - // |import * as ns from './file'| - // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); - changes.deleteNode(sourceFile, importDecl); - } - } - // token.parent is a variableDeclaration - function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { - switch (varDecl.parent.parent.kind) { - case 220 /* ForStatement */: { - var forStatement = varDecl.parent.parent; - var forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(forInitializer); - changes.deleteNode(sourceFile, forInitializer); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } - break; - } - case 222 /* ForOfStatement */: - var forOfStatement = varDecl.parent.parent; - ts.Debug.assert(forOfStatement.initializer.kind === 233 /* VariableDeclarationList */); - var forOfInitializer = forOfStatement.initializer; - if (deletedAncestors) - deletedAncestors.add(forOfInitializer.declarations[0]); - changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral()); - break; - case 221 /* ForInStatement */: - case 230 /* TryStatement */: - break; - default: - var variableStatement = varDecl.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - if (deletedAncestors) - deletedAncestors.add(variableStatement); - changes.deleteNode(sourceFile, variableStatement); - } - else { - if (deletedAncestors) - deletedAncestors.add(varDecl); - changes.deleteNodeInList(sourceFile, varDecl); - } + changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); + } + } + function tryDeleteParameter(changes, sourceFile, p, checker, sourceFiles, isFixAll) { + if (mayDeleteParameter(p, checker, isFixAll)) { + changes.delete(sourceFile, p); + deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); } } function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { case 154 /* MethodDeclaration */: - // Don't remove a parameter if this overrides something + // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: { - // Can't remove a non-last parameter. Can remove a parameter in code-fix-all if future parameters are also unused. + case 237 /* FunctionDeclaration */: + return true; + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: { + // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); ts.Debug.assert(index !== -1); @@ -104865,6 +105803,14 @@ var ts; return ts.Debug.failBadSyntaxKind(parent); } } + function deleteUnusedArguments(changes, sourceFile, deletedParameter, sourceFiles, checker) { + ts.FindAllReferences.Core.eachSignatureCall(deletedParameter.parent, sourceFiles, checker, function (call) { + var index = deletedParameter.parent.parameters.indexOf(deletedParameter); + if (call.arguments.length > index) { // Just in case the call didn't provide enough arguments. + changes.delete(sourceFile, call.arguments[index]); + } + }); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -104884,12 +105830,12 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -104900,16 +105846,16 @@ var ts; break; } // falls through - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - changes.deleteNode(sourceFile, container); + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + changes.delete(sourceFile, container); break; default: if (ts.isBlock(statement.parent)) { split(sliceAfter(statement.parent.statements, statement), shouldRemove, function (start, end) { return changes.deleteNodeRange(sourceFile, start, end); }); } else { - changes.deleteNode(sourceFile, statement); + changes.delete(sourceFile, statement); } } } @@ -104921,12 +105867,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -104960,7 +105906,7 @@ var ts; getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return doChange(changes, diag.file, diag.start); }); }, }); function doChange(changes, sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var labeledStatement = ts.cast(token.parent, ts.isLabeledStatement); var pos = token.getStart(sourceFile); var statementPos = labeledStatement.statement.getStart(sourceFile); @@ -104990,7 +105936,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 281 /* JSDocNullableType */) { + if (typeNode.kind === 284 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -105010,7 +105956,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; + var fixedType = typeNode.kind === 284 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -105019,7 +105965,7 @@ var ts; changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); // TODO: GH#18217 } function getInfo(sourceFile, pos, checker) { - var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), isTypeContainer); + var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), isTypeContainer); var typeNode = decl && decl.type; return typeNode && { typeNode: typeNode, type: checker.getTypeFromTypeNode(typeNode) }; } @@ -105027,22 +105973,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 208 /* AsExpression */: + case 210 /* AsExpression */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 156 /* GetAccessor */: case 160 /* IndexSignature */: - case 177 /* MappedType */: + case 179 /* MappedType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: - case 190 /* TypeAssertionExpression */: - case 232 /* VariableDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 192 /* TypeAssertionExpression */: + case 235 /* VariableDeclaration */: return true; default: return false; @@ -105089,7 +106035,7 @@ var ts; } } function getNodes(sourceFile, start) { - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var containingFunction = ts.getContainingFunction(token); if (!containingFunction) { return; @@ -105099,11 +106045,11 @@ var ts; case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -105273,8 +106219,22 @@ var ts; signatureDeclaration.body = body; return signatureDeclaration; } - function createMethodFromCallExpression(_a, methodName, inJs, makeStatic, preferences) { + function createMethodFromCallExpression(context, _a, methodName, inJs, makeStatic, preferences) { var typeArguments = _a.typeArguments, args = _a.arguments, parent = _a.parent; + var checker = context.program.getTypeChecker(); + var types = ts.map(args, function (arg) { + var type = checker.getTypeAtLocation(arg); + if (type === undefined) { + return undefined; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + type = checker.getBaseTypeOfLiteralType(type); + return checker.typeToTypeNode(type); + }); + var names = ts.map(args, function (arg) { + return ts.isIdentifier(arg) ? arg.text : + ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + }); return ts.createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, @@ -105283,11 +106243,11 @@ var ts; /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); }), - /*parameters*/ createDummyParameters(args.length, /*names*/ undefined, /*minArgumentCount*/ undefined, inJs), + /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), createStubbedMethodBody(preferences)); } codefix.createMethodFromCallExpression = createMethodFromCallExpression; - function createDummyParameters(argCount, names, minArgumentCount, inJs) { + function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; for (var i = 0; i < argCount; i++) { var newParameter = ts.createParameter( @@ -105296,7 +106256,7 @@ var ts; /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : ts.createKeywordTypeNode(119 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(119 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -105322,7 +106282,7 @@ var ts; } var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); - var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*inJs*/ false); + var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); var restParameter = ts.createParameter( @@ -105386,18 +106346,19 @@ var ts; if (ts.isSourceFileJavaScript(sourceFile)) { return undefined; // TODO: GH#20113 } - var token = ts.getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, start); var declaration; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeenseen*/ ts.returnTrue); }); - return changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getNameOfDeclaration(declaration).getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start, /*includeJsDocComment*/ false), err.code, program, cancellationToken, markSeen); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen); }); }, }); @@ -105479,11 +106440,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: return true; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return !!declaration.name; } return false; @@ -105543,8 +106504,8 @@ var ts; function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? @@ -105612,21 +106573,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -105634,13 +106595,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -105749,7 +106710,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 235 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -105777,7 +106738,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 187 /* CallExpression */) { + if (parent.kind === 189 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -105945,8 +106906,8 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 187 /* CallExpression */ : 188 /* NewExpression */; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 189 /* CallExpression */ : 190 /* NewExpression */; + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -105973,7 +106934,7 @@ var ts; }); function getActionsForInvalidImportLocation(context) { var sourceFile = context.sourceFile; - var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); + var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } @@ -106048,7 +107009,7 @@ var ts; }, }); function getPropertyDeclaration(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined; } function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) { @@ -106133,7 +107094,7 @@ var ts; : ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, name, ts.createExternalModuleReference(required))); } function getInfo(sourceFile, pos) { - var parent = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false).parent; + var parent = ts.getTokenAtPosition(sourceFile, pos).parent; if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ true)) throw ts.Debug.failBadSyntaxKind(parent); var decl = ts.cast(parent.parent, ts.isVariableDeclaration); @@ -106166,7 +107127,7 @@ var ts; }); }, }); function getInfo(sourceFile, pos) { - var name = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var name = ts.getTokenAtPosition(sourceFile, pos); if (!ts.isIdentifier(name)) return undefined; // bad input var parent = name.parent; @@ -106190,7 +107151,7 @@ var ts; (function (codefix) { var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof"; var fixId = fixIdAddMissingTypeof; - var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code]; + var errorCodes = [ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { @@ -106205,9 +107166,9 @@ var ts; }); }, }); function getImportTypeNode(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 179 /* ImportType */); + ts.Debug.assert(token.parent.kind === 181 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -106243,7 +107204,7 @@ var ts; }); } }); function getInfo(sourceFile, pos) { - var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var token = ts.getTokenAtPosition(sourceFile, pos); var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); if (ts.isClassDeclaration(indexSignature.parent)) return undefined; @@ -106272,129 +107233,325 @@ var ts; (function (ts) { var refactor; (function (refactor) { - var generateGetAccessorAndSetAccessor; - (function (generateGetAccessorAndSetAccessor) { - var refactorName = "Convert import"; - var actionNameNamespaceToNamed = "Convert namespace import to named imports"; - var actionNameNamedToNamespace = "Convert named imports to namespace import"; - refactor.registerRefactor(refactorName, { - getAvailableActions: function (context) { - var i = getImportToConvert(context); - if (!i) + var refactorName = "Convert export"; + var actionNameDefaultToNamed = "Convert default export to named export"; + var actionNameNamedToDefault = "Convert named export to default export"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var info = getInfo(context); + if (!info) + return undefined; + var description = info.wasDefault ? ts.Diagnostics.Convert_default_export_to_named_export.message : ts.Diagnostics.Convert_named_export_to_default_export.message; + var actionName = info.wasDefault ? actionNameDefaultToNamed : actionNameNamedToDefault; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + }, + }); + function getInfo(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var exportNode = ts.getParentNodeInSpan(token, file, span); + if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { + return undefined; + } + var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; + var flags = ts.getModifierFlags(exportNode); + var wasDefault = !!(flags & 512 /* Default */); + // If source file already has a default export, don't offer refactor. + if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + return undefined; + } + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: { + var node = exportNode; + return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + } + case 217 /* VariableStatement */: { + var vs = exportNode; + // Must be `export const x = something;`. + if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { return undefined; - var description = i.kind === 246 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 246 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; - return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; - }, - getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); - return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + var decl = ts.first(vs.declarationList.declarations); + if (!decl.initializer) + return undefined; + ts.Debug.assert(!wasDefault); + return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - }); - // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. - function getImportToConvert(context) { - var file = context.file; - var span = ts.getRefactorContextSpan(context); - var token = ts.getTokenAtPosition(file, span.start, /*includeJsDocComment*/ false); - var importDecl = ts.getParentNodeInSpan(token, file, span); - if (!importDecl || !ts.isImportDeclaration(importDecl)) + default: return undefined; - var importClause = importDecl.importClause; - return importClause && importClause.namedBindings; } - function doChange(sourceFile, program, changes, toConvert) { - var checker = program.getTypeChecker(); - if (toConvert.kind === 246 /* NamespaceImport */) { - doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + function doChange(exportingSourceFile, program, info, changes, cancellationToken) { + changeExport(exportingSourceFile, info, changes, program.getTypeChecker()); + changeImports(program, info, changes, cancellationToken); + } + function changeExport(exportingSourceFile, _a, changes, checker) { + var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; + if (wasDefault) { + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 79 /* DefaultKeyword */))); + } + else { + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* ExportKeyword */)); + switch (exportNode.kind) { + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(79 /* DefaultKeyword */)); + break; + case 217 /* VariableStatement */: + // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` + if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { + // We checked in `getInfo` that an initializer exists. + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + break; + } + // falls through + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: + // `export type T = number;` -> `type T = number; export default T;` + changes.deleteModifier(exportingSourceFile, exportKeyword); + changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); + break; + default: + ts.Debug.assertNever(exportNode); + } + } + } + function changeImports(program, _a, changes, cancellationToken) { + var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; + var checker = program.getTypeChecker(); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { + var importingSourceFile = ref.getSourceFile(); + if (wasDefault) { + changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName.text); } else { - doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + changeNamedToDefaultImport(importingSourceFile, ref, changes); } - } - function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { - var usedAsNamespaceOrDefault = false; - var nodesToReplace = []; - var conflictingNames = ts.createMap(); - ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { - if (!ts.isPropertyAccessExpression(id.parent)) { - usedAsNamespaceOrDefault = true; + }); + } + function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.default` --> `a.foo` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + // `default as foo` --> `foo`, `default as bar` --> `foo as bar` + changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); + break; + } + case 248 /* ImportClause */: { + var clause = parent; + ts.Debug.assert(clause.name === ref); + var spec = makeImportSpecifier(exportName, ref.text); + var namedBindings = clause.namedBindings; + if (!namedBindings) { + // `import foo from "./a";` --> `import { foo } from "./a";` + changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); + } + else if (namedBindings.kind === 249 /* NamespaceImport */) { + // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` + changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); + changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } else { - var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); - var exportName = parent.name.text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { - conflictingNames.set(exportName, true); - } - ts.Debug.assert(parent.expression === id); - nodesToReplace.push(parent); + // `import foo, { bar } from "./a"` --> `import { bar, foo } from "./a";` + changes.delete(importingSourceFile, ref); + changes.insertNodeAtEndOfList(importingSourceFile, namedBindings.elements, spec); } - }); - // We may need to change `mod.x` to `_x` to avoid a name conflict. - var exportNameToImportName = ts.createMap(); - for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { - var propertyAccess = nodesToReplace_1[_i]; - var exportName = propertyAccess.name.text; - var importName = exportNameToImportName.get(exportName); - if (importName === undefined) { - exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); - } - changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); - } - var importSpecifiers = []; - exportNameToImportName.forEach(function (name, propertyName) { - importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); - }); - var importDecl = toConvert.parent.parent; - if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { - // Need to leave the namespace import alone - changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); - } - else { - changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); + break; } + default: + ts.Debug.failBadSyntaxKind(parent); } - function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { - var importDecl = toConvert.parent.parent; - var moduleSpecifier = importDecl.moduleSpecifier; - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; - var namespaceNameConflicts = toConvert.elements.some(function (element) { - return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { - return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); - }) || false; - }); - var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; - var neededNamedImports = []; - var _loop_23 = function (element) { - var propertyName = (element.propertyName || element.name).text; - ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { - var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); - if (ts.isShorthandPropertyAssignment(id.parent)) { - changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); - } - else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { - if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { - neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); - } + } + function changeNamedToDefaultImport(importingSourceFile, ref, changes) { + var parent = ref.parent; + switch (parent.kind) { + case 187 /* PropertyAccessExpression */: + // `a.foo` --> `a.default` + changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); + break; + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: { + var spec = parent; + if (spec.kind === 251 /* ImportSpecifier */) { + // `import { foo } from "./a";` --> `import foo from "./a";` + // `import { foo as bar } from "./a";` --> `import bar from "./a";` + var defaultImport = ts.createIdentifier(spec.name.text); + if (spec.parent.elements.length === 1) { + changes.replaceNode(importingSourceFile, spec.parent, defaultImport); } else { - changes.replaceNode(sourceFile, id, access); + changes.delete(importingSourceFile, spec); + changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); } - }); - }; - for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { - var element = _a[_i]; - _loop_23(element); + } + else { + // `export { foo } from "./a";` --> `export { default as foo } from "./a";` + // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` + // `export { foo as default } from "./a";` --> `export { default } from "./a";` + // (Because `export foo from "./a";` isn't valid syntax.) + changes.replaceNode(importingSourceFile, spec, makeExportSpecifier("default", spec.name.text)); + } + break; + } + default: + ts.Debug.failBadSyntaxKind(parent); + } + } + function makeImportSpecifier(propertyName, name) { + return ts.createImportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + function makeExportSpecifier(propertyName, name) { + return ts.createExportSpecifier(propertyName === name ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name)); + } + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var refactorName = "Convert import"; + var actionNameNamespaceToNamed = "Convert namespace import to named imports"; + var actionNameNamedToNamespace = "Convert named imports to namespace import"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var i = getImportToConvert(context); + if (!i) + return undefined; + var description = i.kind === 249 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 249 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + }); + // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. + function getImportToConvert(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start); + var importDecl = ts.getParentNodeInSpan(token, file, span); + if (!importDecl || !ts.isImportDeclaration(importDecl)) + return undefined; + var importClause = importDecl.importClause; + return importClause && importClause.namedBindings; + } + function doChange(sourceFile, program, changes, toConvert) { + var checker = program.getTypeChecker(); + if (toConvert.kind === 249 /* NamespaceImport */) { + doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + else { + doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + } + } + function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { + var usedAsNamespaceOrDefault = false; + var nodesToReplace = []; + var conflictingNames = ts.createMap(); + ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { + if (!ts.isPropertyAccessExpression(id.parent)) { + usedAsNamespaceOrDefault = true; } - changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); - if (neededNamedImports.length) { - changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + else { + var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); + var exportName = parent.name.text; + if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + conflictingNames.set(exportName, true); + } + ts.Debug.assert(parent.expression === id); + nodesToReplace.push(parent); } + }); + // We may need to change `mod.x` to `_x` to avoid a name conflict. + var exportNameToImportName = ts.createMap(); + for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { + var propertyAccess = nodesToReplace_1[_i]; + var exportName = propertyAccess.name.text; + var importName = exportNameToImportName.get(exportName); + if (importName === undefined) { + exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); + } + changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); + } + var importSpecifiers = []; + exportNameToImportName.forEach(function (name, propertyName) { + importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); + }); + var importDecl = toConvert.parent.parent; + if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { + // Need to leave the namespace import alone + changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); } - function updateImport(old, defaultImportName, elements) { - return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + else { + changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); } - })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + } + function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { + var importDecl = toConvert.parent.parent; + var moduleSpecifier = importDecl.moduleSpecifier; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; + var namespaceNameConflicts = toConvert.elements.some(function (element) { + return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + }) || false; + }); + var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; + var neededNamedImports = []; + var _loop_24 = function (element) { + var propertyName = (element.propertyName || element.name).text; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); + if (ts.isShorthandPropertyAssignment(id.parent)) { + changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); + } + else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { + if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { + neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); + } + } + else { + changes.replaceNode(sourceFile, id, access); + } + }); + }; + for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { + var element = _a[_i]; + _loop_24(element); + } + changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); + if (neededNamedImports.length) { + changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + } + } + function updateImport(old, defaultImportName, elements) { + return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); /* @internal */ @@ -106552,7 +107709,7 @@ var ts; } // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start), sourceFile, span); // Do the same for the ending position var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; @@ -106705,7 +107862,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 235 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -106717,13 +107874,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 97 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 187 /* CallExpression */) { + if (node.parent.kind === 189 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -106738,8 +107895,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -106751,20 +107908,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 217 /* IfStatement */: + case 220 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 213 /* Block */: - if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { + case 216 /* Block */: + if (node.parent && node.parent.kind === 233 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -106776,11 +107933,11 @@ var ts; break; } switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -106788,8 +107945,8 @@ var ts; seenLabels.pop(); break; } - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: { var label = node.label; if (label) { @@ -106799,20 +107956,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 227 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -106877,7 +108034,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 274 /* SourceFile */) { + if (current.kind === 277 /* SourceFile */) { return scopes; } } @@ -106969,12 +108126,12 @@ var ts; switch (scope.kind) { case 155 /* Constructor */: return "constructor"; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return "arrow function"; case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); @@ -106987,12 +108144,12 @@ var ts; } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 235 /* ClassDeclaration */ + return scope.kind === 238 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 240 /* ModuleBlock */ + return scope.kind === 243 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -107271,7 +108428,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 216 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 219 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.createVariableStatement( @@ -107290,9 +108447,9 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 216 /* ExpressionStatement */) { + if (node.parent.kind === 219 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. - changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); + changeTracker.delete(context.file, node.parent); } else { var localReference = ts.createIdentifier(localNameText); @@ -107377,7 +108534,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 228 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -107555,7 +108712,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 234 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 237 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -107618,7 +108775,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_24 = function (i) { + var _loop_25 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -107658,7 +108815,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_24(i); + _loop_25(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -107871,30 +109028,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 273 /* EnumMember */: + case 276 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return parent.kind !== 244 /* ImportDeclaration */ && - parent.kind !== 248 /* ImportSpecifier */; - case 204 /* SpreadElement */: - case 180 /* ObjectBindingPattern */: - case 182 /* BindingElement */: + return parent.kind !== 247 /* ImportDeclaration */ && + parent.kind !== 251 /* ImportSpecifier */; + case 206 /* SpreadElement */: + case 182 /* ObjectBindingPattern */: + case 184 /* BindingElement */: return false; case 71 /* Identifier */: - return parent.kind !== 182 /* BindingElement */ && - parent.kind !== 248 /* ImportSpecifier */ && - parent.kind !== 252 /* ExportSpecifier */; + return parent.kind !== 184 /* BindingElement */ && + parent.kind !== 251 /* ImportSpecifier */ && + parent.kind !== 255 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 213 /* Block */: - case 274 /* SourceFile */: - case 240 /* ModuleBlock */: - case 266 /* CaseClause */: + case 216 /* Block */: + case 277 /* SourceFile */: + case 243 /* ModuleBlock */: + case 269 /* CaseClause */: return true; default: return false; @@ -107914,8 +109071,7 @@ var ts; var actionDescription = ts.Diagnostics.Generate_get_and_set_accessors.message; refactor.registerRefactor(actionName, { getEditsForAction: getEditsForAction, getAvailableActions: getAvailableActions }); function getAvailableActions(context) { - var file = context.file; - if (!getConvertibleFieldAtPosition(context, file)) + if (!getConvertibleFieldAtPosition(context)) return undefined; return [{ name: actionName, @@ -107930,7 +109086,7 @@ var ts; } function getEditsForAction(context, _actionName) { var file = context.file; - var fieldInfo = getConvertibleFieldAtPosition(context, file); + var fieldInfo = getConvertibleFieldAtPosition(context); if (!fieldInfo) return undefined; var isJS = ts.isSourceFileJavaScript(file); @@ -107991,13 +109147,13 @@ var ts; function startsWithUnderscore(name) { return name.charCodeAt(0) === 95 /* _ */; } - function getConvertibleFieldAtPosition(context, file) { - var startPosition = context.startPosition, endPosition = context.endPosition; - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + function getConvertibleFieldAtPosition(context) { + var file = context.file, startPosition = context.startPosition, endPosition = context.endPosition; + var node = ts.getTokenAtPosition(file, startPosition); var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; - if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) // TODO: GH#18217 + if (!declaration || !ts.nodeOverlapsWithStartEnd(declaration.name, file, startPosition, endPosition) // TODO: GH#18217 || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; @@ -108152,11 +109308,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return true; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -108209,10 +109365,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_25 = function (sourceFile) { + var _loop_26 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_26 = function (statement) { + var _loop_27 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -108234,22 +109390,22 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_26(statement); + _loop_27(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_25(sourceFile); + _loop_26(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + case 247 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 249 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node.name; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node); @@ -108280,20 +109436,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 247 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 246 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -108363,15 +109519,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -108384,23 +109540,23 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 249 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } else { if (name && defaultUnused) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } if (namedBindings) { if (namedBindingsUnused) { - changes.deleteNode(sourceFile, namedBindings); + changes.delete(sourceFile, namedBindings); } - else if (namedBindings.kind === 247 /* NamedImports */) { + else if (namedBindings.kind === 250 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) - changes.deleteNodeInList(sourceFile, element); + changes.delete(sourceFile, element); } } } @@ -108411,20 +109567,20 @@ var ts; switch (name.kind) { case 71 /* Identifier */: if (isUnused(name)) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { - changes.deleteNode(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); + changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } else { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (ts.isIdentifier(element.name) && isUnused(element.name)) { - changes.deleteNode(sourceFile, element.name); + changes.delete(sourceFile, element.name); } } } @@ -108521,13 +109677,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 243 /* ImportEqualsDeclaration */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: return true; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -108539,7 +109695,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -108549,9 +109705,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -108560,7 +109716,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 246 /* NamespaceImport */) { + if (namedBindings.kind === 249 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -108572,9 +109728,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return name; - case 180 /* ObjectBindingPattern */: { + case 182 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.createObjectBindingPattern(newElements) : undefined; @@ -108631,13 +109787,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -108645,17 +109801,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return cb(statement); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 216 /* ExpressionStatement */: { + case 219 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -108664,7 +109820,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 219 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -108696,23 +109852,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -108723,18 +109879,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(decl); @@ -108809,7 +109965,7 @@ var ts; return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */ || ts.isObjectLiteralExpression(expression); } function getConvertibleArrowFunctionAtPosition(file, startPosition) { - var node = ts.getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); + var node = ts.getTokenAtPosition(file, startPosition); var func = ts.getContainingFunction(node); if (!func || !ts.isArrowFunction(func) || (!ts.rangeContainsRange(func, node) || ts.rangeContainsRange(func.body, node))) return undefined; @@ -108915,7 +110071,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 299 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 281 /* FirstJSDocNode */ || kid.kind > 302 /* LastJSDocNode */; }); return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -108985,7 +110141,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(300 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(303 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -109042,7 +110198,7 @@ var ts; return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { - return ts.emptyArray; + return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -109296,7 +110452,7 @@ var ts; }; SourceFileObject.prototype.computeNamedDeclarations = function () { var result = ts.createMultiMap(); - ts.forEachChild(this, visit); + this.forEachChild(visit); return result; function addDeclaration(declaration) { var name = getDeclarationName(declaration); @@ -109312,14 +110468,14 @@ var ts; return declarations; } function getDeclarationName(declaration) { - var name = ts.getNameOfDeclaration(declaration); + var name = ts.getNonAssignedNameOfDeclaration(declaration); return name && (ts.isComputedPropertyName(name) && ts.isPropertyAccessExpression(name.expression) ? name.expression.name.text : ts.isPropertyName(name) ? ts.getNameFromPropertyName(name) : undefined); } function visit(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: var functionDeclaration = node; @@ -109341,17 +110497,17 @@ var ts; } ts.forEachChild(node, visit); break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 252 /* ExportSpecifier */: - case 248 /* ImportSpecifier */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 255 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 166 /* TypeLiteral */: @@ -109364,8 +110520,8 @@ var ts; break; } // falls through - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: { + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -109376,31 +110532,31 @@ var ts; } } // falls through - case 273 /* EnumMember */: + case 276 /* EnumMember */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: addDeclaration(node); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addDeclaration(importClause); + addDeclaration(importClause.name); } // Handle named bindings in imports e.g.: // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -109409,7 +110565,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -109777,7 +110933,7 @@ var ts; readFile: function (fileName) { // stub missing host functionality var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); if (entry) { return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot); } @@ -109827,7 +110983,7 @@ var ts; return; function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var entry = hostCache.getEntryByPath(path); + var entry = hostCache && hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : (!!host.fileExists && host.fileExists(fileName)); @@ -109842,11 +110998,11 @@ var ts; return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); } function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { - ts.Debug.assert(hostCache !== undefined); + ts.Debug.assert(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined // to the program to allow reporting of errors for missing files. - var hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path); + var hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path); if (!hostFileInformation) { return undefined; } @@ -109942,17 +111098,17 @@ var ts; return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { - if (options === void 0) { options = ts.defaultPreferences; } + if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 - getCanonicalFileName, preferences, cancellationToken); + preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -109977,10 +111133,10 @@ var ts; return undefined; } // falls through - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_4 = typeChecker.getTypeAtLocation(node); @@ -110025,7 +111181,8 @@ var ts; return file.getLineAndCharacterOfPosition(position); } // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; + var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; var base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; function scanForSourcemapURL(fileName) { var mappedFile = sourcemappedFileCache.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); @@ -110034,11 +111191,15 @@ var ts; } var starts = ts.getLineStarts(mappedFile); for (var index = starts.length - 1; index >= 0; index--) { - sourceMapCommentRegExp.lastIndex = starts[index]; - var comment = sourceMapCommentRegExp.exec(mappedFile.text); + var lineText = mappedFile.text.substring(starts[index], starts[index + 1]); + var comment = sourceMapCommentRegExp.exec(lineText); if (comment) { return comment[1]; } + // If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!lineText.match(whitespaceOrMapCommentRegExp)) { + break; + } } } function convertDocumentToSourceMapper(file, contents, mapFileName) { @@ -110192,18 +111353,32 @@ var ts; return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } function findRenameLocations(fileName, position, findInStrings, findInComments) { - return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (ts.isIdentifier(node) && ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) { + var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; + return [openingElement, closingElement].map(function (node) { return ({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node.tagName, sourceFile) }); }); + } + else { + var refs = getReferences(node, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); + return refs && refs.map(function (_a) { + var fileName = _a.fileName, textSpan = _a.textSpan; + return ({ fileName: fileName, textSpan: textSpan }); + }); + } } function getReferencesAtPosition(fileName, position) { - return getReferences(fileName, position); + synchronizeHostData(); + return getReferences(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position); } - function getReferences(fileName, position, options) { + function getReferences(node, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. var sourceFiles = options && options.isForRename ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); - return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, node, position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -110227,10 +111402,11 @@ var ts; /** * This is a semantic operation. */ - function getSignatureHelpItems(fileName, position) { + function getSignatureHelpItems(fileName, position, _a) { + var triggerReason = (_a === void 0 ? ts.emptyOptions : _a).triggerReason; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); } /// Syntactic features function getNonBoundSourceFile(fileName) { @@ -110244,7 +111420,7 @@ var ts; return undefined; } switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: @@ -110252,7 +111428,7 @@ var ts; case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 174 /* ThisType */: + case 176 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span @@ -110269,7 +111445,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 === 239 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 242 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -110339,7 +111515,7 @@ var ts; braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var token = ts.getTouchingToken(sourceFile, position, /*includeJsDocComment*/ false); + var token = ts.getTouchingToken(sourceFile, position); var matchKind = token.getStart(sourceFile) === position ? braceMatching.get(token.kind.toString()) : undefined; var match = matchKind && ts.findChildOfKind(token.parent, matchKind, sourceFile); // We want to order the braces when we return the result. @@ -110380,7 +111556,7 @@ var ts; return []; } function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = ts.createTextSpanFromBounds(start, end); @@ -110391,7 +111567,7 @@ var ts; }); } function getCombinedCodeFix(scope, fixId, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110399,7 +111575,7 @@ var ts; return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } function organizeImports(scope, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); @@ -110407,7 +111583,7 @@ var ts; return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { @@ -110470,8 +111646,8 @@ var ts; } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); - return range && ts.createTextSpanFromRange(range); + var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); + return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -110599,8 +111775,7 @@ var ts; } function getRenameInfo(fileName, position) { synchronizeHostData(); - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - return ts.Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); + return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position); } function getRefactorContext(file, positionOrRange, preferences, formatOptions) { var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1]; @@ -110616,13 +111791,13 @@ var ts; }; } function getApplicableRefactors(fileName, positionOrRange, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getApplicableRefactors(getRefactorContext(file, positionOrRange, preferences)); } function getEditsForRefactor(fileName, formatOptions, positionOrRange, refactorName, actionName, preferences) { - if (preferences === void 0) { preferences = ts.defaultPreferences; } + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); @@ -110716,7 +111891,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 254 /* ExternalModuleReference */ || + node.parent.kind === 257 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -110734,7 +111909,7 @@ var ts; // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && + (node.parent.parent.kind === 186 /* ObjectLiteralExpression */ || node.parent.parent.kind === 266 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -110773,7 +111948,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 186 /* ElementAccessExpression */ && + node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -110804,7 +111979,7 @@ var ts; if (sourceFile.isDeclarationFile) { return undefined; } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { // Get previous token if the token is returned starts on new line @@ -110853,114 +112028,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return spanInVariableDeclaration(node); case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return spanInBlock(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInBlock(node.block); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 218 /* DoStatement */: + case 221 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 217 /* IfStatement */: + case 220 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return spanInForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 230 /* TryStatement */: + case 233 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 182 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 184 /* BindingElement */: // span on complete node return textSpan(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: // span in statement return spanInNode(node.statement); case 150 /* Decorator */: return spanInNodeArray(parent.decorators); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -111003,13 +112178,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 === 71 /* Identifier */ || - node.kind === 204 /* SpreadElement */ || - node.kind === 270 /* PropertyAssignment */ || - node.kind === 271 /* ShorthandPropertyAssignment */) && + node.kind === 206 /* SpreadElement */ || + node.kind === 273 /* PropertyAssignment */ || + node.kind === 274 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 200 /* BinaryExpression */) { + if (node.kind === 202 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -111031,22 +112206,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: return textSpan(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (node.parent.operatorToken.kind === 26 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -111055,20 +112230,20 @@ var ts; } } switch (node.parent.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; @@ -111077,7 +112252,7 @@ var ts; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -111107,7 +112282,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 224 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -111119,7 +112294,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 222 /* ForOfStatement */) { + parent.parent.kind === 225 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -111160,7 +112335,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); + (functionDeclaration.parent.kind === 238 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -111183,26 +112358,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 221 /* ForInStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 224 /* 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 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 225 /* 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 === 233 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 236 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -111227,21 +112402,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 182 /* BindingElement */) { + if (bindingPattern.parent.kind === 184 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 181 /* ArrayBindingPattern */ && node.kind !== 180 /* ObjectBindingPattern */); - var elements = node.kind === 183 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 183 /* ArrayBindingPattern */ && node.kind !== 182 /* ObjectBindingPattern */); + var elements = node.kind === 185 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 208 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -111249,18 +112424,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 === 200 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 202 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -111268,25 +112443,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 238 /* EnumDeclaration */: - case 235 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 213 /* Block */: + case 216 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 269 /* CatchClause */: + case 272 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -111294,7 +112469,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 180 /* ObjectBindingPattern */: + case 182 /* 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); @@ -111310,7 +112485,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 181 /* ArrayBindingPattern */: + case 183 /* 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); @@ -111325,12 +112500,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 187 /* CallExpression */ || - node.parent.kind === 188 /* NewExpression */) { + if (node.parent.kind === 221 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 189 /* CallExpression */ || + node.parent.kind === 190 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 191 /* ParenthesizedExpression */) { + if (node.parent.kind === 193 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -111339,21 +112514,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 155 /* Constructor */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 191 /* ParenthesizedExpression */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 193 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -111363,20 +112538,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 273 /* PropertyAssignment */ || node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 190 /* TypeAssertionExpression */) { + if (node.parent.kind === 192 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 218 /* DoStatement */) { + if (node.parent.kind === 221 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -111384,7 +112559,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.kind === 225 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -111804,9 +112979,9 @@ var ts; return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 6046364b40a7e..3e74564a5566b 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -16,31 +16,67 @@ and limitations under the License. "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]; }; + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -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 __assign = (this && this.__assign) || function () { + __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; + }; + return __assign.apply(this, arguments); }; "use strict"; -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]; +var __assign = (this && this.__assign) || function () { + __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; + }; + return __assign.apply(this, arguments); +}; +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 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, 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 }; } - return t; }; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } @@ -892,23 +928,6 @@ var ts; return array.slice().sort(comparer); } ts.sort = sort; - function best(iter, isBetter) { - var x = iter.next(); - if (x.done) { - return undefined; - } - var best = x.value; - while (true) { - var _a = iter.next(), value = _a.value, done = _a.done; - if (done) { - return best; - } - if (isBetter(value, best)) { - best = value; - } - } - } - ts.best = best; function arrayIterator(array) { var i = 0; return { next: function () { @@ -1869,8 +1888,9 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; - function tryRemovePrefix(str, prefix) { - return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; } ts.tryRemovePrefix = tryRemovePrefix; function isPatternMatch(_a, candidate) { @@ -2210,160 +2230,163 @@ var ts; SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType"; + SyntaxKind[SyntaxKind["OptionalType"] = 169] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 170] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 171] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 172] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 173] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 174] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 175] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 176] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 177] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 178] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 179] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 180] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 181] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 182] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 183] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 184] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 185] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 186] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 187] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 188] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 189] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 190] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 191] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 192] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 193] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 194] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 195] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 196] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 197] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 198] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 199] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 200] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 201] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 202] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 203] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 204] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 205] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 206] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 207] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 208] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 209] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 210] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 211] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 212] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 213] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 214] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 215] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 213] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 216] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 217] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 218] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 219] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 220] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 221] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 222] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 223] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 224] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 225] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 226] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 227] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 228] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 229] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 230] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 231] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 232] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 233] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 234] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 235] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 236] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 237] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 238] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 239] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 240] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 241] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 242] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 243] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 244] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 245] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 246] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 247] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 248] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 249] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 250] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 251] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 252] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 253] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 254] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 255] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 256] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 257] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 258] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 259] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 260] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 261] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 262] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 263] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 264] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 265] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 266] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 267] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 268] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 269] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 270] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 271] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 272] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 273] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 274] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 275] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 276] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 277] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 278] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 279] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 280] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 281] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 282] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 295] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 296] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 297] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 298] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 299] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 283] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 284] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 285] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 286] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 287] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 288] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 289] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 290] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 291] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 292] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 293] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 294] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 295] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 296] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 297] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 298] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 299] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 300] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 301] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 302] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 300] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 303] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 301] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 302] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 303] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 304] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 305] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 304] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 305] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 306] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 307] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 308] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 306] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 309] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -2376,7 +2399,7 @@ var ts; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 181] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; @@ -2390,10 +2413,10 @@ var ts; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 299] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 299] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 281] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 302] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 292] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 302] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -2567,6 +2590,7 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; @@ -2786,6 +2810,8 @@ var ts; CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; CheckFlags[CheckFlags["Late"] = 1024] = "Late"; CheckFlags[CheckFlags["ReverseMapped"] = 2048] = "ReverseMapped"; + CheckFlags[CheckFlags["OptionalParameter"] = 4096] = "OptionalParameter"; + CheckFlags[CheckFlags["RestParameter"] = 8192] = "RestParameter"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var InternalSymbolName; @@ -4420,6 +4446,9 @@ var ts; }, resolvePath: ChakraHost.resolvePath, fileExists: ChakraHost.fileExists, + deleteFile: ChakraHost.deleteFile, + getModifiedTime: ChakraHost.getModifiedTime, + setModifiedTime: ChakraHost.setModifiedTime, directoryExists: ChakraHost.directoryExists, createDirectory: ChakraHost.createDirectory, getExecutingFilePath: function () { return ChakraHost.executingFile; }, @@ -4578,7 +4607,6 @@ var ts; An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - A_tuple_type_element_list_cannot_be_empty: diag(1122, ts.DiagnosticCategory.Error, "A_tuple_type_element_list_cannot_be_empty_1122", "A tuple type element list cannot be empty."), Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), @@ -4698,6 +4726,8 @@ var ts; _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254", "A 'const' initializer in an ambient context must be a string or numeric literal."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -4728,7 +4758,7 @@ var ts; An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340", "Module '{0}' does not refer to a type, but is used as a type here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), @@ -4798,6 +4828,7 @@ var ts; The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), @@ -4847,6 +4878,7 @@ var ts; Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_may_only_implement_another_class_or_interface: diag(2422, ts.DiagnosticCategory.Error, "A_class_may_only_implement_another_class_or_interface_2422", "A class may only implement another class or interface."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), @@ -4994,6 +5026,9 @@ var ts; Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), + Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."), + Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."), + A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "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: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -5080,6 +5115,8 @@ var ts; Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."), Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"), + _0_was_declared_here: diag(2728, ts.DiagnosticCategory.Error, "_0_was_declared_here_2728", "'{0}' was declared here."), + Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "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: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -5379,6 +5416,10 @@ var ts; Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true), All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), + Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), + Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), + and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5410,6 +5451,8 @@ var ts; Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."), Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."), Skipping_clean_because_not_all_projects_could_be_located: diag(6371, ts.DiagnosticCategory.Error, "Skipping_clean_because_not_all_projects_could_be_located_6371", "Skipping clean because not all projects could be located"), + The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), + The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -5441,6 +5484,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Error, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{0}`"), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_a_ts_file: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_a_ts_file_8002", "'import ... =' can only be used in a .ts file."), @@ -5585,6 +5629,10 @@ var ts; Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"), Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"), Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"), + Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"), + Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"), + Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"), + Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), }; })(ts || (ts = {})); var ts; @@ -7733,7 +7781,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 274 /* SourceFile */) { + while (node && node.kind !== 277 /* SourceFile */) { node = node.parent; } return node; @@ -7741,11 +7789,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return true; } return false; @@ -7883,7 +7931,7 @@ 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 === 300 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 303 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7976,14 +8024,6 @@ var ts; return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier) { - return identifier; - } - ts.escapeIdentifier = escapeIdentifier; // 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) { @@ -7997,7 +8037,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; + return node.kind === 235 /* VariableDeclaration */ && node.parent.kind === 272 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -8029,11 +8069,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 && node.kind === 239 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 242 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 274 /* SourceFile */ || - node.kind === 239 /* ModuleDeclaration */ || + return node.kind === 277 /* SourceFile */ || + node.kind === 242 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8050,9 +8090,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.isExternalModule(node.parent); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8064,22 +8104,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 269 /* CatchClause */: - case 239 /* ModuleDeclaration */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 272 /* CatchClause */: + case 242 /* ModuleDeclaration */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; - case 213 /* Block */: + case 216 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -8095,22 +8135,22 @@ var ts; case 160 /* IndexSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: - case 288 /* JSDocSignature */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 291 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -8120,8 +8160,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: return true; default: return false; @@ -8130,15 +8170,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 214 /* VariableStatement */: - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 217 /* VariableStatement */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -8159,7 +8199,7 @@ var ts; // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; function getNameFromIndexInfo(info) { @@ -8186,7 +8226,7 @@ var ts; return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -8231,7 +8271,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 213 /* Block */) { + if (node.body && node.body.kind === 216 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8245,7 +8285,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 274 /* SourceFile */: + case 277 /* 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 @@ -8254,25 +8294,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: errorNode = node.name; break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8304,35 +8344,34 @@ var ts; return file.scriptKind === 6 /* JSON */; } ts.isJsonSourceFile = isJsonSourceFile; - function isConstEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */ && isConst(node); + function isEnumConst(node) { + return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */) - || !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + ts.isEnumConst = isEnumConst; + function isVarConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); } - ts.isConst = isConst; + ts.isVarConst = isVarConst; function isLet(node) { return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 189 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 179 /* ImportType */ && - n.argument.kind === 178 /* LiteralType */ && + return n.kind === 181 /* ImportType */ && + n.argument.kind === 180 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 216 /* ExpressionStatement */ + return node.kind === 219 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -8343,9 +8382,9 @@ var ts; function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 149 /* Parameter */ || node.kind === 148 /* TypeParameter */ || - node.kind === 192 /* FunctionExpression */ || - node.kind === 193 /* ArrowFunction */ || - node.kind === 191 /* ParenthesizedExpression */) ? + node.kind === 194 /* FunctionExpression */ || + node.kind === 195 /* ArrowFunction */ || + node.kind === 193 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -8361,7 +8400,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 181 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -8375,11 +8414,11 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 196 /* VoidExpression */; - case 207 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 198 /* VoidExpression */; + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 148 /* TypeParameter */: - return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; + return node.parent.kind === 179 /* MappedType */ || node.parent.kind === 174 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: @@ -8387,20 +8426,20 @@ var ts; if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 187 /* 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 === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 185 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 187 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through case 146 /* QualifiedName */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: { var parent = node.parent; if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 179 /* ImportType */) { + if (parent.kind === 181 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -8409,22 +8448,22 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 181 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 148 /* TypeParameter */: return node === parent.constraint; case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return node === parent.type; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 155 /* Constructor */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -8435,12 +8474,12 @@ var ts; case 159 /* ConstructSignature */: case 160 /* IndexSignature */: return node === parent.type; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return node === parent.type; - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -8465,23 +8504,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitor(node); - case 241 /* CaseBlock */: - case 213 /* Block */: - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 226 /* WithStatement */: - case 227 /* SwitchStatement */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 228 /* LabeledStatement */: - case 230 /* TryStatement */: - case 269 /* CatchClause */: + case 244 /* CaseBlock */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -8491,19 +8530,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 238 /* EnumDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 241 /* EnumDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* 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. @@ -8546,12 +8585,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 166 /* TypeLiteral */: return node.members; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return node.properties; } } @@ -8559,14 +8598,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 182 /* BindingElement */: - case 273 /* EnumMember */: + case 184 /* BindingElement */: + case 276 /* EnumMember */: case 149 /* Parameter */: - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 271 /* ShorthandPropertyAssignment */: - case 232 /* VariableDeclaration */: + case 274 /* ShorthandPropertyAssignment */: + case 235 /* VariableDeclaration */: return true; } } @@ -8578,12 +8617,12 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 233 /* VariableDeclarationList */ - && node.parent.parent.kind === 214 /* VariableStatement */; + return node.parent.kind === 236 /* VariableDeclarationList */ + && node.parent.parent.kind === 217 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { - return ts.isVariableDeclaration(node) ? isConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : ts.isPropertySignature(node) && hasReadonlyModifier(node); } @@ -8595,8 +8634,8 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return true; } return false; @@ -8607,7 +8646,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 228 /* LabeledStatement */) { + if (node.statement.kind !== 231 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -8615,17 +8654,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 216 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { return node.kind === 154 /* MethodDeclaration */ && - (node.parent.kind === 184 /* ObjectLiteralExpression */ || - node.parent.kind === 205 /* ClassExpression */); + (node.parent.kind === 186 /* ObjectLiteralExpression */ || + node.parent.kind === 207 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8638,7 +8677,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 270 /* PropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -8675,7 +8714,7 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 274 /* SourceFile */); + ts.Debug.assert(node.kind !== 277 /* SourceFile */); while (true) { node = node.parent; if (!node) { @@ -8710,14 +8749,14 @@ var ts; node = node.parent; } break; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 239 /* ModuleDeclaration */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 242 /* ModuleDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 154 /* MethodDeclaration */: @@ -8728,8 +8767,8 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 238 /* EnumDeclaration */: - case 274 /* SourceFile */: + case 241 /* EnumDeclaration */: + case 277 /* SourceFile */: return node; } } @@ -8740,8 +8779,8 @@ var ts; if (container) { switch (container.kind) { case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: return container; } } @@ -8766,9 +8805,9 @@ var ts; case 147 /* ComputedPropertyName */: node = node.parent; break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!stopOnFunctions) { continue; } @@ -8799,14 +8838,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { + if (func.kind === 194 /* FunctionExpression */ || func.kind === 195 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 191 /* ParenthesizedExpression */) { + while (parent.kind === 193 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 189 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -8817,7 +8856,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -8826,7 +8865,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) + return (kind === 187 /* PropertyAccessExpression */ || kind === 188 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -8834,7 +8873,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; @@ -8847,10 +8886,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return node.tag; - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -8859,25 +8898,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // classes are valid targets return true; case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 235 /* ClassDeclaration */; + return parent.kind === 238 /* ClassDeclaration */; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 154 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 235 /* ClassDeclaration */; + && parent.kind === 238 /* ClassDeclaration */; case 149 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined && (parent.kind === 155 /* Constructor */ || parent.kind === 154 /* MethodDeclaration */ || parent.kind === 157 /* SetAccessor */) - && grandparent.kind === 235 /* ClassDeclaration */; + && grandparent.kind === 238 /* ClassDeclaration */; } return false; } @@ -8893,7 +8932,7 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 case 154 /* MethodDeclaration */: case 157 /* SetAccessor */: @@ -8905,9 +8944,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 257 /* JsxOpeningElement */ || - parent.kind === 256 /* JsxSelfClosingElement */ || - parent.kind === 258 /* JsxClosingElement */) { + if (parent.kind === 260 /* JsxOpeningElement */ || + parent.kind === 259 /* JsxSelfClosingElement */ || + parent.kind === 261 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -8920,37 +8959,37 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: - case 208 /* AsExpression */: - case 190 /* TypeAssertionExpression */: - case 209 /* NonNullExpression */: - case 191 /* ParenthesizedExpression */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: - case 193 /* ArrowFunction */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 200 /* BinaryExpression */: - case 201 /* ConditionalExpression */: - case 204 /* SpreadElement */: - case 202 /* TemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: + case 210 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 211 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 202 /* BinaryExpression */: + case 203 /* ConditionalExpression */: + case 206 /* SpreadElement */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 206 /* OmittedExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 203 /* YieldExpression */: - case 197 /* AwaitExpression */: - case 210 /* MetaProperty */: + case 208 /* OmittedExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 205 /* YieldExpression */: + case 199 /* AwaitExpression */: + case 212 /* MetaProperty */: return true; case 146 /* QualifiedName */: while (node.parent.kind === 146 /* QualifiedName */) { @@ -8974,47 +9013,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 182 /* BindingElement */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 184 /* BindingElement */: return parent.initializer === node; - case 216 /* ExpressionStatement */: - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 225 /* ReturnStatement */: - case 226 /* WithStatement */: - case 227 /* SwitchStatement */: - case 266 /* CaseClause */: - case 229 /* ThrowStatement */: + case 219 /* ExpressionStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 228 /* ReturnStatement */: + case 229 /* WithStatement */: + case 230 /* SwitchStatement */: + case 269 /* CaseClause */: + case 232 /* ThrowStatement */: return parent.expression === node; - case 220 /* ForStatement */: + case 223 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 236 /* VariableDeclarationList */) || forInStatement.expression === node; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return node === parent.expression; - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return node === parent.expression; case 147 /* ComputedPropertyName */: return node === parent.expression; case 150 /* Decorator */: - case 265 /* JsxExpression */: - case 264 /* JsxSpreadAttribute */: - case 272 /* SpreadAssignment */: + case 268 /* JsxExpression */: + case 267 /* JsxSpreadAttribute */: + case 275 /* SpreadAssignment */: return true; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -9022,7 +9061,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -9031,7 +9070,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; + return node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 257 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -9063,7 +9102,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 187 /* CallExpression */) { + if (callExpression.kind !== 189 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -9159,11 +9198,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 194 /* FunctionExpression */ || e.kind === 195 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 192 /* FunctionExpression */ || - initializer.kind === 205 /* ClassExpression */ || - initializer.kind === 193 /* ArrowFunction */) { + if (initializer.kind === 194 /* FunctionExpression */ || + initializer.kind === 207 /* ClassExpression */ || + initializer.kind === 195 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -9232,7 +9271,7 @@ var ts; return false; } function getRightMostAssignedExpression(node) { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -9255,6 +9294,14 @@ var ts; return 0 /* None */; } var lhs = expr.left; + if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + // F.prototype = { ... } + return 6 /* Prototype */; + } + return getSpecialPropertyAccessKind(lhs); + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getSpecialPropertyAccessKind(lhs) { if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } @@ -9263,11 +9310,7 @@ var ts; return 2 /* ModuleExports */; } else if (isEntityNameExpression(lhs.expression)) { - if (lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { - // F.prototype = { ... } - return 6 /* Prototype */; - } - else if (isPrototypeAccess(lhs.expression)) { + if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } @@ -9287,7 +9330,7 @@ var ts; } return 0 /* None */; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + ts.getSpecialPropertyAccessKind = getSpecialPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.right)) { expr = expr.right; @@ -9301,7 +9344,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 219 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9311,14 +9354,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.parent; - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return node.parent.parent; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return node.parent; - case 178 /* LiteralType */: + case 180 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9328,12 +9371,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return node.moduleSpecifier; - case 243 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 179 /* ImportType */: + case 246 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 257 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 181 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9342,11 +9385,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -9354,7 +9397,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 247 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { @@ -9363,8 +9406,8 @@ var ts; case 149 /* Parameter */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: - case 271 /* ShorthandPropertyAssignment */: - case 270 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return node.questionToken !== undefined; @@ -9374,14 +9417,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 284 /* JSDocFunctionType */ && + return node.kind === 287 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 298 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 301 /* JSDocTypedefTag */ || node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9406,12 +9449,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; case 152 /* PropertyDeclaration */: return node.initializer; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return node.initializer; } } @@ -9421,59 +9464,57 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 239 /* ModuleDeclaration */ + node.body.kind === 242 /* ModuleDeclaration */ ? node.body : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; - getJSDocCommentsAndTagsWorker(hostNode); - return result || ts.emptyArray; - function getJSDocCommentsAndTagsWorker(node) { - var parent = node.parent; - if (!parent) - return; - if (parent.kind === 270 /* PropertyAssignment */ || parent.kind === 152 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { - getJSDocCommentsAndTagsWorker(parent); - } - // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - if (parent.parent && parent.parent.parent && - (getSingleVariableOfVariableStatement(parent.parent.parent) || - getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || - getSourceOfDefaultedAssignment(parent.parent.parent))) { - getJSDocCommentsAndTagsWorker(parent.parent.parent); - } - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { - if (ts.isBinaryExpression(parent)) { - getJSDocCommentsAndTagsWorker(parent.parent); - } - else { - getJSDocCommentsAndTagsWorker(parent); - } + // Pull parameter comments from declaring function as well + if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { + result = ts.addRange(result, hostNode.initializer.jsDoc); + } + var node = hostNode; + while (node && node.parent) { + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); } - // Pull parameter comments from declaring function as well if (node.kind === 149 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); + break; } - if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { - result = ts.addRange(result, node.initializer.jsDoc); - } - if (ts.hasJSDocNodes(node)) { - result = ts.addRange(result, node.jsDoc); - } + node = getNextJSDocCommentLocation(node); } + return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function getNextJSDocCommentLocation(node) { + var parent = node.parent; + if (parent.kind === 273 /* PropertyAssignment */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 219 /* ExpressionStatement */ && node.kind === 187 /* PropertyAccessExpression */ || + getNestedModuleDeclaration(parent) || + ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */) { + return parent; + } + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + else if (parent.parent && + (getSingleVariableOfVariableStatement(parent.parent) === node || + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */)) { + return parent.parent; + } + else if (parent.parent && parent.parent.parent && + (getSingleVariableOfVariableStatement(parent.parent.parent) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || + getSourceOfDefaultedAssignment(parent.parent.parent))) { + return parent.parent.parent; + } + } /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -9522,7 +9563,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 288 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9535,31 +9576,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 191 /* ParenthesizedExpression */: - case 183 /* ArrayLiteralExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 185 /* ArrayLiteralExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: node = parent; break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -9586,22 +9627,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 213 /* Block */: - case 214 /* VariableStatement */: - case 226 /* WithStatement */: - case 217 /* IfStatement */: - case 227 /* SwitchStatement */: - case 241 /* CaseBlock */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 228 /* LabeledStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 230 /* TryStatement */: - case 269 /* CatchClause */: + case 216 /* Block */: + case 217 /* VariableStatement */: + case 229 /* WithStatement */: + case 220 /* IfStatement */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 231 /* LabeledStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 233 /* TryStatement */: + case 272 /* CatchClause */: return true; } return false; @@ -9618,15 +9659,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 173 /* ParenthesizedType */); + return walkUp(node, 175 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 191 /* ParenthesizedExpression */); + return walkUp(node, 193 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */) { + while (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -9634,11 +9675,11 @@ var ts; ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 194 /* DeleteExpression */; + return node && node.kind === 196 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9695,9 +9736,9 @@ var ts; case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 273 /* EnumMember */: - case 270 /* PropertyAssignment */: - case 185 /* PropertyAccessExpression */: + case 276 /* EnumMember */: + case 273 /* PropertyAssignment */: + case 187 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; case 146 /* QualifiedName */: @@ -9709,12 +9750,12 @@ var ts; return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 182 /* BindingElement */: - case 248 /* ImportSpecifier */: + case 184 /* BindingElement */: + case 251 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 252 /* ExportSpecifier */: - case 262 /* JsxAttribute */: + case 255 /* ExportSpecifier */: + case 265 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -9730,13 +9771,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */ || - node.kind === 242 /* NamespaceExportDeclaration */ || - node.kind === 245 /* ImportClause */ && !!node.name || - node.kind === 246 /* NamespaceImport */ || - node.kind === 248 /* ImportSpecifier */ || - node.kind === 252 /* ExportSpecifier */ || - node.kind === 249 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 245 /* NamespaceExportDeclaration */ || + node.kind === 248 /* ImportClause */ && !!node.name || + node.kind === 249 /* NamespaceImport */ || + node.kind === 251 /* ImportSpecifier */ || + node.kind === 255 /* ExportSpecifier */ || + node.kind === 252 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9745,11 +9786,22 @@ var ts; return isEntityNameExpression(e) || ts.isClassExpression(e); } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { + function getEffectiveBaseTypeNode(node) { + if (isInJavaScriptFile(node)) { + // Prefer an @augments tag because it may have type parameters. + var tag = ts.getJSDocAugmentsTag(node); + if (tag) { + return tag.class; + } + } + return getClassExtendsHeritageElement(node); + } + ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; + function getClassExtendsHeritageElement(node) { var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; @@ -9758,7 +9810,7 @@ var ts; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getClassExtendsHeritageClauseElement(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray + : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -9831,14 +9883,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -9852,9 +9904,9 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined @@ -9960,7 +10012,7 @@ var ts; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 182 /* BindingElement */) { + while (node.kind === 184 /* BindingElement */) { node = node.parent.parent; } return node; @@ -9969,14 +10021,14 @@ var ts; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; return kind === 155 /* Constructor */ - || kind === 192 /* FunctionExpression */ - || kind === 234 /* FunctionDeclaration */ - || kind === 193 /* ArrowFunction */ + || kind === 194 /* FunctionExpression */ + || kind === 237 /* FunctionDeclaration */ + || kind === 195 /* ArrowFunction */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ - || kind === 239 /* ModuleDeclaration */ - || kind === 274 /* SourceFile */; + || kind === 242 /* ModuleDeclaration */ + || kind === 277 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9995,23 +10047,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: return 1 /* Right */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -10035,15 +10087,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 190 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 200 /* BinaryExpression */) { + if (expression.kind === 202 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { + else if (expression.kind === 200 /* PrefixUnaryExpression */ || expression.kind === 201 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -10053,15 +10105,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return 0; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return 1; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return 2; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return 4; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -10082,21 +10134,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 198 /* PrefixUnaryExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 194 /* DeleteExpression */: - case 197 /* AwaitExpression */: + case 200 /* PrefixUnaryExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 196 /* DeleteExpression */: + case 199 /* AwaitExpression */: return 16; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return 17; - case 187 /* CallExpression */: + case 189 /* CallExpression */: return 18; - case 188 /* NewExpression */: + case 190 /* NewExpression */: return hasArguments ? 19 : 18; - case 189 /* TaggedTemplateExpression */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 191 /* TaggedTemplateExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -10106,19 +10158,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 205 /* ClassExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 207 /* ClassExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: - case 191 /* ParenthesizedExpression */: - case 206 /* OmittedExpression */: + case 204 /* TemplateExpression */: + case 193 /* ParenthesizedExpression */: + case 208 /* OmittedExpression */: return 20; default: return -1; @@ -10177,6 +10229,7 @@ var ts; var hasReadNonFileDiagnostics = false; return { add: add, + lookup: lookup, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, reattachFileDiagnostics: reattachFileDiagnostics @@ -10184,6 +10237,23 @@ var ts; function reattachFileDiagnostics(newFile) { ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; }); } + function lookup(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, ts.compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -10606,7 +10676,7 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 289 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); @@ -10618,7 +10688,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 289 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -10911,8 +10981,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 184 /* ObjectLiteralExpression */ - || kind === 183 /* ArrayLiteralExpression */; + return kind === 186 /* ObjectLiteralExpression */ + || kind === 185 /* ArrayLiteralExpression */; } return false; } @@ -10922,7 +10992,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */ + return node.kind === 209 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -10944,16 +11014,16 @@ var ts; ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); + (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 184 /* ObjectLiteralExpression */ && + return expression.kind === 186 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 183 /* ArrayLiteralExpression */ && + return expression.kind === 185 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -11294,8 +11364,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 238 /* EnumDeclaration */: - case 239 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -11372,21 +11442,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && parent.parent.kind === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 219 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -11489,7 +11559,7 @@ var ts; } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); } ts.isUMDExportSymbol = isUMDExportSymbol; function showModuleSpecifier(_a) { @@ -11559,6 +11629,11 @@ var ts; return position >= span.start && position < textSpanEnd(span); } ts.textSpanContainsPosition = textSpanContainsPosition; + /* @internal */ + function textRangeContainsPositionInclusive(span, position) { + return position >= span.pos && position <= span.end; + } + ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive; // Returns true if 'span' contains 'other'. function textSpanContainsTextSpan(span, other) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -11752,7 +11827,7 @@ var ts; function getTypeParameterOwner(d) { if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 239 /* InterfaceDeclaration */) { return current; } } @@ -11777,27 +11852,34 @@ var ts; return isEmptyBindingPattern(node.name); } ts.isEmptyBindingElement = isEmptyBindingElement; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { - node = node.parent; + function walkUpBindingElementsAndPatterns(binding) { + var node = binding.parent; + while (ts.isBindingElement(node.parent)) { + node = node.parent.parent; } - return node; + return node.parent; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 232 /* VariableDeclaration */) { + ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns; + function getCombinedFlags(node, getFlags) { + if (ts.isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + var flags = getFlags(node); + if (node.kind === 235 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 236 /* VariableDeclarationList */) { + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= ts.getModifierFlags(node); + if (node && node.kind === 217 /* VariableStatement */) { + flags |= getFlags(node); } return flags; } + function getCombinedModifierFlags(node) { + return getCombinedFlags(node, ts.getModifierFlags); + } ts.getCombinedModifierFlags = getCombinedModifierFlags; // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags @@ -11807,19 +11889,7 @@ var ts; // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 232 /* VariableDeclaration */) { - node = node.parent; - } - if (node && node.kind === 233 /* VariableDeclarationList */) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 214 /* VariableStatement */) { - flags |= node.flags; - } - return flags; + return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** @@ -11927,16 +11997,6 @@ var ts; return unescapeLeadingUnderscores(symbol.escapedName); } ts.symbolName = symbolName; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id) { - return id; - } - ts.unescapeIdentifier = unescapeIdentifier; /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -11953,17 +12013,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return expr.name; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11972,10 +12032,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 228 /* LabeledStatement */: { + case 231 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11987,7 +12047,7 @@ var ts; } function getDeclarationIdentifier(node) { var name = getNameOfDeclaration(node); - return ts.isIdentifier(name) ? name : undefined; + return name && ts.isIdentifier(name) ? name : undefined; } function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); @@ -11998,29 +12058,20 @@ var ts; return !!node.name; // A 'name' property should always be a DeclarationName. } ts.isNamedDeclaration = isNamedDeclaration; - // TODO: GH#18217 This is often used as if it returns a defined result - function getNameOfDeclaration(declaration) { - if (!declaration) { - return undefined; - } + /** @internal */ + function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: - if (!declaration.name) { - return getAssignedName(declaration); - } - break; case 71 /* Identifier */: return declaration; - case 299 /* JSDocPropertyTag */: - case 293 /* JSDocParameterTag */: { + case 302 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 200 /* BinaryExpression */: { + case 202 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -12032,17 +12083,22 @@ var ts; return undefined; } } - case 292 /* JSDocCallbackTag */: - return declaration.name; - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } } return declaration.name; } + ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration; + function getNameOfDeclaration(declaration) { + if (declaration === undefined) + return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { if (!node.parent) { @@ -12331,545 +12387,545 @@ var ts; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 169 /* UnionType */; + return node.kind === 171 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 170 /* IntersectionType */; + return node.kind === 172 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 171 /* ConditionalType */; + return node.kind === 173 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 172 /* InferType */; + return node.kind === 174 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 173 /* ParenthesizedType */; + return node.kind === 175 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 174 /* ThisType */; + return node.kind === 176 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 175 /* TypeOperator */; + return node.kind === 177 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 176 /* IndexedAccessType */; + return node.kind === 178 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 177 /* MappedType */; + return node.kind === 179 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 178 /* LiteralType */; + return node.kind === 180 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 179 /* ImportType */; + return node.kind === 181 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 180 /* ObjectBindingPattern */; + return node.kind === 182 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 181 /* ArrayBindingPattern */; + return node.kind === 183 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 182 /* BindingElement */; + return node.kind === 184 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 183 /* ArrayLiteralExpression */; + return node.kind === 185 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 184 /* ObjectLiteralExpression */; + return node.kind === 186 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 185 /* PropertyAccessExpression */; + return node.kind === 187 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 186 /* ElementAccessExpression */; + return node.kind === 188 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 187 /* CallExpression */; + return node.kind === 189 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 188 /* NewExpression */; + return node.kind === 190 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 189 /* TaggedTemplateExpression */; + return node.kind === 191 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 190 /* TypeAssertionExpression */; + return node.kind === 192 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 191 /* ParenthesizedExpression */; + return node.kind === 193 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 302 /* PartiallyEmittedExpression */) { + while (node.kind === 305 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 192 /* FunctionExpression */; + return node.kind === 194 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 193 /* ArrowFunction */; + return node.kind === 195 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 194 /* DeleteExpression */; + return node.kind === 196 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 195 /* TypeOfExpression */; + return node.kind === 197 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 196 /* VoidExpression */; + return node.kind === 198 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 197 /* AwaitExpression */; + return node.kind === 199 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 198 /* PrefixUnaryExpression */; + return node.kind === 200 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 199 /* PostfixUnaryExpression */; + return node.kind === 201 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 200 /* BinaryExpression */; + return node.kind === 202 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 201 /* ConditionalExpression */; + return node.kind === 203 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 202 /* TemplateExpression */; + return node.kind === 204 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 203 /* YieldExpression */; + return node.kind === 205 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 204 /* SpreadElement */; + return node.kind === 206 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 205 /* ClassExpression */; + return node.kind === 207 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 206 /* OmittedExpression */; + return node.kind === 208 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 208 /* AsExpression */; + return node.kind === 210 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 209 /* NonNullExpression */; + return node.kind === 211 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 210 /* MetaProperty */; + return node.kind === 212 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 211 /* TemplateSpan */; + return node.kind === 214 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 212 /* SemicolonClassElement */; + return node.kind === 215 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 213 /* Block */; + return node.kind === 216 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 214 /* VariableStatement */; + return node.kind === 217 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 215 /* EmptyStatement */; + return node.kind === 218 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 216 /* ExpressionStatement */; + return node.kind === 219 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 217 /* IfStatement */; + return node.kind === 220 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 218 /* DoStatement */; + return node.kind === 221 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 219 /* WhileStatement */; + return node.kind === 222 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 220 /* ForStatement */; + return node.kind === 223 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 221 /* ForInStatement */; + return node.kind === 224 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 222 /* ForOfStatement */; + return node.kind === 225 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 223 /* ContinueStatement */; + return node.kind === 226 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 224 /* BreakStatement */; + return node.kind === 227 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; + return node.kind === 227 /* BreakStatement */ || node.kind === 226 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 225 /* ReturnStatement */; + return node.kind === 228 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 226 /* WithStatement */; + return node.kind === 229 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 227 /* SwitchStatement */; + return node.kind === 230 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 228 /* LabeledStatement */; + return node.kind === 231 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 229 /* ThrowStatement */; + return node.kind === 232 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 230 /* TryStatement */; + return node.kind === 233 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 231 /* DebuggerStatement */; + return node.kind === 234 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 232 /* VariableDeclaration */; + return node.kind === 235 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 233 /* VariableDeclarationList */; + return node.kind === 236 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 234 /* FunctionDeclaration */; + return node.kind === 237 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 235 /* ClassDeclaration */; + return node.kind === 238 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 236 /* InterfaceDeclaration */; + return node.kind === 239 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 237 /* TypeAliasDeclaration */; + return node.kind === 240 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 238 /* EnumDeclaration */; + return node.kind === 241 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */; + return node.kind === 242 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 240 /* ModuleBlock */; + return node.kind === 243 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 241 /* CaseBlock */; + return node.kind === 244 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 242 /* NamespaceExportDeclaration */; + return node.kind === 245 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 243 /* ImportEqualsDeclaration */; + return node.kind === 246 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 244 /* ImportDeclaration */; + return node.kind === 247 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 245 /* ImportClause */; + return node.kind === 248 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 246 /* NamespaceImport */; + return node.kind === 249 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 247 /* NamedImports */; + return node.kind === 250 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 248 /* ImportSpecifier */; + return node.kind === 251 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 249 /* ExportAssignment */; + return node.kind === 252 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 250 /* ExportDeclaration */; + return node.kind === 253 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 251 /* NamedExports */; + return node.kind === 254 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 252 /* ExportSpecifier */; + return node.kind === 255 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 253 /* MissingDeclaration */; + return node.kind === 256 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 254 /* ExternalModuleReference */; + return node.kind === 257 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 255 /* JsxElement */; + return node.kind === 258 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 256 /* JsxSelfClosingElement */; + return node.kind === 259 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 257 /* JsxOpeningElement */; + return node.kind === 260 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 258 /* JsxClosingElement */; + return node.kind === 261 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 259 /* JsxFragment */; + return node.kind === 262 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 260 /* JsxOpeningFragment */; + return node.kind === 263 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 261 /* JsxClosingFragment */; + return node.kind === 264 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 262 /* JsxAttribute */; + return node.kind === 265 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 263 /* JsxAttributes */; + return node.kind === 266 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 264 /* JsxSpreadAttribute */; + return node.kind === 267 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 265 /* JsxExpression */; + return node.kind === 268 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 266 /* CaseClause */; + return node.kind === 269 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 267 /* DefaultClause */; + return node.kind === 270 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 268 /* HeritageClause */; + return node.kind === 271 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 269 /* CatchClause */; + return node.kind === 272 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 270 /* PropertyAssignment */; + return node.kind === 273 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 271 /* ShorthandPropertyAssignment */; + return node.kind === 274 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 272 /* SpreadAssignment */; + return node.kind === 275 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 274 /* SourceFile */; + return node.kind === 277 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 275 /* Bundle */; + return node.kind === 278 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 276 /* UnparsedSource */; + return node.kind === 279 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 278 /* JSDocTypeExpression */; + return node.kind === 281 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 279 /* JSDocAllType */; + return node.kind === 282 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 280 /* JSDocUnknownType */; + return node.kind === 283 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 281 /* JSDocNullableType */; + return node.kind === 284 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 282 /* JSDocNonNullableType */; + return node.kind === 285 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 283 /* JSDocOptionalType */; + return node.kind === 286 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 284 /* JSDocFunctionType */; + return node.kind === 287 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 285 /* JSDocVariadicType */; + return node.kind === 288 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 286 /* JSDocComment */; + return node.kind === 289 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 290 /* JSDocAugmentsTag */; + return node.kind === 293 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 291 /* JSDocClassTag */; + return node.kind === 294 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocThisTag(node) { - return node.kind === 295 /* JSDocThisTag */; + return node.kind === 298 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 293 /* JSDocParameterTag */; + return node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 294 /* JSDocReturnTag */; + return node.kind === 297 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 296 /* JSDocTypeTag */; + return node.kind === 299 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 297 /* JSDocTemplateTag */; + return node.kind === 300 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 298 /* JSDocTypedefTag */; + return node.kind === 301 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 299 /* JSDocPropertyTag */; + return node.kind === 302 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 299 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; + return node.kind === 302 /* JSDocPropertyTag */ || node.kind === 296 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 287 /* JSDocTypeLiteral */; + return node.kind === 290 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 292 /* JSDocCallbackTag */; + return node.kind === 295 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 288 /* JSDocSignature */; + return node.kind === 291 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -12880,7 +12936,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 300 /* SyntaxList */; + return n.kind === 303 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -12995,8 +13051,8 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 180 /* ObjectBindingPattern */ - || kind === 181 /* ArrayBindingPattern */; + || kind === 182 /* ObjectBindingPattern */ + || kind === 183 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13011,13 +13067,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; default: return false; @@ -13028,11 +13084,11 @@ var ts; switch (kind) { case 153 /* MethodSignature */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: case 164 /* ConstructorType */: return true; default: @@ -13054,11 +13110,11 @@ var ts; || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */ || kind === 160 /* IndexSignature */ - || kind === 212 /* SemicolonClassElement */; + || kind === 215 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); + return node && (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { @@ -13093,9 +13149,9 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 270 /* PropertyAssignment */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 272 /* SpreadAssignment */ + return kind === 273 /* PropertyAssignment */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 275 /* SpreadAssignment */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ || kind === 157 /* SetAccessor */; @@ -13103,7 +13159,7 @@ var ts; ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ @@ -13116,14 +13172,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 207 /* ExpressionWithTypeArguments */ - || kind === 279 /* JSDocAllType */ - || kind === 280 /* JSDocUnknownType */ - || kind === 281 /* JSDocNullableType */ - || kind === 282 /* JSDocNonNullableType */ - || kind === 283 /* JSDocOptionalType */ - || kind === 284 /* JSDocFunctionType */ - || kind === 285 /* JSDocVariadicType */; + || kind === 209 /* ExpressionWithTypeArguments */ + || kind === 282 /* JSDocAllType */ + || kind === 283 /* JSDocUnknownType */ + || kind === 284 /* JSDocNullableType */ + || kind === 285 /* JSDocNonNullableType */ + || kind === 286 /* JSDocOptionalType */ + || kind === 287 /* JSDocFunctionType */ + || kind === 288 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -13148,8 +13204,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 181 /* ArrayBindingPattern */ - || kind === 180 /* ObjectBindingPattern */; + return kind === 183 /* ArrayBindingPattern */ + || kind === 182 /* ObjectBindingPattern */; } return false; } @@ -13157,15 +13213,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 183 /* ArrayLiteralExpression */ - || kind === 184 /* ObjectLiteralExpression */; + return kind === 185 /* ArrayLiteralExpression */ + || kind === 186 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 182 /* BindingElement */ - || kind === 206 /* OmittedExpression */; + return kind === 184 /* BindingElement */ + || kind === 208 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13174,9 +13230,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return true; } return false; @@ -13197,8 +13253,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return true; } return false; @@ -13210,8 +13266,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return true; } return false; @@ -13220,25 +13276,25 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */ - || kind === 179 /* ImportType */; + || kind === 181 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 185 /* PropertyAccessExpression */ + return kind === 187 /* PropertyAccessExpression */ || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 189 /* TaggedTemplateExpression */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 191 /* TaggedTemplateExpression */: case 150 /* Decorator */: return true; default: @@ -13247,12 +13303,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; + return node.kind === 189 /* CallExpression */ || node.kind === 190 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 202 /* TemplateExpression */ + return kind === 204 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13263,32 +13319,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: - case 188 /* NewExpression */: - case 187 /* CallExpression */: - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 259 /* JsxFragment */: - case 189 /* TaggedTemplateExpression */: - case 183 /* ArrayLiteralExpression */: - case 191 /* ParenthesizedExpression */: - case 184 /* ObjectLiteralExpression */: - case 205 /* ClassExpression */: - case 192 /* FunctionExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 190 /* NewExpression */: + case 189 /* CallExpression */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 262 /* JsxFragment */: + case 191 /* TaggedTemplateExpression */: + case 185 /* ArrayLiteralExpression */: + case 193 /* ParenthesizedExpression */: + case 186 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 209 /* NonNullExpression */: - case 210 /* MetaProperty */: + case 211 /* NonNullExpression */: + case 212 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13302,13 +13358,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 190 /* TypeAssertionExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 192 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13317,9 +13373,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -13338,15 +13394,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 201 /* ConditionalExpression */: - case 203 /* YieldExpression */: - case 193 /* ArrowFunction */: - case 200 /* BinaryExpression */: - case 204 /* SpreadElement */: - case 208 /* AsExpression */: - case 206 /* OmittedExpression */: - case 303 /* CommaListExpression */: - case 302 /* PartiallyEmittedExpression */: + case 203 /* ConditionalExpression */: + case 205 /* YieldExpression */: + case 195 /* ArrowFunction */: + case 202 /* BinaryExpression */: + case 206 /* SpreadElement */: + case 210 /* AsExpression */: + case 208 /* OmittedExpression */: + case 306 /* CommaListExpression */: + case 305 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13354,18 +13410,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 190 /* TypeAssertionExpression */ - || kind === 208 /* AsExpression */; + return kind === 192 /* TypeAssertionExpression */ + || kind === 210 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 302 /* PartiallyEmittedExpression */; + return node.kind === 305 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 301 /* NotEmittedStatement */; + return node.kind === 304 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -13376,13 +13432,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return true; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13390,7 +13446,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; + return node.kind === 224 /* ForInStatement */ || node.kind === 225 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13414,113 +13470,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */ + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 240 /* ModuleBlock */ - || kind === 239 /* ModuleDeclaration */; + return kind === 243 /* ModuleBlock */ + || kind === 242 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 239 /* ModuleDeclaration */; + || kind === 242 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 247 /* NamedImports */ - || kind === 246 /* NamespaceImport */; + return kind === 250 /* NamedImports */ + || kind === 249 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; + return node.kind === 242 /* ModuleDeclaration */ || node.kind === 241 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 193 /* ArrowFunction */ - || kind === 182 /* BindingElement */ - || kind === 235 /* ClassDeclaration */ - || kind === 205 /* ClassExpression */ + return kind === 195 /* ArrowFunction */ + || kind === 184 /* BindingElement */ + || kind === 238 /* ClassDeclaration */ + || kind === 207 /* ClassExpression */ || kind === 155 /* Constructor */ - || kind === 238 /* EnumDeclaration */ - || kind === 273 /* EnumMember */ - || kind === 252 /* ExportSpecifier */ - || kind === 234 /* FunctionDeclaration */ - || kind === 192 /* FunctionExpression */ + || kind === 241 /* EnumDeclaration */ + || kind === 276 /* EnumMember */ + || kind === 255 /* ExportSpecifier */ + || kind === 237 /* FunctionDeclaration */ + || kind === 194 /* FunctionExpression */ || kind === 156 /* GetAccessor */ - || kind === 245 /* ImportClause */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 248 /* ImportSpecifier */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 262 /* JsxAttribute */ + || kind === 248 /* ImportClause */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 251 /* ImportSpecifier */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 265 /* JsxAttribute */ || kind === 154 /* MethodDeclaration */ || kind === 153 /* MethodSignature */ - || kind === 239 /* ModuleDeclaration */ - || kind === 242 /* NamespaceExportDeclaration */ - || kind === 246 /* NamespaceImport */ + || kind === 242 /* ModuleDeclaration */ + || kind === 245 /* NamespaceExportDeclaration */ + || kind === 249 /* NamespaceImport */ || kind === 149 /* Parameter */ - || kind === 270 /* PropertyAssignment */ + || kind === 273 /* PropertyAssignment */ || kind === 152 /* PropertyDeclaration */ || kind === 151 /* PropertySignature */ || kind === 157 /* SetAccessor */ - || kind === 271 /* ShorthandPropertyAssignment */ - || kind === 237 /* TypeAliasDeclaration */ + || kind === 274 /* ShorthandPropertyAssignment */ + || kind === 240 /* TypeAliasDeclaration */ || kind === 148 /* TypeParameter */ - || kind === 232 /* VariableDeclaration */ - || kind === 298 /* JSDocTypedefTag */ - || kind === 292 /* JSDocCallbackTag */ - || kind === 299 /* JSDocPropertyTag */; + || kind === 235 /* VariableDeclaration */ + || kind === 301 /* JSDocTypedefTag */ + || kind === 295 /* JSDocCallbackTag */ + || kind === 302 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 234 /* FunctionDeclaration */ - || kind === 253 /* MissingDeclaration */ - || kind === 235 /* ClassDeclaration */ - || kind === 236 /* InterfaceDeclaration */ - || kind === 237 /* TypeAliasDeclaration */ - || kind === 238 /* EnumDeclaration */ - || kind === 239 /* ModuleDeclaration */ - || kind === 244 /* ImportDeclaration */ - || kind === 243 /* ImportEqualsDeclaration */ - || kind === 250 /* ExportDeclaration */ - || kind === 249 /* ExportAssignment */ - || kind === 242 /* NamespaceExportDeclaration */; + return kind === 237 /* FunctionDeclaration */ + || kind === 256 /* MissingDeclaration */ + || kind === 238 /* ClassDeclaration */ + || kind === 239 /* InterfaceDeclaration */ + || kind === 240 /* TypeAliasDeclaration */ + || kind === 241 /* EnumDeclaration */ + || kind === 242 /* ModuleDeclaration */ + || kind === 247 /* ImportDeclaration */ + || kind === 246 /* ImportEqualsDeclaration */ + || kind === 253 /* ExportDeclaration */ + || kind === 252 /* ExportAssignment */ + || kind === 245 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 224 /* BreakStatement */ - || kind === 223 /* ContinueStatement */ - || kind === 231 /* DebuggerStatement */ - || kind === 218 /* DoStatement */ - || kind === 216 /* ExpressionStatement */ - || kind === 215 /* EmptyStatement */ - || kind === 221 /* ForInStatement */ - || kind === 222 /* ForOfStatement */ - || kind === 220 /* ForStatement */ - || kind === 217 /* IfStatement */ - || kind === 228 /* LabeledStatement */ - || kind === 225 /* ReturnStatement */ - || kind === 227 /* SwitchStatement */ - || kind === 229 /* ThrowStatement */ - || kind === 230 /* TryStatement */ - || kind === 214 /* VariableStatement */ - || kind === 219 /* WhileStatement */ - || kind === 226 /* WithStatement */ - || kind === 301 /* NotEmittedStatement */ - || kind === 305 /* EndOfDeclarationMarker */ - || kind === 304 /* MergeDeclarationMarker */; + return kind === 227 /* BreakStatement */ + || kind === 226 /* ContinueStatement */ + || kind === 234 /* DebuggerStatement */ + || kind === 221 /* DoStatement */ + || kind === 219 /* ExpressionStatement */ + || kind === 218 /* EmptyStatement */ + || kind === 224 /* ForInStatement */ + || kind === 225 /* ForOfStatement */ + || kind === 223 /* ForStatement */ + || kind === 220 /* IfStatement */ + || kind === 231 /* LabeledStatement */ + || kind === 228 /* ReturnStatement */ + || kind === 230 /* SwitchStatement */ + || kind === 232 /* ThrowStatement */ + || kind === 233 /* TryStatement */ + || kind === 217 /* VariableStatement */ + || kind === 222 /* WhileStatement */ + || kind === 229 /* WithStatement */ + || kind === 304 /* NotEmittedStatement */ + || kind === 308 /* EndOfDeclarationMarker */ + || kind === 307 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 148 /* TypeParameter */) { - return node.parent.kind !== 297 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + return node.parent.kind !== 300 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -13547,10 +13603,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 213 /* Block */) + if (node.kind !== 216 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { + if (node.parent.kind === 233 /* TryStatement */ || node.parent.kind === 272 /* CatchClause */) { return false; } } @@ -13560,7 +13616,7 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 254 /* ExternalModuleReference */ + return kind === 257 /* ExternalModuleReference */ || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } @@ -13571,62 +13627,62 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 185 /* PropertyAccessExpression */; + || kind === 187 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 255 /* JsxElement */ - || kind === 265 /* JsxExpression */ - || kind === 256 /* JsxSelfClosingElement */ + return kind === 258 /* JsxElement */ + || kind === 268 /* JsxExpression */ + || kind === 259 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 259 /* JsxFragment */; + || kind === 262 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 262 /* JsxAttribute */ - || kind === 264 /* JsxSpreadAttribute */; + return kind === 265 /* JsxAttribute */ + || kind === 267 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 265 /* JsxExpression */; + || kind === 268 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 257 /* JsxOpeningElement */ - || kind === 256 /* JsxSelfClosingElement */; + return kind === 260 /* JsxOpeningElement */ + || kind === 259 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 266 /* CaseClause */ - || kind === 267 /* DefaultClause */; + return kind === 269 /* CaseClause */ + || kind === 270 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 299 /* LastJSDocNode */; + return node.kind >= 281 /* FirstJSDocNode */ && node.kind <= 302 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 286 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 289 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 289 /* FirstJSDocTagNode */ && node.kind <= 299 /* LastJSDocTagNode */; + return node.kind >= 292 /* FirstJSDocTagNode */ && node.kind <= 302 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -13669,22 +13725,22 @@ var ts; case 161 /* TypePredicate */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: - case 177 /* MappedType */: - case 190 /* TypeAssertionExpression */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 208 /* AsExpression */: - case 232 /* VariableDeclaration */: - case 234 /* FunctionDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 278 /* JSDocTypeExpression */: - case 281 /* JSDocNullableType */: - case 282 /* JSDocNonNullableType */: - case 283 /* JSDocOptionalType */: - case 284 /* JSDocFunctionType */: - case 285 /* JSDocVariadicType */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: + case 179 /* MappedType */: + case 192 /* TypeAssertionExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 210 /* AsExpression */: + case 235 /* VariableDeclaration */: + case 237 /* FunctionDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 281 /* JSDocTypeExpression */: + case 284 /* JSDocNullableType */: + case 285 /* JSDocNonNullableType */: + case 286 /* JSDocOptionalType */: + case 287 /* JSDocFunctionType */: + case 288 /* JSDocVariadicType */: return true; } return false; @@ -13704,10 +13760,10 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -13719,7 +13775,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 209 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13756,7 +13812,7 @@ var ts; (function (ts) { /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; + return node.kind === 250 /* NamedImports */ || node.kind === 254 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -13897,6 +13953,13 @@ var ts; } /* @internal */ function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + /* @internal */ + function compareDiagnosticsSkipRelatedInformation(d1, d2) { return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || ts.compareValues(d1.start, d2.start) || ts.compareValues(d1.length, d2.length) || @@ -13904,7 +13967,19 @@ var ts; compareMessageText(d1.messageText, d2.messageText) || 0 /* EqualTo */; } - ts.compareDiagnostics = compareDiagnostics; + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; + } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; + } + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + } function compareMessageText(t1, t2) { var text1 = t1; var text2 = t2; @@ -14447,17 +14522,15 @@ var ts; return true; } ts.containsPath = containsPath; - function tryRemoveDirectoryPrefix(path, dirPath) { - var a = ts.tryRemovePrefix(path, dirPath); - if (a === undefined) - return undefined; - switch (a.charCodeAt(0)) { - case 47 /* slash */: - case 92 /* backslash */: - return a.slice(1); - default: - return undefined; - } + function isDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + } + function stripLeadingDirectorySeparator(s) { + return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + } + function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { + var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); + return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix); } ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; // Reserved characters, forces escaping of any non-word (or digit), non-whitespace character. @@ -15010,7 +15083,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 274 /* SourceFile */) { + if (kind === 277 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -15074,14 +15147,14 @@ var ts; visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return visitNode(cbNode, node.expression); case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || @@ -15106,20 +15179,20 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -15141,9 +15214,9 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -15168,290 +15241,288 @@ var ts; return visitNode(cbNode, node.elementType); case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 172 /* InferType */: + case 174 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 179 /* ImportType */: + case 181 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 173 /* ParenthesizedType */: - case 175 /* TypeOperator */: + case 175 /* ParenthesizedType */: + case 177 /* TypeOperator */: return visitNode(cbNode, node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 177 /* MappedType */: + case 179 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return visitNode(cbNode, node.literal); - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitNode(cbNode, node.name); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return visitNode(cbNode, node.label); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 278 /* JSDocTypeExpression */: - return visitNode(cbNode, node.type); - case 282 /* JSDocNonNullableType */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 281 /* JSDocTypeExpression */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 286 /* JSDocOptionalType */: + case 288 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 281 /* JSDocNullableType */: - return visitNode(cbNode, node.type); - case 283 /* JSDocOptionalType */: - return visitNode(cbNode, node.type); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 285 /* JSDocVariadicType */: - return visitNode(cbNode, node.type); - case 286 /* JSDocComment */: + case 289 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 293 /* JSDocParameterTag */: - case 299 /* JSDocPropertyTag */: + case 296 /* JSDocParameterTag */: + case 302 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15460,17 +15531,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 294 /* JSDocReturnTag */: + case 297 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 297 /* JSDocTemplateTag */: + case 300 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 298 /* JSDocTypedefTag */: + case 301 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 278 /* JSDocTypeExpression */) { + node.typeExpression.kind === 281 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15478,18 +15549,18 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 292 /* JSDocCallbackTag */: + case 295 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 295 /* JSDocThisTag */: + case 298 /* JSDocThisTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 287 /* JSDocTypeLiteral */: + case 290 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15497,7 +15568,7 @@ var ts; } } return; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15711,7 +15782,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(216 /* ExpressionStatement */); + var statement = createNode(219 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15828,13 +15899,10 @@ var ts; } } function addJSDocComment(node) { - var comments = ts.getJSDocCommentRanges(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - node.jsDoc = ts.append(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)); - } - } + ts.Debug.assert(!node.jsDoc); // Should only be called once per node + var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); }); + if (jsDoc.length) + node.jsDoc = jsDoc; return node; } function fixupParentReferences(rootNode) { @@ -15870,7 +15938,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // 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(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(277 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -16677,7 +16745,7 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 152 /* PropertyDeclaration */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return true; case 154 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal @@ -16694,8 +16762,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: return true; } } @@ -16704,42 +16772,42 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 214 /* VariableStatement */: - case 213 /* Block */: - case 217 /* IfStatement */: - case 216 /* ExpressionStatement */: - case 229 /* ThrowStatement */: - case 225 /* ReturnStatement */: - case 227 /* SwitchStatement */: - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 220 /* ForStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 215 /* EmptyStatement */: - case 230 /* TryStatement */: - case 228 /* LabeledStatement */: - case 218 /* DoStatement */: - case 231 /* DebuggerStatement */: - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 217 /* VariableStatement */: + case 216 /* Block */: + case 220 /* IfStatement */: + case 219 /* ExpressionStatement */: + case 232 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 230 /* SwitchStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 223 /* ForStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 218 /* EmptyStatement */: + case 233 /* TryStatement */: + case 231 /* LabeledStatement */: + case 221 /* DoStatement */: + case 234 /* DebuggerStatement */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 273 /* EnumMember */; + return node.kind === 276 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { @@ -16755,7 +16823,7 @@ var ts; return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 232 /* VariableDeclaration */) { + if (node.kind !== 235 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16881,7 +16949,12 @@ var ts; return result; } function createMissingList() { - return createNodeArray([], getNodePos()); + var list = createNodeArray([], getNodePos()); + list.isMissingList = true; + return list; + } + function isMissingList(arr) { + return !!arr.isMissingList; } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -16943,7 +17016,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(202 /* TemplateExpression */); + var template = createNode(204 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -16955,7 +17028,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(211 /* TemplateSpan */); + var span = createNode(214 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -17021,10 +17094,9 @@ var ts; case 163 /* FunctionType */: case 164 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -17038,14 +17110,14 @@ var ts; return finishNode(node); } function parseThisTypeNode() { - var node = createNode(174 /* ThisType */); + var node = createNode(176 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(279 /* JSDocAllType */); + var result = createNode(282 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, result); + return createPostfixType(286 /* JSDocOptionalType */, result); } else { nextToken(); @@ -17053,7 +17125,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(282 /* JSDocNonNullableType */); + var result = createNode(285 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -17077,18 +17149,18 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(280 /* JSDocUnknownType */, pos); + var result = createNode(283 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(281 /* JSDocNullableType */, pos); + var result = createNode(284 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(287 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); @@ -17110,12 +17182,12 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(288 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(283 /* JSDocOptionalType */, type); + return createPostfixType(286 /* JSDocOptionalType */, type); } return type; } @@ -17455,7 +17527,7 @@ var ts; return finishNode(node); } function parseMappedType() { - var node = createNode(177 /* MappedType */); + var node = createNode(179 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17477,13 +17549,26 @@ var ts; parseExpected(18 /* CloseBraceToken */); return finishNode(node); } + function parseTupleElementType() { + var pos = getNodePos(); + if (parseOptional(24 /* DotDotDotToken */)) { + var node = createNode(170 /* RestType */, pos); + node.type = parseType(); + return finishNode(node); + } + var type = parseType(); + if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 284 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 169 /* OptionalType */; + } + return type; + } function parseTupleType() { var node = createNode(168 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseTupleElementType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(173 /* ParenthesizedType */); + var node = createNode(175 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); parseExpected(20 /* CloseParenToken */); @@ -17501,10 +17586,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(178 /* LiteralType */); + var node = createNode(180 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(200 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17525,7 +17610,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(179 /* ImportType */); + var node = createNode(181 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17651,19 +17736,19 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); + type = createPostfixType(285 /* JSDocNonNullableType */, type); break; case 55 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(281 /* JSDocNullableType */, type); + type = createPostfixType(284 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(176 /* IndexedAccessType */, type.pos); + var node = createNode(178 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); @@ -17682,21 +17767,21 @@ var ts; } return type; } - function createJSDocPostfixType(kind, type) { + function createPostfixType(kind, type) { nextToken(); var postfix = createNode(kind, type.pos); postfix.type = type; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(175 /* TypeOperator */); + var node = createNode(177 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(172 /* InferType */); + var node = createNode(174 /* InferType */); parseExpected(126 /* InferKeyword */); var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); @@ -17729,10 +17814,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(172 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(171 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17816,7 +17901,7 @@ var ts; } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(171 /* ConditionalType */, type.pos); + var node = createNode(173 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -18009,7 +18094,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(203 /* YieldExpression */); + var node = createNode(205 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -18031,11 +18116,11 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(193 /* ArrowFunction */, asyncModifier.pos); + node = createNode(195 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(193 /* ArrowFunction */, identifier.pos); + node = createNode(195 /* ArrowFunction */, identifier.pos); } var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; @@ -18233,7 +18318,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(193 /* ArrowFunction */); + var node = createNodeWithJSDoc(195 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18297,7 +18382,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(201 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(203 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18377,39 +18462,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(200 /* BinaryExpression */, left.pos); + var node = createNode(202 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(208 /* AsExpression */, left.pos); + var node = createNode(210 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(194 /* DeleteExpression */); + var node = createNode(196 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(195 /* TypeOfExpression */); + var node = createNode(197 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(196 /* VoidExpression */); + var node = createNode(198 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18425,7 +18510,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(197 /* AwaitExpression */); + var node = createNode(199 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18469,7 +18554,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 190 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 192 /* TypeAssertionExpression */) { parseErrorAt(pos, end, 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 { @@ -18566,7 +18651,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(198 /* PrefixUnaryExpression */); + var node = createNode(200 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18579,7 +18664,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(201 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18635,7 +18720,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(210 /* MetaProperty */, fullStart); + var node = createNode(212 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18710,7 +18795,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(185 /* PropertyAccessExpression */, expression.pos); + var node = createNode(187 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -18719,8 +18804,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 257 /* JsxOpeningElement */) { - var node = createNode(255 /* JsxElement */, opening.pos); + if (opening.kind === 260 /* JsxOpeningElement */) { + var node = createNode(258 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18729,15 +18814,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 260 /* JsxOpeningFragment */) { - var node = createNode(259 /* JsxFragment */, opening.pos); + else if (opening.kind === 263 /* JsxOpeningFragment */) { + var node = createNode(262 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 259 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18752,7 +18837,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(200 /* BinaryExpression */, result.pos); + var badNode = createNode(202 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -18810,7 +18895,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(263 /* JsxAttributes */); + var jsxAttributes = createNode(266 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18819,7 +18904,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(263 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18831,7 +18916,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(257 /* JsxOpeningElement */, fullStart); + node = createNode(260 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18843,7 +18928,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(256 /* JsxSelfClosingElement */, fullStart); + node = createNode(259 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18860,7 +18945,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18868,7 +18953,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(265 /* JsxExpression */); + var node = createNode(268 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18890,7 +18975,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(262 /* JsxAttribute */); + var node = createNode(265 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18905,7 +18990,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(264 /* JsxSpreadAttribute */); + var node = createNode(267 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18913,7 +18998,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(258 /* JsxClosingElement */); + var node = createNode(261 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18926,7 +19011,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(261 /* JsxClosingFragment */); + var node = createNode(264 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18941,7 +19026,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(190 /* TypeAssertionExpression */); + var node = createNode(192 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18952,7 +19037,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(187 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18960,14 +19045,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(211 /* 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(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(186 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(188 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -18994,7 +19079,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(191 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -19018,7 +19103,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -19026,7 +19111,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(187 /* CallExpression */, expression.pos); + var callExpr = createNode(189 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -19138,28 +19223,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(193 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(204 /* SpreadElement */); + var node = createNode(206 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(208 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(183 /* ArrayLiteralExpression */); + var node = createNode(185 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19171,7 +19256,7 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 272 /* SpreadAssignment */; + node.kind = 275 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19198,7 +19283,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - node.kind = 271 /* ShorthandPropertyAssignment */; + node.kind = 274 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -19206,14 +19291,14 @@ var ts; } } else { - node.kind = 270 /* PropertyAssignment */; + node.kind = 273 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(184 /* ObjectLiteralExpression */); + var node = createNode(186 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19232,7 +19317,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(192 /* FunctionExpression */); + var node = createNodeWithJSDoc(194 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19257,7 +19342,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(210 /* MetaProperty */, fullStart); + var node_2 = createNode(212 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19274,7 +19359,7 @@ var ts; } break; } - var node = createNode(188 /* NewExpression */, fullStart); + var node = createNode(190 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19284,7 +19369,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(213 /* Block */); + var node = createNode(216 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19317,12 +19402,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(215 /* EmptyStatement */); + var node = createNode(218 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(217 /* IfStatement */); + var node = createNode(220 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19332,7 +19417,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(218 /* DoStatement */); + var node = createNode(221 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19347,7 +19432,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(219 /* WhileStatement */); + var node = createNode(222 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19371,7 +19456,7 @@ var ts; } var forOrForInOrForOfStatement; if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { - var forOfStatement = createNode(222 /* ForOfStatement */, pos); + var forOfStatement = createNode(225 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19379,14 +19464,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(221 /* ForInStatement */, pos); + var forInStatement = createNode(224 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(220 /* ForStatement */, pos); + var forStatement = createNode(223 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19404,7 +19489,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 227 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19412,7 +19497,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(225 /* ReturnStatement */); + var node = createNode(228 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19421,7 +19506,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(226 /* WithStatement */); + var node = createNode(229 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19430,7 +19515,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(266 /* CaseClause */); + var node = createNode(269 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19438,7 +19523,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(267 /* DefaultClause */); + var node = createNode(270 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19448,12 +19533,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(227 /* SwitchStatement */); + var node = createNode(230 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(241 /* CaseBlock */); + var caseBlock = createNode(244 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19468,7 +19553,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(229 /* ThrowStatement */); + var node = createNode(232 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19476,7 +19561,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(230 /* TryStatement */); + var node = createNode(233 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19489,7 +19574,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(269 /* CatchClause */); + var result = createNode(272 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19503,7 +19588,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(231 /* DebuggerStatement */); + var node = createNode(234 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19515,12 +19600,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 228 /* LabeledStatement */; + node.kind = 231 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 216 /* ExpressionStatement */; + node.kind = 219 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19687,16 +19772,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(235 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(237 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(238 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19706,9 +19791,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(223 /* ContinueStatement */); + return parseBreakOrContinueStatement(226 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(224 /* BreakStatement */); + return parseBreakOrContinueStatement(227 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19805,7 +19890,7 @@ var ts; if (node.decorators || node.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 missing = createMissingNode(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(256 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -19828,16 +19913,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(206 /* OmittedExpression */); + return createNode(208 /* OmittedExpression */); } - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(182 /* BindingElement */); + var node = createNode(184 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19853,14 +19938,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(180 /* ObjectBindingPattern */); + var node = createNode(182 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(181 /* ArrayBindingPattern */); + var node = createNode(183 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19882,7 +19967,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(232 /* VariableDeclaration */); + var node = createNode(235 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19895,7 +19980,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(233 /* VariableDeclarationList */); + var node = createNode(236 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19933,13 +20018,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 214 /* VariableStatement */; + node.kind = 217 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 234 /* FunctionDeclaration */; + node.kind = 237 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -20121,7 +20206,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(212 /* SemicolonClassElement */); + var result = createNode(215 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -20158,10 +20243,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 207 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 238 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -20204,14 +20289,14 @@ var ts; function parseHeritageClause() { var tok = token(); ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(268 /* HeritageClause */); + var node = createNode(271 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -20228,7 +20313,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 236 /* InterfaceDeclaration */; + node.kind = 239 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20237,7 +20322,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 237 /* TypeAliasDeclaration */; + node.kind = 240 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -20251,13 +20336,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 = createNodeWithJSDoc(273 /* EnumMember */); + var node = createNodeWithJSDoc(276 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 238 /* EnumDeclaration */; + node.kind = 241 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20270,7 +20355,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(240 /* ModuleBlock */); + var node = createNode(243 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20281,7 +20366,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; // 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 */; @@ -20293,7 +20378,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 239 /* ModuleDeclaration */; + node.kind = 242 /* ModuleDeclaration */; if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -20339,7 +20424,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 242 /* NamespaceExportDeclaration */; + node.kind = 245 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20357,7 +20442,7 @@ var ts; } } // Import statement - node.kind = 244 /* ImportDeclaration */; + node.kind = 247 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20372,7 +20457,7 @@ var ts; return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 243 /* ImportEqualsDeclaration */; + node.kind = 246 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20386,7 +20471,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(245 /* ImportClause */, fullStart); + var importClause = createNode(248 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20396,7 +20481,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(250 /* NamedImports */); } return finishNode(importClause); } @@ -20406,7 +20491,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(254 /* ExternalModuleReference */); + var node = createNode(257 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20429,7 +20514,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(246 /* NamespaceImport */); + var namespaceImport = createNode(249 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20444,14 +20529,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 250 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(252 /* ExportSpecifier */); + return parseImportOrExportSpecifier(255 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(248 /* ImportSpecifier */); + return parseImportOrExportSpecifier(251 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20476,19 +20561,19 @@ var ts; else { node.name = identifierName; } - if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 251 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 250 /* ExportDeclaration */; + node.kind = 253 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(251 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(254 /* 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. @@ -20501,7 +20586,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 249 /* ExportAssignment */; + node.kind = 252 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20521,10 +20606,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ - || node.kind === 244 /* ImportDeclaration */ - || node.kind === 249 /* ExportAssignment */ - || node.kind === 250 /* ExportDeclaration */ + || node.kind === 246 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 257 /* ExternalModuleReference */ + || node.kind === 247 /* ImportDeclaration */ + || node.kind === 252 /* ExportAssignment */ + || node.kind === 253 /* ExportDeclaration */ ? node : undefined; } @@ -20587,7 +20672,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20647,17 +20732,16 @@ var ts; ts.Debug.assert(start >= 0); ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } var tags; var tagsPos; var tagsEnd; var comments = []; - var result; - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, function () { + return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. var state = 1 /* SawAsterisk */; @@ -20743,9 +20827,8 @@ var ts; } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift(); @@ -20757,7 +20840,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(286 /* JSDocComment */, start); + var result = createNode(289 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20874,6 +20957,16 @@ var ts; indent += whitespace.length; } break; + case 17 /* OpenBraceToken */: + state = 2 /* SavingComments */; + if (lookAhead(function () { return nextJSDocToken() === 57 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link"; })) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token @@ -20895,7 +20988,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(289 /* JSDocTag */, atToken.pos); + var result = createNode(292 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20955,8 +21048,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(299 /* JSDocPropertyTag */, atToken.pos) : - createNode(293 /* JSDocParameterTag */, atToken.pos); + createNode(302 /* JSDocPropertyTag */, atToken.pos) : + createNode(296 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); @@ -20976,18 +21069,18 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(281 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 293 /* JSDocParameterTag */ || child.kind === 299 /* JSDocPropertyTag */) { + if (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; @@ -20998,27 +21091,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 297 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocReturnTag */, atToken.pos); + var result = createNode(297 /* 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 === 296 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 299 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(296 /* JSDocTypeTag */, atToken.pos); + var result = createNode(299 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(293 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -21026,7 +21119,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(207 /* ExpressionWithTypeArguments */); + var node = createNode(209 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -21038,7 +21131,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(185 /* PropertyAccessExpression */, node.pos); + var prop = createNode(187 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -21046,13 +21139,13 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(291 /* JSDocClassTag */, atToken.pos); + var tag = createNode(294 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); } function parseThisTag(atToken, tagName) { - var tag = createNode(295 /* JSDocThisTag */, atToken.pos); + var tag = createNode(298 /* JSDocThisTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); @@ -21062,7 +21155,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(298 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(301 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21078,9 +21171,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(290 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 296 /* JSDocTypeTag */) { + if (child.kind === 299 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -21112,7 +21205,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(242 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -21126,7 +21219,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(295 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -21135,7 +21228,7 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(288 /* JSDocSignature */, start); + var jsdocSignature = createNode(291 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); @@ -21143,7 +21236,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 294 /* JSDocReturnTag */) { + if (tag && tag.kind === 297 /* JSDocReturnTag */) { return tag; } } @@ -21188,9 +21281,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 293 /* JSDocParameterTag */ && + if (child && (child.kind === 296 /* JSDocParameterTag */ || child.kind === 302 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 + name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } return child; @@ -21264,7 +21357,7 @@ var ts; if (constraint) { ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(297 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(300 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -22068,6 +22161,7 @@ var ts; ["esnext.array", "lib.esnext.array.d.ts"], ["esnext.symbol", "lib.esnext.symbol.d.ts"], ["esnext.asynciterable", "lib.esnext.asynciterable.d.ts"], + ["esnext.intl", "lib.esnext.intl.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -23237,7 +23331,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 270 /* PropertyAssignment */) { + if (element.kind !== 273 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -23314,13 +23408,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -23337,7 +23431,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25425,24 +25519,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 238 /* EnumDeclaration */: - if (ts.isConst(node)) { + case 241 /* EnumDeclaration */: + if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 240 /* ModuleBlock */: { + case 243 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -25464,7 +25558,7 @@ var ts; }); return state_1; } - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -25623,7 +25717,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -25648,32 +25742,32 @@ var ts; return "__constructor" /* Constructor */; case 163 /* FunctionType */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: return "__call" /* Call */; case 164 /* ConstructorType */: case 159 /* ConstructSignature */: return "__new" /* New */; case 160 /* IndexSignature */: return "__index" /* Index */; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); case 149 /* 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 === 284 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 287 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -25767,7 +25861,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 && - (node.kind === 249 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 252 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -25792,7 +25886,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 255 /* ExportSpecifier */ || (node.kind === 246 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -25859,7 +25953,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -25904,7 +25998,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { @@ -25953,8 +26047,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 237 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -25986,77 +26080,78 @@ var ts; return; } switch (node.kind) { - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: bindWhileStatement(node); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: bindDoStatement(node); break; - case 220 /* ForStatement */: + case 223 /* ForStatement */: bindForStatement(node); break; - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: bindIfStatement(node); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: bindTryStatement(node); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: bindSwitchStatement(node); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: bindCaseBlock(node); break; - case 266 /* CaseClause */: + case 269 /* CaseClause */: bindCaseClause(node); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: bindLabeledStatement(node); break; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: bindCallExpressionFlow(node); break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 274 /* SourceFile */: + case 277 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 213 /* Block */: - case 240 /* ModuleBlock */: + } + case 216 /* Block */: + case 243 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -26069,15 +26164,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return hasNarrowableArgument(expr); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -26086,7 +26181,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -26097,7 +26192,7 @@ var ts; } } } - if (expr.expression.kind === 185 /* PropertyAccessExpression */ && + if (expr.expression.kind === 187 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -26130,9 +26225,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -26210,33 +26305,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 217 /* IfStatement */: - case 219 /* WhileStatement */: - case 218 /* DoStatement */: + case 220 /* IfStatement */: + case 222 /* WhileStatement */: + case 221 /* DoStatement */: return parent.expression === node; - case 220 /* ForStatement */: - case 201 /* ConditionalExpression */: + case 223 /* ForStatement */: + case 203 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 191 /* ParenthesizedExpression */) { + if (node.kind === 193 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 200 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 202 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 191 /* ParenthesizedExpression */ || - node.parent.kind === 198 /* PrefixUnaryExpression */ && + while (node.parent.kind === 193 /* ParenthesizedExpression */ || + node.parent.kind === 200 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -26278,7 +26373,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 231 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -26312,13 +26407,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 222 /* ForOfStatement */) { + if (node.kind === 225 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 233 /* VariableDeclarationList */) { + if (node.initializer.kind !== 236 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -26340,7 +26435,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 225 /* ReturnStatement */) { + if (node.kind === 228 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -26360,7 +26455,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 227 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -26456,7 +26551,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 270 /* 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; @@ -26524,14 +26619,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 221 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -26542,10 +26637,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 183 /* ArrayLiteralExpression */) { + else if (node.kind === 185 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 204 /* SpreadElement */) { + if (e.kind === 206 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -26553,16 +26648,16 @@ var ts; } } } - else if (node.kind === 184 /* ObjectLiteralExpression */) { + else if (node.kind === 186 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 270 /* PropertyAssignment */) { + if (p.kind === 273 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 271 /* ShorthandPropertyAssignment */) { + else if (p.kind === 274 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 272 /* SpreadAssignment */) { + else if (p.kind === 275 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -26618,7 +26713,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 188 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26629,7 +26724,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -26676,10 +26771,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 === 191 /* ParenthesizedExpression */) { + while (expr.kind === 193 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { + if (expr.kind === 194 /* FunctionExpression */ || expr.kind === 195 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -26687,7 +26782,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 185 /* PropertyAccessExpression */) { + if (node.expression.kind === 187 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -26696,21 +26791,21 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 184 /* ObjectLiteralExpression */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 186 /* ObjectLiteralExpression */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 266 /* JsxAttributes */: return 1 /* IsContainer */; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 179 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -26718,32 +26813,32 @@ var ts; } // falls through case 155 /* Constructor */: - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: case 158 /* CallSignature */: - case 288 /* JSDocSignature */: - case 284 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: case 163 /* FunctionType */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 269 /* CatchClause */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: - case 241 /* CaseBlock */: + case 272 /* CatchClause */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: + case 244 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 213 /* Block */: + case 216 /* 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 @@ -26776,20 +26871,20 @@ 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 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 274 /* SourceFile */: + case 277 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 184 /* ObjectLiteralExpression */: - case 236 /* InterfaceDeclaration */: - case 263 /* JsxAttributes */: + case 290 /* JSDocTypeLiteral */: + case 186 /* ObjectLiteralExpression */: + case 239 /* InterfaceDeclaration */: + case 266 /* 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 @@ -26800,21 +26895,21 @@ var ts; case 164 /* ConstructorType */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: - case 288 /* JSDocSignature */: + case 291 /* JSDocSignature */: case 160 /* IndexSignature */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 284 /* JSDocFunctionType */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 237 /* TypeAliasDeclaration */: - case 177 /* MappedType */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 287 /* JSDocFunctionType */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 240 /* TypeAliasDeclaration */: + case 179 /* 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 @@ -26835,11 +26930,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 274 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { + var body = node.kind === 277 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 277 /* SourceFile */ || body.kind === 243 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { + if (stat.kind === 253 /* ExportDeclaration */ || stat.kind === 252 /* ExportAssignment */) { return true; } } @@ -26923,7 +27018,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 275 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -26935,7 +27030,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ + var currentKind = prop.kind === 273 /* PropertyAssignment */ || prop.kind === 274 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -26967,10 +27062,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -27111,8 +27206,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 274 /* SourceFile */ && - blockScopeContainer.kind !== 239 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 277 /* SourceFile */ && + blockScopeContainer.kind !== 242 /* 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. @@ -27208,7 +27303,11 @@ var ts; } else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912 /* HasComputedFlags */) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + var saveParent = parent; + if (node.kind === 1 /* EndOfFileToken */) + parent = node; bindJSDoc(node); + parent = saveParent; } inStrictMode = saveInStrictMode; } @@ -27266,11 +27365,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 274 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -27278,7 +27377,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -27306,19 +27405,19 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return checkStrictModeCatchClause(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkStrictModeWithStatement(node); - case 174 /* ThisType */: + case 176 /* ThisType */: seenThisKeyword = true; return; case 161 /* TypePredicate */: @@ -27327,18 +27426,18 @@ var ts; return bindTypeParameter(node); case 149 /* Parameter */: return bindParameter(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 273 /* EnumMember */: + case 276 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); case 158 /* CallSignature */: case 159 /* ConstructSignature */: @@ -27351,7 +27450,7 @@ var ts; // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 67208127 /* MethodExcludes */); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return bindFunctionDeclaration(node); case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); @@ -27360,83 +27459,83 @@ var ts; case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); case 163 /* FunctionType */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 177 /* MappedType */: + case 290 /* JSDocTypeLiteral */: + case 179 /* MappedType */: return bindAnonymousTypeWorker(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return bindFunctionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 205 /* ClassExpression */: - case 235 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 238 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return bindJsxAttributes(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return bindImportClause(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return bindExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return bindExportAssignment(node); - case 274 /* SourceFile */: + case 277 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 213 /* Block */: + case 216 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 293 /* JSDocParameterTag */: - if (node.parent.kind === 288 /* JSDocSignature */) { + case 296 /* JSDocParameterTag */: + if (node.parent.kind === 291 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 290 /* JSDocTypeLiteral */) { break; } // falls through - case 299 /* JSDocPropertyTag */: + case 302 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 286 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -27468,7 +27567,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 252 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; ? 2097152 /* Alias */ // An export default clause with any other expression exports a value @@ -27482,7 +27581,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 274 /* SourceFile */) { + if (node.parent.kind !== 277 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -27567,8 +27666,8 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -27595,7 +27694,7 @@ var ts; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -27607,7 +27706,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 277 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -27664,9 +27763,9 @@ var ts; function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 277 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + : propertyAccess.parent.parent.kind === 277 /* SourceFile */; if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; @@ -27760,7 +27859,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -27793,7 +27892,7 @@ var ts; prototypeSymbol.parent = symbol; } function bindEnumDeclaration(node) { - return ts.isConst(node) + return ts.isEnumConst(node) ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); } @@ -27823,7 +27922,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { + if (node.kind === 296 /* JSDocParameterTag */ && container.kind !== 291 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -27900,7 +27999,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 172 /* InferType */) { + else if (node.parent.kind === 174 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -27928,13 +28027,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 218 /* EmptyStatement */) || // report error on class declarations - node.kind === 235 /* ClassDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 242 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (ts.isEnumDeclaration(node) && (!ts.isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -27991,43 +28090,43 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); @@ -28038,11 +28137,11 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -28094,12 +28193,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 186 /* 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 === 58 /* EqualsToken */ && leftKind === 183 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 185 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -28148,8 +28247,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 === 208 /* AsExpression */ - || expressionKind === 190 /* TypeAssertionExpression */) { + if (expressionKind === 210 /* AsExpression */ + || expressionKind === 192 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -28526,13 +28625,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -28543,25 +28642,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 238 /* EnumDeclaration */: - case 273 /* EnumMember */: - case 209 /* NonNullExpression */: + case 241 /* EnumDeclaration */: + case 276 /* EnumMember */: + case 211 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 255 /* JsxElement */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 258 /* JsxElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: case 10 /* JsxText */: - case 258 /* JsxClosingElement */: - case 259 /* JsxFragment */: - case 260 /* JsxOpeningFragment */: - case 261 /* JsxClosingFragment */: - case 262 /* JsxAttribute */: - case 263 /* JsxAttributes */: - case 264 /* JsxSpreadAttribute */: - case 265 /* JsxExpression */: + case 261 /* JsxClosingElement */: + case 262 /* JsxFragment */: + case 263 /* JsxOpeningFragment */: + case 264 /* JsxClosingFragment */: + case 265 /* JsxAttribute */: + case 266 /* JsxAttributes */: + case 267 /* JsxSpreadAttribute */: + case 268 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -28569,11 +28668,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 202 /* TemplateExpression */: - case 189 /* TaggedTemplateExpression */: - case 271 /* ShorthandPropertyAssignment */: + case 204 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 274 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -28587,14 +28686,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -28621,19 +28720,21 @@ var ts; case 166 /* TypeLiteral */: case 167 /* ArrayType */: case 168 /* TupleType */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 171 /* ConditionalType */: - case 172 /* InferType */: - case 173 /* ParenthesizedType */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 174 /* ThisType */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: - case 178 /* LiteralType */: - case 242 /* NamespaceExportDeclaration */: + case 169 /* OptionalType */: + case 170 /* RestType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 174 /* InferType */: + case 175 /* ParenthesizedType */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: + case 245 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; @@ -28655,10 +28756,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -28670,18 +28771,18 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; @@ -28691,7 +28792,7 @@ var ts; // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -28709,8 +28810,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 183 /* ArrayLiteralExpression */: - case 188 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: + case 190 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -28718,26 +28819,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: // Return statements may require an `await` in ESNext. transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; break; - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -28753,27 +28854,27 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 181 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 183 /* ArrayLiteralExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 185 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return 942011713 /* ClassExcludes */; case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; @@ -28795,24 +28896,24 @@ var ts; case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 160 /* IndexSignature */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 269 /* CatchClause */: + case 272 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 302 /* PartiallyEmittedExpression */: - case 191 /* ParenthesizedExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 305 /* PartiallyEmittedExpression */: + case 193 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -29101,6 +29202,7 @@ var ts; getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, + getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, getIndexInfoOfType: getIndexInfoOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, @@ -29174,7 +29276,6 @@ var ts; writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) { return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, getContextualType: function (nodeIn) { @@ -29272,6 +29373,7 @@ var ts; getNeverType: function () { return neverType; }, isSymbolAccessible: isSymbolAccessible, isArrayLikeType: isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, @@ -29330,7 +29432,7 @@ var ts; } } }; - var tupleTypes = []; + var tupleTypes = ts.createMap(); var unionTypes = ts.createMap(); var intersectionTypes = ts.createMap(); var literalTypes = ts.createMap(); @@ -29387,6 +29489,7 @@ var ts; var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createSymbolTable(); + var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); var ambientModulesCache; /** @@ -29600,143 +29703,6 @@ var ts; var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder() { - return { - buildTypeDisplay: function (type, writer, enclosingDeclaration, flags) { - typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); - }, - buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } - symbolToString(symbol, enclosingDeclaration, meaning, flags | 4 /* AllowAnyNodeKind */, emitTextWriterWrapper(writer)); - }, - buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay: function (info, writer, kind, enclosing, flags) { - var sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, sig, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildParameterDisplay: function (symbol, writer, enclosing, flags) { - var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { - var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 8192 /* OmitParameterModifiers */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol: function (symbol, writer, enclosing, flags) { - var nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeList(26896 /* TypeParameters */, nodes, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { - var printer = ts.createPrinter({ removeComments: true }); - var flags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */ | toNodeBuilderFlags(originalFlags); - var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; // TODO: GH#18217 - var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); // TODO: GH#18217 - printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForTypeParametersAndDelimiters: function (typeParameters, writer, enclosing, flags) { - var printer = ts.createPrinter({ removeComments: true }); - var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); // TODO: GH#18217 - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - var predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - } - }; - function emitTextWriterWrapper(underlying) { - return { - write: ts.noop, - writeTextOfNode: ts.noop, - writeLine: ts.noop, - increaseIndent: function () { - return underlying.increaseIndent(); - }, - decreaseIndent: function () { - return underlying.decreaseIndent(); - }, - getText: function () { - return ""; - }, - rawWrite: ts.noop, - writeLiteral: function (s) { - return underlying.writeStringLiteral(s); - }, - getTextPos: function () { - return 0; - }, - getLine: function () { - return 0; - }, - getColumn: function () { - return 0; - }, - getIndent: function () { - return 0; - }, - isAtStartOfLine: function () { - return false; - }, - clear: function () { - return underlying.clear(); - }, - writeKeyword: function (text) { - return underlying.writeKeyword(text); - }, - writeOperator: function (text) { - return underlying.writeOperator(text); - }, - writePunctuation: function (text) { - return underlying.writePunctuation(text); - }, - writeSpace: function (text) { - return underlying.writeSpace(text); - }, - writeStringLiteral: function (text) { - return underlying.writeStringLiteral(text); - }, - writeParameter: function (text) { - return underlying.writeParameter(text); - }, - writeProperty: function (text) { - return underlying.writeProperty(text); - }, - writeSymbol: function (text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol: function (symbol, enclosing, meaning) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError: function () { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression: function (name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError: function () { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -29774,6 +29740,31 @@ var ts; getDiagnostics(sourceFile, cancellationToken); return emitResolver; } + function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) { + var diagnostic = location + ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + var existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + function addRelatedInfo(diagnostic) { + var relatedInformation = []; + for (var _i = 1; _i < arguments.length; _i++) { + relatedInformation[_i - 1] = arguments[_i]; + } + var _a; + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation); + return diagnostic; + } function error(location, message, arg0, arg1, arg2, arg3) { var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -29899,22 +29890,57 @@ var ts; error(ts.getNameOfDeclaration(source.declarations[0]), 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 & 384 /* Enum */ || source.flags & 384 /* Enum */ + var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); + var isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ + : isEitherBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; - error(errorNode, message_2, symbolToString(source)); - }); + var sourceSymbolFile_1 = source.declarations && ts.getSourceFileOfNode(source.declarations[0]); + var targetSymbolFile_1 = target.declarations && ts.getSourceFileOfNode(target.declarations[0]); + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile_1 && targetSymbolFile_1 && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile_1 !== targetSymbolFile_1) { + var firstFile_1 = ts.comparePaths(sourceSymbolFile_1.path, targetSymbolFile_1.path) === -1 /* LessThan */ ? sourceSymbolFile_1 : targetSymbolFile_1; + var secondFile = firstFile_1 === sourceSymbolFile_1 ? targetSymbolFile_1 : sourceSymbolFile_1; + var cacheKey = firstFile_1.path + "|" + secondFile.path; + var existing = amalgamatedDuplicates.get(cacheKey) || { firstFile: firstFile_1, secondFile: secondFile, firstFileInstances: ts.createMap(), secondFileInstances: ts.createMap() }; + var symbolName_1 = symbolToString(source); + var firstInstanceList_1 = existing.firstFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + var secondInstanceList_1 = existing.secondFileInstances.get(symbolName_1) || { instances: [], blockScoped: isEitherBlockScoped }; + ts.forEach(source.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = sourceSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + var targetList = targetSymbolFile_1 === firstFile_1 ? firstInstanceList_1 : secondInstanceList_1; + targetList.instances.push(errorNode); + }); + existing.firstFileInstances.set(symbolName_1, firstInstanceList_1); + existing.secondFileInstances.set(symbolName_1, secondInstanceList_1); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + var symbolName_2 = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_2, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_2, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { + ts.forEach(target.declarations, function (node) { + var errorNode = (ts.getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getOuterNameOfJsInitializer(node) : ts.getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNode) { + var err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && ts.length(err.relatedInformation) < 5) { + addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + } + } function combineSymbolTables(first, second) { if (!ts.hasEntries(first)) return second; @@ -29989,7 +30015,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 277 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -30047,17 +30073,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 182 /* BindingElement */) { + if (declaration.kind === 184 /* 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, 182 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 184 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || 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, 232 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 235 /* VariableDeclaration */), usage); } - else if (declaration.kind === 232 /* VariableDeclaration */) { + else if (declaration.kind === 235 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -30075,12 +30101,12 @@ var ts; // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 255 /* ExportSpecifier */ || (usage.parent.kind === 252 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 249 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 252 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -30088,9 +30114,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 214 /* VariableStatement */: - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: + case 217 /* VariableStatement */: + case 223 /* ForStatement */: + case 225 /* 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)) { @@ -30162,7 +30188,7 @@ 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 & 67901928 /* Type */ && lastLocation.kind !== 286 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 289 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || @@ -30182,7 +30208,7 @@ var ts; !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 171 /* ConditionalType */) { + else if (location.kind === 173 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -30196,14 +30222,14 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 277 /* 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.get("default" /* Default */)) { @@ -30227,7 +30253,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 255 /* ExportSpecifier */)) { break; } } @@ -30241,7 +30267,7 @@ var ts; } } break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } @@ -30264,9 +30290,9 @@ var ts; } } break; - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -30282,7 +30308,7 @@ var ts; } break loop; } - if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 207 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -30290,7 +30316,7 @@ var ts; } } break; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -30312,7 +30338,7 @@ var ts; // case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 239 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -30325,14 +30351,14 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -30367,8 +30393,8 @@ var ts; location = location.parent; } break; - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; @@ -30387,7 +30413,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 277 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -30461,7 +30487,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67216319 /* Value */) === 67216319 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 242 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 245 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } @@ -30470,12 +30496,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 239 /* ModuleDeclaration */: // For `namespace N { N; }` + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 242 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -30543,9 +30569,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -30609,18 +30635,26 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238 /* EnumDeclaration */) ? d : undefined; }); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 241 /* EnumDeclaration */) ? d : undefined; }); if (declaration === undefined) return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + var diagnosticMessage = void 0; + var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & 32 /* Class */) { - error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & 256 /* RegularEnum */) { - error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } } @@ -30633,13 +30667,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return node; - case 245 /* ImportClause */: + case 248 /* ImportClause */: return node.parent; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return node.parent.parent; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -30649,7 +30683,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -30837,20 +30871,20 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 249 /* ExportAssignment */: - case 200 /* BinaryExpression */: + case 252 /* ExportAssignment */: + case 202 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -30911,11 +30945,11 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 249 /* ExportAssignment */) { + if (node.kind === 252 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 252 /* ExportSpecifier */) { + else if (node.kind === 255 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -30943,7 +30977,7 @@ var ts; else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 246 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -30967,7 +31001,7 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + else if (name.kind === 146 /* QualifiedName */ || name.kind === 187 /* PropertyAccessExpression */) { var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -31132,10 +31166,19 @@ var ts; } function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) { var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName; - var errorInfo = packageId && ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)); + var errorInfo = packageId + ? ts.chainDiagnosticMessages( + /*details*/ undefined, typesPackageExists(packageId.name) + ? ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0 + : ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)) + : undefined; errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } + function typesPackageExists(packageName) { + return host.getSourceFiles().some(function (sf) { return !!sf.resolvedModules && !!ts.forEachEntry(sf.resolvedModules, function (r) { + return r && r.packageId && r.packageId.name === ts.getTypesPackageName(packageName); + }); }); + } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -31161,7 +31204,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 277 /* SourceFile */)) { error(referencingLocation, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } @@ -31394,6 +31437,12 @@ var ts; var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } function createTypeofType() { @@ -31412,25 +31461,19 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { type.members = members; - type.properties = getNamedMembers(members); + type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); type.callSignatures = callSignatures; type.constructSignatures = constructSignatures; - if (stringIndexInfo) - type.stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) - type.numberIndexInfo = numberIndexInfo; + type.stringIndexInfo = stringIndexInfo; + type.numberIndexInfo = numberIndexInfo; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { @@ -31446,12 +31489,12 @@ var ts; } } switch (location.kind) { - case 274 /* SourceFile */: + case 277 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -31548,7 +31591,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 255 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -31660,10 +31703,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 277 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -31716,8 +31759,8 @@ var ts; // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || - entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 187 /* PropertyAccessExpression */ || + entityName.parent.kind === 246 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -31799,64 +31842,33 @@ var ts; function createNodeBuilder() { return { typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeToTypeNodeHelper(type, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); }); }, indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; // TODO: GH#18217 + return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); }); }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); }); }, symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, /*expectsIdentifier*/ false); }); }, symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToExpression(symbol, context, meaning); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); }); }, symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParametersToTypeParameterDeclarations(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); }); }, symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = symbolToParameterDeclaration(symbol, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); }); }, typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); - var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); - var resultingNode = typeParameterToDeclaration(parameter, context); - var result = context.encounteredError ? undefined : resultingNode; - return result; + return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, }; - function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { - return { + function withContext(enclosingDeclaration, flags, tracker, cb) { + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, @@ -31864,6 +31876,8 @@ var ts; visitedSymbols: undefined, inferTypeParameters: undefined }; + var resultingNode = cb(context); + return context.encounteredError ? undefined : resultingNode; } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -31981,7 +31995,7 @@ var ts; var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 171 /* UnionType */ : 172 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -32050,7 +32064,7 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 207 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -32088,7 +32102,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; + return declaration.parent.kind === 277 /* SourceFile */ || declaration.parent.kind === 243 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -32136,8 +32150,15 @@ var ts; } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { - var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); + var arity = getTypeReferenceArity(type); + var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); + var hasRestElement = type.target.hasRestElement; if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + for (var i = type.target.minLength; i < arity; i++) { + tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ? + ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) : + ts.createOptionalTypeNode(tupleConstituentNodes[i]); + } return ts.createTupleTypeNode(tupleConstituentNodes); } } @@ -32351,7 +32372,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -32405,7 +32426,7 @@ var ts; function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 296 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -32413,7 +32434,7 @@ var ts; } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; - var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 8192 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? @@ -32422,7 +32443,8 @@ var ts; cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? ts.createToken(55 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 4096 /* OptionalParameter */; + var questionToken = isOptional ? ts.createToken(55 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -32432,7 +32454,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 182 /* BindingElement */) { + if (clone.kind === 184 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -32516,17 +32538,49 @@ var ts; } return top; } + function getSpecifierForModuleSymbol(symbol, context) { + var file = ts.getDeclarationOfKind(symbol, 277 /* SourceFile */); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + if (context.tracker.trackReferencedAmbientModule) { + var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); + if (ts.length(ambientDecls)) { + for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { + var decl = ambientDecls_1[_i]; + context.tracker.trackReferencedAmbientModule(decl, symbol); + } + } + } + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return symbol.escapedName.substring(1, symbol.escapedName.length - 1); + } + var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); + var links = getSymbolLinks(symbol); + var specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = ts.flatten(ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" }))[0]; + links.specifierCache = links.specifierCache || ts.createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= 16777216 /* InInitialEntityName */; - var rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= 16777216 /* InInitialEntityName */; var isTypeOf = meaning === 67216319 /* Value */; - if (ambientModuleSymbolRegex.test(rootName)) { + if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - var lit = ts.createLiteralTypeNode(ts.createLiteral(rootName.substring(1, rootName.length - 1))); + var lit = ts.createLiteralTypeNode(ts.createLiteral(getSpecifierForModuleSymbol(chain[0], context))); if (!nonRootParts || ts.isEntityName(nonRootParts)) { if (nonRootParts) { var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -32700,8 +32754,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173 /* ParenthesizedType */; }); - if (node.kind === 237 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 175 /* ParenthesizedType */; }); + if (node.kind === 240 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -32709,11 +32763,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 240 /* ModuleBlock */ && + node.parent.kind === 243 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 277 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -32733,42 +32787,22 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 - var file = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); - if (!file || !context.tracker.moduleResolverHost) { - if (context.tracker.trackReferencedAmbientModule) { - var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); - if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; - context.tracker.trackReferencedAmbientModule(decl); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration)); - return "\"" + (file.moduleName || ts.moduleSpecifiers.getModuleSpecifiers(symbol, compilerOptions, contextFile, context.tracker.moduleResolverHost, context.tracker.moduleResolverHost.getSourceFiles(), { importModuleSpecifierPreference: "non-relative" })[0]) + "\""; - } - } var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 235 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { - context.encounteredError = true; - } switch (declaration.kind) { - case 205 /* ClassExpression */: - return "(Anonymous class)"; - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - return "(Anonymous function)"; + case 207 /* ClassExpression */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + context.encounteredError = true; + } + return declaration.kind === 207 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var nameType = symbol.nameType; @@ -32793,27 +32827,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 292 /* JSDocCallbackTag */: - case 298 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 234 /* FunctionDeclaration */: - case 238 /* EnumDeclaration */: - case 243 /* ImportEqualsDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 237 /* FunctionDeclaration */: + case 241 /* EnumDeclaration */: + case 246 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -32821,7 +32855,7 @@ var ts; 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 !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 246 /* ImportEqualsDeclaration */ && parent.kind !== 277 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible @@ -32843,31 +32877,31 @@ var ts; case 158 /* CallSignature */: case 160 /* IndexSignature */: case 149 /* Parameter */: - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: case 162 /* TypeReference */: case 167 /* ArrayType */: case 168 /* TupleType */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 173 /* ParenthesizedType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 175 /* 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 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: return false; // Type parameters are always visible case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 274 /* SourceFile */: - case 242 /* NamespaceExportDeclaration */: + case 277 /* SourceFile */: + case 245 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return false; default: return false; @@ -32876,10 +32910,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 252 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 252 /* ExportSpecifier */) { + else if (node.parent.kind === 255 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -32975,12 +33009,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 232 /* VariableDeclaration */: - case 233 /* VariableDeclarationList */: - case 248 /* ImportSpecifier */: - case 247 /* NamedImports */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 235 /* VariableDeclaration */: + case 236 /* VariableDeclarationList */: + case 251 /* ImportSpecifier */: + case 250 /* NamedImports */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: return false; default: return true; @@ -33057,7 +33091,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 180 /* ObjectBindingPattern */) { + if (pattern.kind === 182 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -33127,22 +33161,27 @@ var ts; // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); + var index = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); + // If the parent is a tuple type, the rest element has an array type with a union of the + // remaining tuple element types. Otherwise, the rest element has an array type with same + // element type as the parent type. + type = isTupleType(parentType) ? + getArrayLiteralType((parentType.typeArguments || ts.emptyArray).slice(index, getTypeReferenceArity(parentType))) : + createArrayType(elementType); } else { // Use specific property type when parent is a tuple or numeric index type when parent is an array - var propName = "" + pattern.elements.indexOf(declaration); - type = isTupleLikeType(parentType) - ? getTypeOfPropertyOfType(parentType, propName) - : elementType; + var index_1 = pattern.elements.indexOf(declaration); + type = isTupleLikeType(parentType) ? + getTupleElementType(parentType, index_1) || declaration.initializer && checkDeclarationInitializer(declaration) : + elementType; if (!type) { if (isTupleType(parentType)) { error(declaration, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { - error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); + error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), "" + index_1); } return errorType; } @@ -33153,7 +33192,7 @@ var ts; if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } - return declaration.initializer ? + return declaration.initializer && !ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], 2 /* Subtype */) : type; } @@ -33170,7 +33209,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 185 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -33180,11 +33219,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 224 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 225 /* 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, @@ -33203,7 +33242,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 235 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // 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 @@ -33275,20 +33314,20 @@ var ts; var jsDocType; var _loop_4 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : - declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = ts.isBinaryExpression(declaration) ? declaration : + ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { return { value: errorType }; } - var special = ts.getSpecialPropertyAssignmentKind(expression); + var special = ts.isPropertyAccessExpression(expression) ? ts.getSpecialPropertyAccessKind(expression) : ts.getSpecialPropertyAssignmentKind(expression); if (special === 4 /* ThisProperty */) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. declarationInConstructor = thisContainer.kind === 155 /* Constructor */ || - thisContainer.kind === 234 /* FunctionDeclaration */ || - (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + thisContainer.kind === 237 /* FunctionDeclaration */ || + (thisContainer.kind === 194 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -33309,7 +33348,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); } } - else if (!jsDocType) { + else if (!jsDocType && ts.isBinaryExpression(expression)) { // If we don't have an explicit JSDoc type, get the type from the expression. var type_2 = getWidenedLiteralType(checkExpressionCached(expression.right)); if (ts.getObjectFlags(type_2) & 16 /* Anonymous */ && @@ -33391,7 +33430,7 @@ var ts; // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { - return checkDeclarationInitializer(element); + return addOptionality(checkDeclarationInitializer(element)); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -33436,12 +33475,13 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + var hasRestElement = !!(lastElement && lastElement.kind === 184 /* BindingElement */ && lastElement.dotDotDotToken); + if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } - // If the pattern has at least one element, and no rest element, then it should imply a tuple type. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); - var result = createTupleType(elementTypes); + var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1; + var result = createTupleType(elementTypes, minLength, hasRestElement); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; @@ -33458,7 +33498,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 180 /* ObjectBindingPattern */ + return pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -33527,7 +33567,7 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 249 /* ExportAssignment */) { + if (declaration.kind === 252 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -33731,8 +33771,8 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 202 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 187 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 202 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -33869,35 +33909,35 @@ var ts; return undefined; } switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: + case 239 /* InterfaceDeclaration */: case 158 /* CallSignature */: case 159 /* ConstructSignature */: case 153 /* MethodSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 284 /* JSDocFunctionType */: - case 234 /* FunctionDeclaration */: + case 287 /* JSDocFunctionType */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: - case 237 /* TypeAliasDeclaration */: - case 297 /* JSDocTemplateTag */: - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: - case 177 /* MappedType */: - case 171 /* ConditionalType */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: + case 240 /* TypeAliasDeclaration */: + case 300 /* JSDocTemplateTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: + case 179 /* MappedType */: + case 173 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 177 /* MappedType */) { + if (node.kind === 179 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 171 /* ConditionalType */) { + else if (node.kind === 173 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && + (node.kind === 238 /* ClassDeclaration */ || node.kind === 207 /* ClassExpression */ || node.kind === 239 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -33905,7 +33945,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, 236 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -33914,9 +33954,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 235 /* ClassDeclaration */ || - node.kind === 205 /* ClassExpression */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 238 /* ClassDeclaration */ || + node.kind === 207 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -33950,15 +33990,7 @@ var ts; return false; } function getBaseTypeNodeOfClass(type) { - var decl = type.symbol.valueDeclaration; - if (ts.isInJavaScriptFile(decl)) { - // Prefer an @augments tag because it may have type parameters. - var tag = ts.getJSDocAugmentsTag(decl); - if (tag) { - return tag.class; - } - } - return ts.getClassExtendsHeritageClauseElement(decl); + return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); } function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); @@ -33981,7 +34013,7 @@ var ts; function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { var decl = type.symbol.valueDeclaration; - var extended = ts.getClassExtendsHeritageClauseElement(decl); + var extended = ts.getEffectiveBaseTypeNode(decl); var baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; @@ -34014,7 +34046,7 @@ var ts; function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { - type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray))]; } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { if (type.symbol.flags & 32 /* Class */) { @@ -34077,7 +34109,7 @@ var ts; // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a // partial instantiation of the members without the base types fully resolved - type.members = undefined; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -34102,7 +34134,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 239 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -34138,7 +34170,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 236 /* InterfaceDeclaration */) { + if (declaration.kind === 239 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -34196,7 +34228,7 @@ var ts; return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 240 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. @@ -34223,7 +34255,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 200 /* BinaryExpression */) { + else if (expr.kind === 202 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -34237,12 +34269,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 71 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -34256,7 +34288,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -34283,7 +34315,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 238 /* EnumDeclaration */) { + if (declaration.kind === 241 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 @@ -34373,7 +34405,7 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 178 /* LiteralType */: + case 180 /* LiteralType */: return true; case 167 /* ArrayType */: return isThislessType(node.elementType); @@ -34753,6 +34785,28 @@ var ts; return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); } + function getExpandedParameters(sig) { + if (sig.hasRestParameter) { + var restIndex_1 = sig.parameters.length - 1; + var restParameter = sig.parameters[restIndex_1]; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var elementTypes = restType.typeArguments || ts.emptyArray; + var minLength_1 = restType.target.minLength; + var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; + var restParams = ts.map(elementTypes, function (t, i) { + var name = getParameterNameAtPosition(sig, restIndex_1 + i); + var checkFlags = i === tupleRestIndex_1 ? 8192 /* RestParameter */ : + i >= minLength_1 ? 4096 /* OptionalParameter */ : 0; + var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); + symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t; + return symbol; + }); + return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams); + } + } + return sig.parameters; + } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); @@ -34930,6 +34984,7 @@ var ts; function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); @@ -34938,6 +34993,7 @@ var ts; setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & 2048 /* TypeLiteral */) { + setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = getMembersOfSymbol(symbol); var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); @@ -35096,7 +35152,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 175 /* TypeOperator */ && + return constraintDeclaration.kind === 177 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -35216,6 +35272,17 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { + return obj.properties.some(function (property) { + var name = property.name && ts.getTextOfPropertyName(property.name); + var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + var actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); if (!(unionType.flags & 262144 /* Union */)) { @@ -35673,10 +35740,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJavaScriptFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 283 /* JSDocOptionalType */ + node.type && node.type.kind === 286 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -35695,7 +35762,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= signature.minArgumentCount; + return parameterIndex >= getMinArgumentCount(signature); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -35710,7 +35777,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 286 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -35805,7 +35872,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 178 /* LiteralType */) { + if (type && type.kind === 180 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -35853,9 +35920,8 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 8192 /* RestParameter */); syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; - syntheticArgsSymbol.isRestParameter = true; if (lastParamVariadicType) { // Replace the last parameter with a rest parameter. parameters.pop(); @@ -35961,9 +36027,9 @@ var ts; signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; } else { - var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? - createTypePredicateFromTypePredicateNode(declaration.type) : + var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ? + createTypePredicateFromTypePredicateNode(type) : noTypePredicate; } ts.Debug.assert(!!signature.resolvedTypePredicate); @@ -36006,16 +36072,13 @@ var ts; return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.last(signature.parameters)); - if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; + var type = getTypeOfRestParameter(signature); + return type && getIndexTypeOfType(type, 1 /* Number */) || anyType; } function getSignatureInstantiation(signature, typeArguments, isJavascript) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); + return getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript)); + } + function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) { var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -36117,32 +36180,40 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - // When an 'infer T' declaration is immediately contained in a type reference node - // (such as 'Foo'), T's constraint is inferred from the constraint of the - // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are - // present, we form an intersection of the inferred constraint types. - if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { - var typeReference = declaration.parent.parent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(declaration.parent); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); - if (declaredConstraint) { - // Type parameter constraints can reference other type parameters so - // constraints need to be instantiated. If instantiation produces the - // type parameter itself, we discard that inference. For example, in - // type Foo = [T, U]; - // type Bar = T extends Foo ? Foo : T; - // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); - var constraint = instantiateType(declaredConstraint, mapper); - if (constraint !== typeParameter) { - inferences = ts.append(inferences, constraint); + if (declaration.parent.kind === 174 /* InferType */) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + var grandParent = declaration.parent.parent; + if (grandParent.kind === 162 /* TypeReference */) { + var typeReference = grandParent; + var typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + var index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = ts.append(inferences, constraint); + } } } } } + // When an 'infer T' declaration is immediately contained in a rest parameter + // declaration, we infer an 'unknown[]' constraint. + else if (grandParent.kind === 149 /* Parameter */ && grandParent.dotDotDotToken) { + inferences = ts.append(inferences, createArrayType(unknownType)); + } } } } @@ -36237,7 +36308,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 290 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 293 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -36296,7 +36367,7 @@ var ts; switch (node.kind) { case 162 /* TypeReference */: return node.typeName; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -36389,9 +36460,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 289 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 173 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -36503,9 +36574,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 241 /* EnumDeclaration */: return declaration; } } @@ -36626,18 +36697,26 @@ var ts; // // Note that the generic type created by this function has no symbol associated with it. The same // is true for each of the synthesized type parameters. - function createTupleTypeOfArity(arity) { - var typeParameters = []; + function createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var typeParameters; var properties = []; - for (var i = 0; i < arity; i++) { - var typeParameter = createType(65536 /* TypeParameter */); - typeParameters.push(typeParameter); - var property = createSymbol(4 /* Property */, "" + i); - property.type = typeParameter; - properties.push(property); + var maxLength = hasRestElement ? arity - 1 : arity; + if (arity) { + typeParameters = new Array(arity); + for (var i = 0; i < arity; i++) { + var typeParameter = typeParameters[i] = createType(65536 /* TypeParameter */); + if (i < maxLength) { + var property = createSymbol(4 /* Property */ | (i >= minLength ? 16777216 /* Optional */ : 0), "" + i); + property.type = typeParameter; + properties.push(property); + } + } } + var literalTypes = []; + for (var i = minLength; i <= maxLength; i++) + literalTypes.push(getLiteralType(i)); var lengthSymbol = createSymbol(4 /* Property */, "length"); - lengthSymbol.type = getLiteralType(arity); + lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes); properties.push(lengthSymbol); var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); type.typeParameters = typeParameters; @@ -36655,21 +36734,47 @@ var ts; type.declaredConstructSignatures = ts.emptyArray; type.declaredStringIndexInfo = undefined; type.declaredNumberIndexInfo = undefined; + type.minLength = minLength; + type.hasRestElement = hasRestElement; + type.associatedNames = associatedNames; return type; } - function getTupleTypeOfArity(arity) { - return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + function getTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames) { + var key = arity + (hasRestElement ? "+" : ",") + minLength + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : ""); + var type = tupleTypes.get(key); + if (!type) { + tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, associatedNames)); + } + return type; } - function createTupleType(elementTypes) { - return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); + function createTupleType(elementTypes, minLength, hasRestElement, associatedNames) { + if (minLength === void 0) { minLength = elementTypes.length; } + if (hasRestElement === void 0) { hasRestElement = false; } + var arity = elementTypes.length; + if (arity === 1 && hasRestElement) { + return createArrayType(elementTypes[0]); + } + var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, associatedNames); + return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } function getTypeFromTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement_1 = lastElement && lastElement.kind === 170 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 169 /* OptionalType */ && n !== restElement_1; }) + 1; + var elementTypes = ts.map(node.elementTypes, function (n) { + var type = getTypeFromTypeNode(n); + return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; + }); + links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1); } return links.resolvedType; } + function getTypeFromOptionalTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getOptionalType(type) : type; + } function getTypeId(type) { return type.id; } @@ -37063,7 +37168,7 @@ var ts; if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getLateBoundSymbol(prop).nameType; if (!type && !ts.isKnownSymbol(prop)) { - var name = ts.getNameOfDeclaration(prop.valueDeclaration); + var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); @@ -37128,7 +37233,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -37148,6 +37253,12 @@ var ts; } return getTypeOfSymbol(prop); } + if (isTupleType(objectType)) { + var restType = getRestTypeOfTupleType(objectType); + if (restType && isNumericLiteralName(propName) && +propName >= 0) { + return restType; + } + } } if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { @@ -37158,7 +37269,7 @@ var ts; undefined; if (indexInfo) { if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -37175,14 +37286,22 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } else { - error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + var suggestion = void 0; + if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) { + if (suggestion !== undefined) { + error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion); + } + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } } } return anyType; } } if (accessNode) { - var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 188 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } @@ -37288,7 +37407,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to 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 (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 188 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -37428,7 +37547,7 @@ var ts; return true; } while (node) { - if (node.kind === 171 /* ConditionalType */) { + if (node.kind === 173 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -37526,7 +37645,10 @@ var ts; resolveImportSymbolType(node, links, moduleSymbol_1, targetMeaning); } else { - error(node, targetMeaning === 67216319 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + var errorMessage = targetMeaning === 67216319 /* Value */ + ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here + : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; + error(node, errorMessage, moduleName); links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -37732,7 +37854,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 239 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -37751,8 +37873,8 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: return anyType; case 142 /* UnknownKeyword */: return unknownType; @@ -37774,16 +37896,16 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 174 /* ThisType */: + case 176 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 162 /* TypeReference */: return getTypeFromTypeReference(node); case 161 /* TypePredicate */: return booleanType; - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); @@ -37791,38 +37913,41 @@ var ts; return getTypeFromArrayTypeNode(node); case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return getTypeFromOptionalTypeNode(node); + case 171 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 173 /* ParenthesizedType */: - case 282 /* JSDocNonNullableType */: - case 278 /* JSDocTypeExpression */: + case 175 /* ParenthesizedType */: + case 170 /* RestType */: + case 285 /* JSDocNonNullableType */: + case 281 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); case 163 /* FunctionType */: case 164 /* ConstructorType */: case 166 /* TypeLiteral */: - case 287 /* JSDocTypeLiteral */: - case 284 /* JSDocFunctionType */: - case 288 /* JSDocSignature */: + case 290 /* JSDocTypeLiteral */: + case 287 /* JSDocFunctionType */: + case 291 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 172 /* InferType */: + case 174 /* InferType */: return getTypeFromInferTypeNode(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode @@ -37971,7 +38096,7 @@ 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(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | (ts.getCheckFlags(symbol) & 1024 /* Late */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (1024 /* Late */ | 4096 /* OptionalParameter */ | 8192 /* RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -37982,11 +38107,6 @@ var ts; if (symbol.nameType) { result.nameType = symbol.nameType; } - if (isTransientSymbol(symbol)) { - if (symbol.isRestParameter) { - result.isRestParameter = symbol.isRestParameter; - } - } return result; } function getAnonymousTypeInstantiation(type, mapper) { @@ -38051,14 +38171,14 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 213 /* Block */ ? "quit" : n === container_3; })) { + if (ts.findAncestor(node, function (n) { return n.kind === 216 /* Block */ ? "quit" : n === container_3; })) { return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 174 /* ThisType */: + case 176 /* ThisType */: return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && @@ -38196,32 +38316,32 @@ var ts; function isContextSensitive(node) { ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive); - case 262 /* JsxAttribute */: { + case 265 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 265 /* JsxExpression */: { + case 268 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -38238,7 +38358,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 193 /* ArrowFunction */) { + if (node.kind !== 195 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -38248,7 +38368,7 @@ var ts; } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. var body = node.body; - return body.kind === 213 /* Block */ ? false : isContextSensitive(body); + return body.kind === 216 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -38318,8 +38438,206 @@ var ts; function areTypesComparable(type1, type2) { return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); } - function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) { + if (isTypeAssignableTo(source, target)) + return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + function elaborateError(node, source, target) { + if (!node) + return false; + switch (node.kind) { + case 268 /* JsxExpression */: + case 193 /* ParenthesizedExpression */: + return elaborateError(node.expression, source, target); + case 202 /* BinaryExpression */: + switch (node.operatorToken.kind) { + case 58 /* EqualsToken */: + case 26 /* CommaToken */: + return elaborateError(node.right, source, target); + } + break; + case 186 /* ObjectLiteralExpression */: + return elaborateObjectLiteral(node, source, target); + case 185 /* ArrayLiteralExpression */: + return elaborateArrayLiteral(node, source, target); + case 266 /* JsxAttributes */: + return elaborateJsxAttributes(node, source, target); + } + return false; + } + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator, source, target) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + var reportedError = false; + for (var status = iterator.next(); !status.done; status = iterator.next()) { + var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; + var sourcePropType = getIndexedAccessType(source, nameType); + var targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + var elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + var resultObj = {}; + // Use the expression type, if available + var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + var reportedDiag = resultObj.error; + var propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + var issuedElaboration = false; + if (!targetProp) { + var indexInfo = isTypeAssignableToKind(nameType, 168 /* NumberLike */) && getIndexInfoOfType(target, 1 /* Number */) || + getIndexInfoOfType(target, 0 /* String */) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + if (!issuedElaboration && (ts.length(targetProp && targetProp.declarations) || ts.length(target.symbol && target.symbol.declarations))) { + addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetProp ? targetProp.declarations[0] : target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 2048 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + } + } + reportedError = true; + } + } + } + return reportedError; + } + function generateJsxAttributes(node) { + var _i, _a, prop; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _b.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 4]; + prop = _a[_i]; + if (ts.isJsxSpreadAttribute(prop)) + return [3 /*break*/, 3]; + return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateJsxAttributes(node, source, target) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + function generateLimitedTupleElements(node, target) { + var len, i, elem, nameType; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + len = ts.length(node.elements); + if (!len) + return [2 /*return*/]; + i = 0; + _a.label = 1; + case 1: + if (!(i < len)) return [3 /*break*/, 4]; + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i))) + return [3 /*break*/, 3]; + elem = node.elements[i]; + if (ts.isOmittedExpression(elem)) + return [3 /*break*/, 3]; + nameType = getLiteralType(i); + return [4 /*yield*/, { errorNode: elem, innerExpression: elem, nameType: nameType }]; + case 2: + _a.sent(); + _a.label = 3; + case 3: + i++; + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + } + function elaborateArrayLiteral(node, source, target) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); + } + return false; + } + function generateObjectLiteralElements(node) { + var _i, _a, prop, type, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + if (!ts.length(node.properties)) + return [2 /*return*/]; + _i = 0, _a = node.properties; + _c.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + prop = _a[_i]; + if (ts.isSpreadAssignment(prop)) + return [3 /*break*/, 7]; + type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), 2240 /* StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 32768 /* Never */)) { + return [3 /*break*/, 7]; + } + _b = prop.kind; + switch (_b) { + case 157 /* SetAccessor */: return [3 /*break*/, 2]; + case 156 /* GetAccessor */: return [3 /*break*/, 2]; + case 154 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 274 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 273 /* PropertyAssignment */: return [3 /*break*/, 4]; + } + return [3 /*break*/, 6]; + case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; + case 3: + _c.sent(); + return [3 /*break*/, 7]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 5: + _c.sent(); + return [3 /*break*/, 7]; + case 6: + ts.Debug.assertNever(prop); + _c.label = 7; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + } + function elaborateObjectLiteral(node, source, target) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** * This is *not* a bi-directional relationship. @@ -38340,13 +38658,20 @@ var ts; if (source === target) { return -1 /* True */; } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { + var targetCount = getParameterCount(target); + if (!hasEffectiveRestParameter(target) && getMinArgumentCount(source) > targetCount) { return 0 /* False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } + var sourceCount = getParameterCount(source); + var sourceRestTypeParameter = getRestTypeParameter(source); + var targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; + if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + return 0 /* False */; + } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; @@ -38367,14 +38692,11 @@ var ts; result &= related; } } - var sourceMax = getNumNonRestParameters(source); - var targetMax = getNumNonRestParameters(target); - var checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax); - var sourceParams = source.parameters; - var targetParams = target.parameters; - for (var i = 0; i < checkCount; i++) { - var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var paramCount = Math.max(sourceCount, targetCount); + var lastIndex = paramCount - 1; + for (var i = 0; i < paramCount; i++) { + var sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); + var targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -38393,7 +38715,7 @@ var ts; !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { - errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.symbolName(sourceParams[i < sourceMax ? i : sourceMax]), ts.symbolName(targetParams[i < targetMax ? i : targetMax])); + errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } return 0 /* False */; } @@ -38468,30 +38790,6 @@ var ts; } return false; } - function getNumNonRestParameters(signature) { - var numParams = signature.parameters.length; - return signature.hasRestParameter ? - numParams - 1 : - numParams; - } - function getNumParametersToCheckForSignatureRelatability(source, sourceNonRestParamCount, target, targetNonRestParamCount) { - if (source.hasRestParameter === target.hasRestParameter) { - if (source.hasRestParameter) { - // If both have rest parameters, get the max and add 1 to - // compensate for the rest parameter. - return Math.max(sourceNonRestParamCount, targetNonRestParamCount) + 1; - } - else { - return Math.min(sourceNonRestParamCount, targetNonRestParamCount); - } - } - else { - // Return the count for whichever signature doesn't have rest parameters. - return source.hasRestParameter ? - targetNonRestParamCount : - sourceNonRestParamCount; - } - } function isEmptyResolvedType(t) { return t.properties.length === 0 && t.callSignatures.length === 0 && @@ -38512,11 +38810,11 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { + return relation === 1 /* Succeeded */; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, false); + enumRelation.set(id, 3 /* FailedAndReported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -38527,13 +38825,16 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); + enumRelation.set(id, 3 /* FailedAndReported */); + } + else { + enumRelation.set(id, 2 /* Failed */); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, 1 /* Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { @@ -38624,7 +38925,7 @@ var ts; * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { + function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) { var errorInfo; var maybeKeys; var sourceStack; @@ -38654,12 +38955,16 @@ var ts; var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - var diag = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); - relatedInformation = ts.append(relatedInformation, diag); // Cause the error to appear with the error that triggered it + var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead); + relatedInformation = ts.append(relatedInformation, diag_1); // Cause the error to appear with the error that triggered it } } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation)); // TODO: GH#18217 + var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { @@ -38741,6 +39046,22 @@ var ts; if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & 262144 /* Union */ && source.flags & 131072 /* Object */ && + target.types.length <= 3 && maybeTypeOfKind(target, 24576 /* Nullable */)) { + var nullStrippedTarget = extractTypesOfKind(target, ~24576 /* Nullable */); + if (!(nullStrippedTarget.flags & (262144 /* Union */ | 32768 /* Never */))) { + target = nullStrippedTarget; + } + } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; @@ -38992,11 +39313,29 @@ var ts; } } if (reportErrors) { - var discriminantType = findMatchingDiscriminantType(source, target); - isRelatedTo(source, discriminantType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + var bestMatchingType = findMatchingDiscriminantType(source, target) || + findMatchingTypeReferenceOrTypeAliasReference(source, target); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } return 0 /* False */; } + function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { + var sourceObjectFlags = ts.getObjectFlags(source); + if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 262144 /* Union */) { + return ts.find(unionTarget.types, function (target) { + if (target.flags & 131072 /* Object */) { + var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); + if (overlapObjFlags & 4 /* Reference */) { + return source.target === target.target; + } + if (overlapObjFlags & 16 /* Anonymous */) { + return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; + } + } + return false; + }); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target) { var match; @@ -39128,9 +39467,8 @@ var ts; 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.set(id, 3 /* FailedAndReported */); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -39417,7 +39755,7 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } - var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source); + var requireOptionalProperties = relation === subtypeRelation && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); if (unmatchedProperty) { if (reportErrors) { @@ -39440,6 +39778,33 @@ var ts; } } var result = -1 /* True */; + if (isTupleType(target)) { + var targetRestType = getRestTypeOfTupleType(target); + if (targetRestType) { + if (!isTupleType(source)) { + return 0 /* False */; + } + var sourceRestType = getRestTypeOfTupleType(source); + if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) { + if (reportErrors) { + reportError(ts.Diagnostics.Rest_signatures_are_incompatible); + } + return 0 /* False */; + } + var targetCount = getTypeReferenceArity(target) - 1; + var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + for (var i = targetCount; i < sourceCount; i++) { + var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + if (!related) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); + } + return 0 /* False */; + } + result &= related; + } + } + } var properties = getPropertiesOfObjectType(target); for (var _b = 0, properties_3 = properties; _b < properties_3.length; _b++) { var targetProp = properties_3[_b]; @@ -39961,20 +40326,26 @@ var ts; return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } function isMatchingSignature(source, target, partialMatch) { + var sourceParameterCount = getParameterCount(source); + var targetParameterCount = getParameterCount(target); + var sourceMinArgumentCount = getMinArgumentCount(source); + var targetMinArgumentCount = getMinArgumentCount(target); + var sourceHasRestParameter = hasEffectiveRestParameter(source); + var targetHasRestParameter = hasEffectiveRestParameter(target); // A source signature matches a target signature if the two signatures have the same number of required, // optional, and rest parameters. - if (source.parameters.length === target.parameters.length && - source.minArgumentCount === target.minArgumentCount && - source.hasRestParameter === target.hasRestParameter) { + if (sourceParameterCount === targetParameterCount && + sourceMinArgumentCount === targetMinArgumentCount && + sourceHasRestParameter === targetHasRestParameter) { return true; } // A source signature partially matches a target signature if the target signature has no fewer required // parameters and no more overall parameters than the source signature (where a signature with a rest // parameter is always considered to have more overall parameters than one without). - var sourceRestCount = source.hasRestParameter ? 1 : 0; - var targetRestCount = target.hasRestParameter ? 1 : 0; - if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (sourceRestCount > targetRestCount || - sourceRestCount === targetRestCount && source.parameters.length >= target.parameters.length)) { + var sourceRestCount = sourceHasRestParameter ? 1 : 0; + var targetRestCount = targetHasRestParameter ? 1 : 0; + if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount && (sourceRestCount > targetRestCount || + sourceRestCount === targetRestCount && sourceParameterCount >= targetParameterCount)) { return true; } return false; @@ -40016,10 +40387,10 @@ var ts; } } } - var targetLen = target.parameters.length; + var targetLen = getParameterCount(target); for (var i = 0; i < targetLen; i++) { - var s = isRestParameterIndex(source, i) ? getRestTypeOfSignature(source) : getTypeOfParameter(source.parameters[i]); - var t = isRestParameterIndex(target, i) ? getRestTypeOfSignature(target) : getTypeOfParameter(target.parameters[i]); + var s = getTypeAtPosition(source, i); + var t = getTypeAtPosition(target, i); var related = compareTypes(s, t); if (!related) { return 0 /* False */; @@ -40039,9 +40410,6 @@ var ts; function compareTypePredicatesIdentical(source, target, compareTypes) { return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); } - function isRestParameterIndex(signature, parameterIndex) { - return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; - } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -40091,7 +40459,12 @@ var ts; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { - return !!getPropertyOfType(type, "0"); + return isTupleType(type) || !!getPropertyOfType(type, "0"); + } + function getTupleElementType(type, index) { + return isTupleType(type) ? + index < getLengthOfTupleType(type) ? type.typeArguments[index] : getRestTypeOfTupleType(type) : + getTypeOfPropertyOfType(type, "" + index); } function isNeitherUnitTypeNorNever(type) { return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); @@ -40138,6 +40511,12 @@ var ts; function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } + function getRestTypeOfTupleType(type) { + return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + } + function getLengthOfTupleType(type) { + return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0); + } function getFalsyFlagsOfTypes(types) { var result = 0; for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { @@ -40197,7 +40576,7 @@ var ts; if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, 524288 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -40410,7 +40789,7 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; @@ -40420,23 +40799,23 @@ var ts; ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 177 /* MappedType */: + case 179 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -40453,24 +40832,22 @@ var ts; } } function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = Math.max(sourceMax, targetMax); - } - else if (source.hasRestParameter) { - count = targetMax; - } - else if (target.hasRestParameter) { - count = sourceMax; - } - else { - count = Math.min(sourceMax, targetMax); - } - for (var i = 0; i < count; i++) { + var sourceCount = getParameterCount(source); + var targetCount = getParameterCount(target); + var sourceHasRest = hasEffectiveRestParameter(source); + var targetHasRest = hasEffectiveRestParameter(target); + var maxCount = sourceHasRest && targetHasRest ? Math.max(sourceCount, targetCount) : + sourceHasRest ? targetCount : + targetHasRest ? sourceCount : + Math.min(sourceCount, targetCount); + var targetRestTypeVariable = getRestTypeParameter(target); + var paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + for (var i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } + if (targetRestTypeVariable) { + callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable); + } } function createInferenceContext(typeParameters, signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : typeParameters.map(createInferenceInfo); @@ -40609,10 +40986,14 @@ var ts; } return undefined; } + function tupleTypesDefinitelyUnrelated(source, target) { + return target.target.minLength > source.target.minLength || + !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source)); + } function typesDefinitelyUnrelated(source, target) { - // Two tuple types with different arity are definitely unrelated. + // Two tuple types with incompatible arities are definitely unrelated. // Two object types that each have a property that is unmatched in the other are definitely unrelated. - return isTupleType(source) && isTupleType(target) && getTypeReferenceArity(source) !== getTypeReferenceArity(target) || + return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) || !!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) && !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false); } function getTypeFromInference(inference) { @@ -40895,12 +41276,33 @@ var ts; } } function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + if (isTupleType(source) && isTupleType(target)) { + var sourceLength = getLengthOfTupleType(source); + var targetLength = getLengthOfTupleType(target); + var sourceRestType = getRestTypeOfTupleType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + } + else { + var properties = getPropertiesOfObjectType(target); + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp) { + inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } } } } @@ -41015,17 +41417,14 @@ var ts; if (!inferredType) { var signature = context.signature; if (signature) { + if (inference.contraCandidates) { + // If we have contravariant inferences we find the best common subtype and treat + // that as a single covariant candidate. + inference.candidates = ts.append(inference.candidates, getContravariantInference(inference)); + inference.contraCandidates = undefined; + } if (inference.candidates) { inferredType = getCovariantInference(inference, context, signature); - // If we have inferred 'never' but have contravariant candidates. To get a more specific type we - // infer from the contravariant candidates instead. - if (inferredType.flags & 32768 /* Never */ && inference.contraCandidates) { - inferredType = getContravariantInference(inference); - } - } - else if (inference.contraCandidates) { - // We only have contravariant inferences, infer the best common subtype of those - inferredType = getContravariantInference(inference); } else if (context.flags & 2 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -41102,13 +41501,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 185 /* PropertyAccessExpression */) { + if (node.kind === 187 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 182 /* BindingElement */) { + if (node.kind === 184 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 184 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -41117,7 +41516,7 @@ var ts; } function getBindingElementNameText(element) { var parent = element.parent; - if (parent.kind === 180 /* ObjectBindingPattern */) { + if (parent.kind === 182 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: @@ -41140,26 +41539,26 @@ var ts; switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && + (target.kind === 235 /* VariableDeclaration */ || target.kind === 184 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 185 /* PropertyAccessExpression */: - return target.kind === 185 /* PropertyAccessExpression */ && + case 187 /* PropertyAccessExpression */: + return target.kind === 187 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 182 /* BindingElement */: - if (target.kind !== 185 /* PropertyAccessExpression */) + case 184 /* BindingElement */: + if (target.kind !== 187 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 184 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 232 /* VariableDeclaration */) { + if (source.parent.parent.kind === 235 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; return !!maybeId && isMatchingReference(maybeId, t.expression); } @@ -41167,7 +41566,7 @@ var ts; return false; } function containsMatchingReference(source, target) { - while (source.kind === 185 /* PropertyAccessExpression */) { + while (source.kind === 187 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -41180,7 +41579,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 === 185 /* PropertyAccessExpression */ && + return target.kind === 187 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -41188,7 +41587,7 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 185 /* PropertyAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } @@ -41232,7 +41631,7 @@ var ts; } } } - if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 187 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -41358,7 +41757,7 @@ var ts; errorType; } function getTypeOfDestructuredArrayElement(type, index) { - return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || + return isTupleLikeType(type) && getTupleElementType(type, index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; } @@ -41366,15 +41765,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 185 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 273 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 225 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -41391,21 +41790,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return stringType; - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return undefinedType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -41413,7 +41812,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 180 /* ObjectBindingPattern */ ? + var type = pattern.kind === 182 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -41431,35 +41830,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 221 /* ForInStatement */) { + if (node.parent.parent.kind === 224 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 222 /* ForOfStatement */) { + if (node.parent.parent.kind === 225 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 232 /* VariableDeclaration */ ? + return node.kind === 235 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? + return node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 232 /* VariableDeclaration */ && node.initializer && + return node.kind === 235 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && + node.kind !== 184 /* BindingElement */ && node.parent.kind === 202 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -41471,13 +41870,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 191 /* ParenthesizedExpression */ || - parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 193 /* ParenthesizedExpression */ || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -41640,11 +42039,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 185 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 187 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 186 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 187 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 189 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 188 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 200 /* BinaryExpression */ && + parent.parent.kind === 202 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -41692,7 +42091,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 = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { + if (reference.parent && reference.parent.kind === 211 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -41763,7 +42162,7 @@ var ts; else if (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 !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 187 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -41819,7 +42218,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 187 /* CallExpression */ ? + var expr = node.kind === 189 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -41827,7 +42226,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -41992,7 +42391,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 185 /* PropertyAccessExpression */ && + return expr.kind === 187 /* PropertyAccessExpression */ && computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); @@ -42043,10 +42442,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 === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 197 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -42261,7 +42660,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 188 /* ElementAccessExpression */ || invokedExpression.kind === 187 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -42281,15 +42680,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -42325,8 +42724,8 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 240 /* ModuleBlock */ || - node.kind === 274 /* SourceFile */ || + node.kind === 243 /* ModuleBlock */ || + node.kind === 277 /* SourceFile */ || node.kind === 152 /* PropertyDeclaration */; }); } @@ -42372,10 +42771,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 185 /* PropertyAccessExpression */ || - parent.kind === 187 /* CallExpression */ && parent.expression === node || - parent.kind === 186 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 182 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 187 /* PropertyAccessExpression */ || + parent.kind === 189 /* CallExpression */ && parent.expression === node || + parent.kind === 188 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 184 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); @@ -42409,7 +42808,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 */)) { @@ -42430,7 +42829,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.kind === 235 /* ClassDeclaration */ + if (declaration.kind === 238 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -42442,12 +42841,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 205 /* ClassExpression */) { + else if (declaration.kind === 207 /* 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.kind !== 274 /* SourceFile */) { + while (container.kind !== 277 /* SourceFile */) { if (container.parent === declaration) { if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; @@ -42497,23 +42896,23 @@ var ts; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - var isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); // 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 === 192 /* FunctionExpression */ || - flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 194 /* FunctionExpression */ || + flowContainer.kind === 195 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). - var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || + var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 252 /* ExportSpecifier */) || - node.parent.kind === 209 /* NonNullExpression */ || - declaration.kind === 232 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 255 /* ExportSpecifier */) || + node.parent.kind === 211 /* NonNullExpression */ || + declaration.kind === 235 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -42544,7 +42943,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 272 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -42569,8 +42968,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 === 220 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && + if (container.kind === 223 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 236 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -42584,7 +42983,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 191 /* ParenthesizedExpression */) { + while (current.parent.kind === 193 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -42592,7 +42991,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 200 /* PrefixUnaryExpression */ || current.parent.kind === 201 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -42650,7 +43049,7 @@ var ts; } function checkThisBeforeSuper(node, container, diagnosticMessage) { var containingClassDecl = container.parent; - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); + var baseTypeNode = ts.getEffectiveBaseTypeNode(containingClassDecl); // If a containing class does not have extends clause or the class extends null // skip checking whether super statement is called before "this" accessing. if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -42677,17 +43076,17 @@ var ts; 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 === 193 /* ArrowFunction */) { + if (container.kind === 195 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 238 /* EnumDeclaration */: + case 241 /* 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; @@ -42725,8 +43124,8 @@ 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 === 192 /* FunctionExpression */ && - container.parent.kind === 200 /* BinaryExpression */ && + if (container.kind === 194 /* FunctionExpression */ && + container.parent.kind === 202 /* BinaryExpression */ && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.prototype.y = f @@ -42757,7 +43156,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 287 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -42774,12 +43173,12 @@ var ts; return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 189 /* 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 === 193 /* ArrowFunction */) { + while (container && container.kind === 195 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -42799,7 +43198,7 @@ var ts; 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 === 184 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -42887,7 +43286,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 184 /* ObjectLiteralExpression */) { + if (container.parent.kind === 186 /* 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 errorType; @@ -42899,7 +43298,7 @@ var ts; } // at this point the only legal case for parent is ClassLikeDeclaration var classLikeDeclaration = container.parent; - if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { + if (!ts.getEffectiveBaseTypeNode(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); return errorType; } @@ -42931,7 +43330,7 @@ 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 === 184 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 186 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { return container.kind === 154 /* MethodDeclaration */ || container.kind === 153 /* MethodSignature */ || @@ -42955,8 +43354,8 @@ var ts; function getContainingObjectLiteral(func) { return (func.kind === 154 /* MethodDeclaration */ || func.kind === 156 /* GetAccessor */ || - func.kind === 157 /* SetAccessor */) && func.parent.kind === 184 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 192 /* FunctionExpression */ && func.parent.kind === 270 /* PropertyAssignment */ ? func.parent.parent : + func.kind === 157 /* SetAccessor */) && func.parent.kind === 186 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 194 /* FunctionExpression */ && func.parent.kind === 273 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -42968,7 +43367,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 193 /* ArrowFunction */) { + if (func.kind === 195 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -42995,7 +43394,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 270 /* PropertyAssignment */) { + if (literal.parent.kind !== 273 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -43009,9 +43408,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 202 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { + if (target.kind === 187 /* PropertyAccessExpression */ || target.kind === 188 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -43034,27 +43433,24 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - var restTypes = []; - for (var i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; links.resolvedSignature = anySignature; - var type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + var type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } var contextualSignature = getContextualSignature(func); if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameter(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var funcHasRestParameter = ts.hasRestParameter(func); + var len = func.parameters.length - (funcHasRestParameter ? 1 : 0); var indexOfParameter = func.parameters.indexOf(parameter); if (ts.getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { ts.Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. @@ -43064,10 +43460,8 @@ var ts; return getTypeAtPosition(contextualSignature, indexOfParameter); } // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === (func.parameters.length - 1) && - isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.last(contextualSignature.parameters)); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -43098,7 +43492,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 182 /* BindingElement */) { + if (parentDeclaration.kind !== 184 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -43180,7 +43574,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 189 /* TaggedTemplateExpression */) { + if (template.parent.kind === 191 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -43228,8 +43622,19 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; - return prop ? getTypeOfSymbol(prop) : undefined; + if (t.flags & 917504 /* StructuredType */) { + var prop = getPropertyOfType(t, name); + if (prop) { + return getTypeOfSymbol(prop); + } + if (isTupleType(t)) { + var restType = getRestTypeOfTupleType(t); + if (restType && isNumericLiteralName(name) && +name >= 0) { + return restType; + } + } + } + return undefined; }, /*noReductions*/ true); } function getIndexTypeOfContextualType(type, kind) { @@ -43258,8 +43663,8 @@ var ts; // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. - var symbolName_1 = getSymbolOfNode(element).escapedName; - var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_1); + var symbolName_3 = getSymbolOfNode(element).escapedName; + var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { return propertyType; } @@ -43325,8 +43730,8 @@ var ts; case 95 /* NullKeyword */: case 71 /* Identifier */: return true; - case 185 /* PropertyAccessExpression */: - case 191 /* ParenthesizedExpression */: + case 187 /* PropertyAccessExpression */: + case 193 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); } return false; @@ -43345,14 +43750,14 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 270 /* PropertyAssignment */) + if (prop.kind !== 273 /* PropertyAssignment */) continue; if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine @@ -43393,52 +43798,52 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 193 /* ArrowFunction */: - case 225 /* ReturnStatement */: + case 195 /* ArrowFunction */: + case 228 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 187 /* CallExpression */: - case 188 /* NewExpression */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 183 /* ArrayLiteralExpression */: { + case 185 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 211 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); + case 214 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 204 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 191 /* ParenthesizedExpression */: { + case 193 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 262 /* JsxAttribute */: - case 264 /* JsxSpreadAttribute */: + case 265 /* JsxAttribute */: + case 267 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -43512,6 +43917,7 @@ var ts; } function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -43522,8 +43928,24 @@ var ts; var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { + var managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (ts.length(declaredManagedType.typeParameters) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.typeParameters, 2, ts.isInJavaScriptFile(context)); + return createTypeReference(declaredManagedType, args); + } + else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { + var args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); + } + } + return attributesType; + } function getJsxPropsTypeFromClassType(sig, isJs, context, reportErrors) { - var forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); + var ns = getJsxNamespaceAt(context); + var forcedLookupLocation = getJsxElementPropertiesName(ns); var attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) @@ -43539,7 +43961,8 @@ var ts; } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -43584,11 +44007,10 @@ var ts; if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) { targetParameterCount--; } - var sourceLength = signature.hasRestParameter ? Number.MAX_VALUE : signature.parameters.length; - return sourceLength < targetParameterCount; + return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; + return node.kind === 194 /* FunctionExpression */ || node.kind === 195 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -43660,18 +44082,19 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 182 /* BindingElement */ && !!node.initializer) || - (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 184 /* BindingElement */ && !!node.initializer) || + (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; - var hasSpreadElement = false; + var elementCount = elements.length; + var hasNonEndingSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); var contextualType = getApparentTypeOfContextualType(node); - for (var index = 0; index < elements.length; index++) { + for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 206 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -43696,13 +44119,17 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; + if (index < elementCount - 1 && e.kind === 206 /* SpreadElement */) { + hasNonEndingSpreadElement = true; + } } - if (!hasSpreadElement) { + if (!hasNonEndingSpreadElement) { + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 206 /* SpreadElement */; + var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - if (inDestructuringPattern && elementTypes.length) { - var type = cloneTypeReference(createTupleType(elementTypes)); + if (inDestructuringPattern && minLength > 0) { + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } @@ -43710,28 +44137,30 @@ 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 === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { + if (!hasRestElement && pattern && (pattern.kind === 183 /* ArrayBindingPattern */ || pattern.kind === 185 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; - for (var i = elementTypes.length; i < patternElements.length; i++) { - var patternElement = patternElements[i]; - if (hasDefaultValue(patternElement)) { + for (var i = elementCount; i < patternElements.length; i++) { + var e = patternElements[i]; + if (hasDefaultValue(e)) { elementTypes.push(contextualType.typeArguments[i]); } - else { - if (patternElement.kind !== 206 /* OmittedExpression */) { - error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + else if (i < patternElements.length - 1 || !(e.kind === 184 /* BindingElement */ && e.dotDotDotToken || e.kind === 206 /* SpreadElement */)) { + if (e.kind !== 208 /* OmittedExpression */) { + error(e, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); } } } - if (elementTypes.length) { - return createTupleType(elementTypes); - } + return createTupleType(elementTypes, minLength, hasRestElement); } } + return getArrayLiteralType(elementTypes, 2 /* Subtype */); + } + function getArrayLiteralType(elementTypes, unionReduction) { + if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } return createArrayType(elementTypes.length ? - getUnionType(elementTypes, 2 /* Subtype */) : + getUnionType(elementTypes, unionReduction) : strictNullChecks ? implicitNeverType : undefinedWideningType); } function isNumericName(name) { @@ -43816,7 +44245,7 @@ var ts; var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 182 /* ObjectBindingPattern */ || contextualType.pattern.kind === 186 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; @@ -43830,11 +44259,11 @@ var ts; var member = getSymbolOfNode(memberDecl); var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 270 /* PropertyAssignment */ || - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 273 /* PropertyAssignment */ || + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 273 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 274 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -43855,8 +44284,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 273 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 274 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -43881,7 +44310,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 272 /* SpreadAssignment */) { + else if (memberDecl.kind === 275 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -43975,13 +44404,16 @@ var ts; type.flags & 131072 /* Object */ && !isGenericMappedType(type) || type.flags & 786432 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node, checkMode) { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node) { + checkJsxOpeningLikeElementOrOpeningFragment(node, 0 /* Normal */); + } + function checkJsxSelfClosingElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node, checkMode) { + function checkJsxElementDeferred(node) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, 0 /* Normal */); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { getIntrinsicTagSymbol(node.closingElement); @@ -43989,6 +44421,9 @@ var ts; else { checkExpression(node.closingElement.tagName); } + } + function checkJsxElement(node, _checkMode) { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } function checkJsxFragment(node, checkMode) { @@ -44011,16 +44446,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - // TODO (yuisu): comment - switch (tagName.kind) { - case 185 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: - return false; - case 71 /* Identifier */: - return ts.isIntrinsicJsxName(tagName.escapedText); - default: - return ts.Debug.fail(); - } + return tagName.kind === 71 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -44063,7 +44489,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 267 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -44086,7 +44512,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 255 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 258 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -44247,12 +44673,24 @@ var ts; return getSignatureInstantiation(signature, args, isJavascript); } function getJsxNamespaceAt(location) { - var namespaceName = getJsxNamespace(location); - var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); - if (candidate) { - return candidate; + var links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + var namespaceName = getJsxNamespace(location); + var resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + var candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -44289,6 +44727,10 @@ var ts; } return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67901928 /* Type */); + } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -44695,7 +45137,7 @@ var ts; // 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, checkMode); + var sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties var isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. @@ -44716,31 +45158,7 @@ var ts; } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (ts.length(openingLikeElement.attributes.properties)) { - var reportedError = false; - var _loop_8 = function (prop) { - if (ts.isJsxSpreadAttribute(prop)) - return "continue"; - var name = ts.idText(prop.name); - var sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - var targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - var rootChain = function () { return ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Types_of_property_0_are_incompatible, name); }; - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - }; - for (var _b = 0, _c = openingLikeElement.attributes.properties; _b < _c.length; _b++) { - var prop = _c[_b]; - _loop_8(prop); - } - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } function checkJsxExpression(node, checkMode) { @@ -44787,9 +45205,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? + var errorNode = node.kind === 187 /* PropertyAccessExpression */ || node.kind === 235 /* VariableDeclaration */ ? node.name : - node.kind === 179 /* ImportType */ ? + node.kind === 181 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -44959,7 +45377,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 !== 185 /* PropertyAccessExpression */ || + if (node.kind !== 187 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; @@ -44991,16 +45409,21 @@ var ts; if (!valueDeclaration) { return; } + var diagnosticMessage; + var declarationName = ts.idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + else if (valueDeclaration.kind === 238 /* ClassDeclaration */ && node.parent.kind !== 162 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); + diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_was_declared_here, declarationName)); } } function isInPropertyInitializer(node) { @@ -45008,7 +45431,7 @@ var ts; switch (node.kind) { case 152 /* PropertyDeclaration */: return true; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -45064,13 +45487,19 @@ var ts; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + var suggestion_1 = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion_1 !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion_1); + } + else { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + } } } diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); } - function getSuggestionForNonexistentProperty(node, containingType) { - var suggestion = getSpellingSuggestionForName(ts.idText(node), getPropertiesOfType(containingType), 67216319 /* Value */); + function getSuggestionForNonexistentProperty(name, containingType) { + var suggestion = getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67216319 /* Value */); return suggestion && ts.symbolName(suggestion); } function getSuggestionForNonexistentSymbol(location, outerName, meaning) { @@ -45129,16 +45558,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 179 /* ImportType */: + case 181 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 181 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { @@ -45172,7 +45601,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer.kind === 236 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -45201,7 +45630,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 221 /* ForInStatement */ && + if (node.kind === 224 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -45219,7 +45648,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 190 /* 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); @@ -45286,7 +45715,7 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (node.kind !== 150 /* Decorator */) { @@ -45352,14 +45781,11 @@ var ts; result.splice(spliceIndex, 0, signature); } } + function isSpreadArgument(arg) { + return !!arg && (arg.kind === 206 /* SpreadElement */ || arg.kind === 213 /* SyntheticExpression */ && arg.isSpread); + } function getSpreadArgumentIndex(args) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - if (arg && arg.kind === 204 /* SpreadElement */) { - return i; - } - } - return -1; + return ts.findIndex(args, isSpreadArgument); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -45371,12 +45797,12 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { // 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 = node.typeArguments; - if (node.template.kind === 202 /* TemplateExpression */) { + if (node.template.kind === 204 /* 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 lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -45398,8 +45824,8 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 188 /* NewExpression */); - return signature.minArgumentCount === 0; + ts.Debug.assert(node.kind === 190 /* NewExpression */); + return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; // If we are missing the close parenthesis, the call is incomplete. @@ -45412,15 +45838,14 @@ var ts; } // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || - signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; + return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); } // Too many arguments implies incorrect arity. - if (!signature.hasRestParameter && argCount > signature.parameters.length) { + if (!hasEffectiveRestParameter(signature) && argCount > getParameterCount(signature)) { return false; } // If the call is incomplete, we should skip the lower bound check. - var hasEnoughArguments = argCount >= signature.minArgumentCount; + var hasEnoughArguments = argCount >= getMinArgumentCount(signature); return callIsIncomplete || hasEnoughArguments; } function hasCorrectTypeArgumentArity(signature, typeArguments) { @@ -45445,9 +45870,10 @@ var ts; // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper, compareTypes) { var context = createInferenceContext(signature.typeParameters, signature, 1 /* InferUnionTypes */, compareTypes); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { + var sourceSignature = contextualMapper ? instantiateSignature(contextualSignature, contextualMapper) : contextualSignature; + forEachMatchingParameterType(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type - inferTypes(context.inferences, instantiateType(source, contextualMapper || identityMapper), target); + inferTypes(context.inferences, source, target); }); if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 8 /* ReturnType */); @@ -45497,7 +45923,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : + getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -45512,11 +45938,13 @@ var ts; } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. - var argCount = getEffectiveArgumentCount(node, args, signature); + var effectiveArgCount = getEffectiveArgumentCount(node, args, signature); + var restTypeParameter = getRestTypeParameter(signature); + var argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; 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 !== 206 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -45530,6 +45958,10 @@ var ts; inferTypes(context.inferences, argType, paramType); } } + if (restTypeParameter) { + var spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); + inferTypes(context.inferences, spreadType, restTypeParameter); + } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this // time treating function expressions normally (which may cause previously inferred type arguments to be fixed // as we construct types for contextually typed parameters) @@ -45547,6 +45979,35 @@ var ts; } return getInferredTypes(context); } + function getSpreadArgumentType(node, args, index, argCount, restType, context) { + if (index >= argCount - 1) { + var arg = getEffectiveArgument(node, args, argCount - 1); + if (isSpreadArgument(arg)) { + // We are inferring from a spread expression in the last argument position, i.e. both the parameter + // and the argument are ...x forms. + return arg.kind === 213 /* SyntheticExpression */ ? + createArrayType(arg.type) : + checkExpressionWithContextualType(arg.expression, restType, context); + } + } + var contextualType = getIndexTypeOfType(restType, 1 /* Number */) || anyType; + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 32764 /* Primitive */ | 1048576 /* Index */); + var types = []; + var spreadIndex = -1; + for (var i = index; i < argCount; i++) { + var argType = getEffectiveArgumentType(node, i); + if (!argType) { + argType = checkExpressionWithContextualType(args[i], contextualType, context); + if (spreadIndex < 0 && isSpreadArgument(args[i])) { + spreadIndex = i - index; + } + } + types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); + } + return spreadIndex < 0 ? + createTupleType(types) : + createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, /*hasRestElement*/ true); + } function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) { var isJavascript = ts.isInJavaScriptFile(signature.declaration); var typeParameters = signature.typeParameters; @@ -45606,7 +46067,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 188 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 190 /* 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. @@ -45620,24 +46081,32 @@ var ts; } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; var argCount = getEffectiveArgumentCount(node, args, signature); + var restIndex = signature.hasRestParameter ? signature.parameters.length - 1 : -1; + var restType = restIndex >= 0 ? getTypeOfSymbol(signature.parameters[restIndex]) : anyType; 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 !== 206 /* OmittedExpression */) { - // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) - var paramType = getTypeAtPosition(signature, i); - // If the effective argument type is undefined, there is no synthetic type for the argument. - // In that case, we should check the argument. - var argType = getEffectiveArgumentType(node, i) || - checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), - // we obtain the regular type of any object literal arguments because we may not have inferred complete - // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; - // Use argument expression as error location when reporting errors - var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; - if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { - return false; + if (arg === undefined || arg.kind !== 208 /* OmittedExpression */) { + if (i === restIndex && (restType.flags & 65536 /* TypeParameter */ || isSpreadArgument(arg) && !isArrayType(restType))) { + var spreadType = getSpreadArgumentType(node, args, i, argCount, restType, /*context*/ undefined); + return checkTypeRelatedTo(spreadType, restType, relation, arg, headMessage); + } + else { + // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) + var paramType = getTypeAtPosition(signature, i); + // If the effective argument type is undefined, there is no synthetic type for the argument. + // In that case, we should check the argument. + var argType = getEffectiveArgumentType(node, i) || + checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); + // If one or more arguments are still excluded (as indicated by a non-null excludeArgument parameter), + // we obtain the regular type of any object literal arguments because we may not have inferred complete + // parameter types yet and therefore excess property checks may yield false positives (see #17041). + var checkArgType = excludeArgument ? getRegularTypeOfObjectLiteral(argType) : argType; + // Use argument expression as error location when reporting errors + var errorNode = reportErrors ? getEffectiveArgumentErrorNode(node, i, arg) : undefined; + if (!checkTypeRelatedTo(checkArgType, paramType, relation, errorNode, headMessage)) { + return false; + } } } } @@ -45647,9 +46116,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 187 /* CallExpression */) { + if (node.kind === 189 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { + if (callee.kind === 187 /* PropertyAccessExpression */ || callee.kind === 188 /* ElementAccessExpression */) { return callee.expression; } } @@ -45664,10 +46133,10 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 189 /* TaggedTemplateExpression */) { + if (node.kind === 191 /* TaggedTemplateExpression */) { var template = node.template; var args_4 = [undefined]; // TODO: GH#18217 - if (template.kind === 202 /* TemplateExpression */) { + if (template.kind === 204 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); @@ -45684,7 +46153,28 @@ var ts; return node.attributes.properties.length > 0 ? [node.attributes] : ts.emptyArray; } else { - return node.arguments || ts.emptyArray; + var args = node.arguments || ts.emptyArray; + var length_4 = args.length; + if (length_4 && isSpreadArgument(args[length_4 - 1]) && getSpreadArgumentIndex(args) === length_4 - 1) { + // We have a spread argument in the last position and no other spread arguments. If the type + // of the argument is a tuple type, spread the tuple elements into the argument list. We can + // call checkExpressionCached because spread expressions never have a contextual type. + var spreadArgument_1 = args[length_4 - 1]; + var type = checkExpressionCached(spreadArgument_1.expression); + if (isTupleType(type)) { + var typeArguments = type.typeArguments || ts.emptyArray; + var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; + var syntheticArgs = ts.map(typeArguments, function (t, i) { + var arg = ts.createNode(213 /* SyntheticExpression */, spreadArgument_1.pos, spreadArgument_1.end); + arg.parent = spreadArgument_1; + arg.type = t; + arg.isSpread = i === restIndex_2; + return arg; + }); + return ts.concatenate(args.slice(0, length_4 - 1), syntheticArgs); + } + } + return args; } } /** @@ -45703,8 +46193,8 @@ var ts; function getEffectiveArgumentCount(node, args, signature) { if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; case 152 /* PropertyDeclaration */: @@ -45749,7 +46239,7 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* 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); @@ -45794,7 +46284,7 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return errorType; } @@ -45849,7 +46339,7 @@ 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 === 235 /* ClassDeclaration */) { + if (node.kind === 238 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return errorType; } @@ -45898,7 +46388,7 @@ var ts; if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -45911,7 +46401,7 @@ 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 === 150 /* Decorator */ || - (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { + (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -45924,7 +46414,7 @@ var ts; // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 191 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -45944,7 +46434,7 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 189 /* TaggedTemplateExpression */; + var isTaggedTemplate = node.kind === 191 /* TaggedTemplateExpression */; var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; @@ -46019,7 +46509,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 === 187 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 189 /* 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 @@ -46066,10 +46556,10 @@ var ts; var max = Number.NEGATIVE_INFINITY; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; - min_1 = Math.min(min_1, sig.minArgumentCount); - max = Math.max(max, sig.parameters.length); + min_1 = Math.min(min_1, getMinArgumentCount(sig)); + max = Math.max(max, getParameterCount(sig)); } - var hasRestParameter_1 = ts.some(signatures, function (sig) { return sig.hasRestParameter; }); + var hasRestParameter_1 = ts.some(signatures, hasEffectiveRestParameter); var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; var paramCount = hasRestParameter_1 ? min_1 : min_1 < max ? min_1 + "-" + max : @@ -46184,11 +46674,12 @@ var ts; var maxParams = -1; for (var i = 0; i < candidates.length; i++) { var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argsCount) { + var paramCount = getParameterCount(candidate); + if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) { return i; } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; + if (paramCount > maxParams) { + maxParams = paramCount; maxParamsIndex = i; } } @@ -46204,7 +46695,7 @@ var ts; if (superType !== errorType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); + var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); @@ -46383,8 +46874,7 @@ var ts; var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); } } function resolveTaggedTemplateExpression(node, candidatesOutArray) { @@ -46410,8 +46900,8 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; @@ -46487,16 +46977,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 257 /* JsxOpeningElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -46572,7 +47062,8 @@ var ts; function getAssignedClassType(symbol) { var decl = symbol.valueDeclaration; var assignmentSymbol = decl && decl.parent && - (ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { var prototype = ts.forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -46586,7 +47077,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 185 /* PropertyAccessExpression */) { + while (parent && parent.kind === 187 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -46618,7 +47109,7 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 188 /* NewExpression */) { + if (node.kind === 190 /* NewExpression */) { var declaration = signature.declaration; if (declaration && declaration.kind !== 155 /* Constructor */ && @@ -46692,7 +47183,7 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -46749,9 +47240,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 234 /* FunctionDeclaration */ + ? 237 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 232 /* VariableDeclaration */ + ? 235 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -46829,10 +47320,107 @@ var ts; } return type; } + function getParameterNameAtPosition(signature, pos) { + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return signature.parameters[pos].escapedName; + } + var restParameter = signature.parameters[paramCount] || unknownSymbol; + var restType = getTypeOfSymbol(restParameter); + if (isTupleType(restType)) { + var associatedNames = restType.target.associatedNames; + var index = pos - paramCount; + return associatedNames ? associatedNames[index] : restParameter.escapedName + "_" + index; + } + return restParameter.escapedName; + } function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? - pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : - pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; + var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (pos < paramCount) { + return getTypeOfParameter(signature.parameters[pos]); + } + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[paramCount]); + if (isTupleType(restType)) { + if (pos - paramCount < getLengthOfTupleType(restType)) { + return restType.typeArguments[pos - paramCount]; + } + var tupleRestType = getRestTypeOfTupleType(restType); + if (tupleRestType) { + return tupleRestType; + } + } + return getIndexTypeOfType(restType, 1 /* Number */) || anyType; + } + return anyType; + } + function getRestTypeAtPosition(source, pos) { + var paramCount = getParameterCount(source); + var hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + var restTypeVariable = getRestTypeParameter(source); + if (restTypeVariable) { + return restTypeVariable; + } + } + var start = hasRest ? Math.min(pos, paramCount - 1) : pos; + var types = []; + var names = []; + for (var i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + var minArgumentCount = getMinArgumentCount(source); + var minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); + } + function getTypeOfRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + return getRestTypeOfTupleType(restType); + } + return restType; + } + return undefined; + } + function getParameterCount(signature) { + var length = signature.parameters.length; + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[length - 1]); + if (isTupleType(restType)) { + return length + (restType.typeArguments || ts.emptyArray).length - 1; + } + } + return length; + } + function getMinArgumentCount(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (isTupleType(restType)) { + var minLength = restType.target.minLength; + if (minLength > 0) { + return signature.parameters.length - 1 + minLength; + } + } + } + return signature.minArgumentCount; + } + function getRestTypeParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + if (restType.flags & 65536 /* TypeParameter */) { + return restType; + } + } + return undefined; + } + function hasEffectiveRestParameter(signature) { + if (signature.hasRestParameter) { + var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); + return !isTupleType(restType) || restType.target.hasRestElement; + } + return false; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -46871,11 +47459,11 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); + var contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -46940,7 +47528,7 @@ var ts; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 213 /* Block */) { + if (func.body.kind !== 216 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -47029,7 +47617,7 @@ var ts; } function getYieldedTypeOfYieldExpression(node, isAsync, checkMode) { var errorNode = node.expression || node; - var expressionType = node.expression ? checkExpressionCached(node.expression, checkMode) : undefinedWideningType; + var expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -47054,7 +47642,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 230 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -47097,11 +47685,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return true; case 154 /* MethodDeclaration */: - return func.parent.kind === 184 /* ObjectLiteralExpression */; + return func.parent.kind === 186 /* ObjectLiteralExpression */; default: return false; } @@ -47125,7 +47713,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 (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 216 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -47165,7 +47753,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 194 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -47226,7 +47814,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 213 /* Block */) { + if (node.body.kind === 216 /* Block */) { checkSourceElement(node.body); } else { @@ -47239,10 +47827,10 @@ var ts; if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -47272,7 +47860,7 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && + (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) && expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); @@ -47289,13 +47877,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { + if (expr.kind === 187 /* PropertyAccessExpression */ || expr.kind === 188 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 246 /* NamespaceImport */; + return !!declaration && declaration.kind === 249 /* NamespaceImport */; } } } @@ -47304,7 +47892,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 187 /* PropertyAccessExpression */ && node.kind !== 188 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -47313,7 +47901,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { + if (expr.kind !== 187 /* PropertyAccessExpression */ && expr.kind !== 188 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -47490,7 +48078,7 @@ 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 === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 273 /* PropertyAssignment */ || property.kind === 274 /* ShorthandPropertyAssignment */) { var name = property.name; if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); @@ -47505,7 +48093,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 271 /* ShorthandPropertyAssignment */) { + if (property.kind === 274 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -47517,7 +48105,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 272 /* SpreadAssignment */) { + else if (property.kind === 275 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -47552,27 +48140,23 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 206 /* OmittedExpression */) { - if (element.kind !== 204 /* SpreadElement */) { + if (element.kind !== 208 /* OmittedExpression */) { + if (element.kind !== 206 /* SpreadElement */) { var propName = "" + elementIndex; - var type = isTypeAny(sourceType) - ? sourceType - : isTupleLikeType(sourceType) - ? getTypeOfPropertyOfType(sourceType, propName) - : elementType; + var type = isTypeAny(sourceType) ? sourceType : + isTupleLikeType(sourceType) ? getTupleElementType(sourceType, elementIndex) : + elementType; if (type) { return checkDestructuringAssignment(element, type, checkMode); } + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); + if (isTupleType(sourceType)) { + error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + } else { - // We still need to check element expression here because we may need to set appropriate flag on the expression - // such as NodeCheckFlags.LexicalThis on "this"expression. - checkExpression(element); - if (isTupleType(sourceType)) { - error(element, ts.Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); - } - else { - error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); - } + error(element, ts.Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); } } else { @@ -47581,12 +48165,15 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 202 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); + var type = isTupleType(sourceType) ? + getArrayLiteralType((sourceType.typeArguments || ts.emptyArray).slice(elementIndex, getTypeReferenceArity(sourceType))) : + createArrayType(elementType); + return checkDestructuringAssignment(restExpression, type, checkMode); } } } @@ -47595,7 +48182,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 274 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -47611,25 +48198,25 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 202 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 184 /* ObjectLiteralExpression */) { + if (target.kind === 186 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 183 /* ArrayLiteralExpression */) { + if (target.kind === 185 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 272 /* SpreadAssignment */ ? + var error = target.parent.kind === 275 /* 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)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -47647,35 +48234,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 189 /* TaggedTemplateExpression */: - case 202 /* TemplateExpression */: + case 191 /* TaggedTemplateExpression */: + case 204 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - case 192 /* FunctionExpression */: - case 205 /* ClassExpression */: - case 193 /* ArrowFunction */: - case 183 /* ArrayLiteralExpression */: - case 184 /* ObjectLiteralExpression */: - case 195 /* TypeOfExpression */: - case 209 /* NonNullExpression */: - case 256 /* JsxSelfClosingElement */: - case 255 /* JsxElement */: + case 194 /* FunctionExpression */: + case 207 /* ClassExpression */: + case 195 /* ArrowFunction */: + case 185 /* ArrayLiteralExpression */: + case 186 /* ObjectLiteralExpression */: + case 197 /* TypeOfExpression */: + case 211 /* NonNullExpression */: + case 259 /* JsxSelfClosingElement */: + case 258 /* JsxElement */: return true; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -47687,9 +48274,9 @@ var ts; } return false; // Some forms listed here for clarity - case 196 /* VoidExpression */: // Explicit opt-out - case 190 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 208 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 198 /* VoidExpression */: // Explicit opt-out + case 192 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 210 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -47705,7 +48292,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 186 /* ObjectLiteralExpression */ || left.kind === 185 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -47904,7 +48491,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } @@ -47925,7 +48512,23 @@ var ts; } } function reportOperatorError() { - error(errorNode || operatorToken, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + var leftStr = typeToString(leftType); + var rightStr = typeToString(rightType); + var errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error(errNode, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); + } + } + function tryGiveBetterPrimaryError(errNode, leftStr, rightStr) { + switch (operatorToken.kind) { + case 34 /* EqualsEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case 35 /* ExclamationEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + return error(errNode, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } function isYieldExpressionInClass(node) { @@ -47982,7 +48585,7 @@ var ts; var returnType = ts.getEffectiveReturnTypeNode(func); if (returnType) { var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' return anyType; @@ -48007,7 +48610,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 263 /* JsxAttributes */) { + if (node.kind === 266 /* JsxAttributes */) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -48043,7 +48646,7 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; + return node.kind === 192 /* TypeAssertionExpression */ || node.kind === 210 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); @@ -48145,7 +48748,7 @@ var ts; function getTypeOfExpression(node, cache) { // 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 === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 189 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -48195,8 +48798,8 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + var ok = (node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 188 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); if (!ok) { @@ -48232,74 +48835,76 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 188 /* NewExpression */: + case 190 /* NewExpression */: return checkCallExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return checkClassExpression(node); - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: return checkAssertion(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return checkNonNullAssertion(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return checkMetaProperty(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return checkDeleteExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return checkVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return checkAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return undefinedWideningType; - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return checkYieldExpression(node); - case 265 /* JsxExpression */: + case 213 /* SyntheticExpression */: + return node.type; + case 268 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return checkJsxElement(node, checkMode); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -48328,6 +48933,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); } } + function isRestParameterType(type) { + return isArrayType(type) || isTupleType(type) || type.flags & 15794176 /* Instantiable */ && isTypeAssignableTo(type, anyArrayType); + } function checkParameter(node) { // Grammar checking // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the @@ -48354,7 +48962,7 @@ var ts; } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isRestParameterType(getTypeOfSymbol(node.symbol))) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -48415,10 +49023,10 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: case 158 /* CallSignature */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: case 163 /* FunctionType */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: @@ -48439,7 +49047,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { + else if (name.kind === 183 /* ArrayBindingPattern */ || name.kind === 182 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -48452,7 +49060,7 @@ var ts; checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + else if (node.kind === 163 /* FunctionType */ || node.kind === 237 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); @@ -48517,7 +49125,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 287 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -48646,7 +49254,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* 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 @@ -48734,7 +49342,7 @@ var ts; // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; - if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + if (ts.getEffectiveBaseTypeNode(containingClassDecl)) { captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); @@ -48756,7 +49364,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -48907,11 +49515,28 @@ var ts; checkSourceElement(node.elementType); } function checkTupleType(node) { - // Grammar checking - var hasErrorFromDisallowedTrailingComma = checkGrammarForDisallowedTrailingComma(node.elementTypes); - if (!hasErrorFromDisallowedTrailingComma && node.elementTypes.length === 0) { - grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); + var elementTypes = node.elementTypes; + var seenOptionalElement = false; + for (var i = 0; i < elementTypes.length; i++) { + var e = elementTypes[i]; + if (e.kind === 170 /* RestType */) { + if (i !== elementTypes.length - 1) { + grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); + break; + } + if (!isArrayType(getTypeFromTypeNode(e))) { + error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); + } + } + else if (e.kind === 169 /* OptionalType */) { + seenOptionalElement = true; + } + else if (seenOptionalElement) { + grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element); + break; + } } + checkGrammarForDisallowedTrailingComma(node.elementTypes); ts.forEach(node.elementTypes, checkSourceElement); } function checkUnionOrIntersectionType(node) { @@ -48925,7 +49550,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 186 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 188 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -48962,7 +49587,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 173 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -48978,9 +49603,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 !== 236 /* InterfaceDeclaration */ && - n.parent.kind !== 235 /* ClassDeclaration */ && - n.parent.kind !== 205 /* ClassExpression */ && + if (n.parent.kind !== 239 /* InterfaceDeclaration */ && + n.parent.kind !== 238 /* ClassDeclaration */ && + n.parent.kind !== 207 /* ClassExpression */ && n.flags & 4194304 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported @@ -49110,7 +49735,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 239 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -49121,7 +49746,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 === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { + if (node.kind === 237 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -49250,22 +49875,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 274 /* SourceFile */: + case 277 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -49273,17 +49898,17 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 245 /* ImportClause */: + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 248 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 232 /* VariableDeclaration */: - case 182 /* BindingElement */: - case 234 /* FunctionDeclaration */: - case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 235 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 237 /* FunctionDeclaration */: + case 251 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); @@ -49554,7 +50179,7 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); @@ -49617,12 +50242,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -49654,7 +50279,7 @@ var ts; } } return commonEntityName; - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); case 162 /* TypeReference */: return node.typeName; @@ -49687,7 +50312,7 @@ var ts; 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -49776,7 +50401,7 @@ var ts; error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag); } var name = getIdentifierFromEntityNameExpression(node.class.expression); - var extend = ts.getClassExtendsHeritageClauseElement(classLike); + var extend = ts.getClassExtendsHeritageElement(classLike); if (extend) { var className = getIdentifierFromEntityNameExpression(extend.expression); if (className && name.escapedText !== className.escapedText) { @@ -49788,7 +50413,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -49871,27 +50496,27 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 274 /* SourceFile */: - case 239 /* ModuleDeclaration */: - case 213 /* Block */: - case 241 /* CaseBlock */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 277 /* SourceFile */: + case 242 /* ModuleDeclaration */: + case 216 /* Block */: + case 244 /* CaseBlock */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; case 155 /* Constructor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: @@ -49905,7 +50530,7 @@ var ts; case 159 /* ConstructSignature */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -49918,10 +50543,7 @@ var ts; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(node, message, name)); } - function parameterNameStartsWithUnderscore(parameterName) { - return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); - } - function isIdentifierThatStartsWithUnderScore(node) { + function isIdentifierThatStartsWithUnderscore(node) { return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node, addDiagnostic) { @@ -49951,7 +50573,7 @@ var ts; } break; case 160 /* IndexSignature */: - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: // Can't be private break; default: @@ -49967,7 +50589,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */) && ts.last(getSymbolOfNode(node).declarations) === node) { for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { var typeParameter = typeParameters_2[_i]; - if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + if (!(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(typeParameter.symbol))); } } @@ -50002,7 +50624,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderScore(declaration.name)) { + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { continue; } if (isImportedDeclaration(declaration)) { @@ -50020,9 +50642,9 @@ var ts; } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - if (parameter) { - var name = ts.getNameOfDeclaration(local.valueDeclaration); - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -50037,7 +50659,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 249 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(0 /* Local */, unuseds.length === 1 @@ -50055,7 +50677,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 235 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 236 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -50076,7 +50698,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 217 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -50090,22 +50712,22 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 181 /* ArrayBindingPattern */: - case 180 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; + return node.kind === 248 /* ImportClause */ || node.kind === 251 /* ImportSpecifier */ || node.kind === 249 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 248 /* ImportClause */ ? decl : decl.kind === 249 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 213 /* Block */) { + if (node.kind === 216 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -50200,7 +50822,7 @@ var ts; } // 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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 277 /* 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)); } @@ -50215,7 +50837,7 @@ var ts; } // 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 === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 277 /* 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)); } @@ -50250,7 +50872,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 === 232 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 235 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -50262,17 +50884,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 214 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 236 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 217 /* 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 === 213 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 240 /* ModuleBlock */ || - container.kind === 239 /* ModuleDeclaration */ || - container.kind === 274 /* SourceFile */); + (container.kind === 216 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 243 /* ModuleBlock */ || + container.kind === 242 /* ModuleDeclaration */ || + container.kind === 277 /* 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 @@ -50298,7 +50920,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 185 /* PropertyAccessExpression */) { + if (n.kind === 187 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -50318,7 +50940,7 @@ var ts; var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { if (symbol.valueDeclaration.kind === 149 /* Parameter */ || - symbol.valueDeclaration.kind === 182 /* BindingElement */) { + symbol.valueDeclaration.kind === 184 /* 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) { @@ -50371,8 +50993,8 @@ var ts; checkExpressionCached(node.initializer); } } - if (node.kind === 182 /* BindingElement */) { - if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 184 /* BindingElement */) { + if (node.parent.kind === 182 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements @@ -50393,7 +51015,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 183 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -50406,13 +51028,13 @@ var ts; // 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 !== 221 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 224 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -50429,8 +51051,8 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 221 /* ForInStatement */) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 224 /* ForInStatement */) { + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -50445,7 +51067,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(ts.getNameOfDeclaration(symbol.valueDeclaration), ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); @@ -50455,7 +51077,7 @@ var ts; if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -50470,8 +51092,8 @@ var ts; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || - (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 235 /* VariableDeclaration */) || + (left.kind === 235 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -50510,7 +51132,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 215 /* EmptyStatement */) { + if (node.thenStatement.kind === 218 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -50530,12 +51152,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 236 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -50569,14 +51191,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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. @@ -50590,7 +51212,7 @@ var ts; // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -50608,7 +51230,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 === 233 /* VariableDeclarationList */) { + if (node.initializer.kind === 236 /* 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); @@ -50622,7 +51244,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 === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* ObjectLiteralExpression */) { + if (varExpr.kind === 185 /* ArrayLiteralExpression */ || varExpr.kind === 186 /* 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)) { @@ -50986,7 +51608,7 @@ var ts; } } else if (func.kind === 155 /* Constructor */) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -51002,7 +51624,7 @@ var ts; } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -51035,7 +51657,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 === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 270 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -51047,7 +51669,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 266 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 269 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -51076,7 +51698,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 231 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -51174,16 +51796,17 @@ var ts; return; } var propDeclaration = prop.valueDeclaration; + var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal - if (indexKind === 1 /* Number */ && !(propDeclaration ? isNumericName(ts.getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.escapedName))) { + if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; } // perform property check if property or indexer is declared in 'type' // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (propDeclaration && - (propDeclaration.kind === 200 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || + if (propDeclaration && name && + (propDeclaration.kind === 202 /* BinaryExpression */ || + name.kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -51357,7 +51980,7 @@ var ts; if (!(node.flags & 4194304 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } - var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); @@ -51369,6 +51992,10 @@ var ts; var staticBaseType = getApparentType(baseConstructorType); checkBaseTypeAccessibility(staticBaseType, baseTypeNode); checkSourceElement(baseTypeNode.expression); + var extendsNode = ts.getClassExtendsHeritageElement(node); + if (extendsNode && extendsNode !== baseTypeNode) { + checkExpression(extendsNode.expression); + } if (ts.some(baseTypeNode.typeArguments)) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { @@ -51435,7 +52062,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_9 = function (member) { + var _loop_8 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -51454,7 +52081,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_9(member); + _loop_8(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -51480,7 +52107,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; + return d.kind === 238 /* ClassDeclaration */ || d.kind === 239 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -51519,7 +52146,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.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 205 /* ClassExpression */) { + if (derivedClassDecl.kind === 207 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -51633,7 +52260,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 239 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -51696,7 +52323,7 @@ var ts; } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isConst(member.parent)) { + if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -51711,7 +52338,7 @@ var ts; } function computeConstantValue(member) { var enumKind = getEnumKind(getSymbolOfNode(member.parent)); - var isConstEnum = ts.isConst(member.parent); + var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -51738,7 +52365,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -51748,7 +52375,7 @@ var ts; } } break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -51776,7 +52403,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: var identifier = expr; @@ -51784,14 +52411,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 185 /* PropertyAccessExpression */) { + if (ex.kind === 187 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -51823,8 +52450,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 187 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 188 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -51838,7 +52465,7 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); computeEnumMemberValues(node); - var enumIsConst = ts.isConst(node); + var enumIsConst = ts.isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & 4194304 /* Ambient */) { error(node.name, ts.Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -51854,7 +52481,7 @@ var ts; if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst) { error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -51862,7 +52489,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 !== 238 /* EnumDeclaration */) { + if (declaration.kind !== 241 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -51885,8 +52512,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 235 /* ClassDeclaration */ || - (declaration.kind === 234 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 238 /* ClassDeclaration */ || + (declaration.kind === 237 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -51949,7 +52576,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, 235 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 238 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -51999,23 +52626,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* 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 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 182 /* BindingElement */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 235 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -52026,12 +52653,12 @@ var ts; break; } // falls through - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 234 /* FunctionDeclaration */: - case 236 /* InterfaceDeclaration */: - case 239 /* ModuleDeclaration */: - case 237 /* TypeAliasDeclaration */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 239 /* InterfaceDeclaration */: + case 242 /* ModuleDeclaration */: + case 240 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -52059,7 +52686,7 @@ var ts; node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -52076,9 +52703,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 250 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 253 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -52111,14 +52738,14 @@ var ts; (symbol.flags & 67901928 /* Type */ ? 67901928 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 252 /* ExportSpecifier */ ? + var message = node.kind === 255 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 252 /* ExportSpecifier */ + && node.kind === 255 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -52145,7 +52772,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 249 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -52169,7 +52796,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 257 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -52205,10 +52832,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 243 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 243 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 277 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -52225,7 +52852,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 277 /* SourceFile */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 242 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -52254,8 +52881,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -52343,7 +52970,7 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || + return (declaration.kind !== 237 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { @@ -52361,10 +52988,10 @@ 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 239 /* ModuleDeclaration */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 234 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 237 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -52402,111 +53029,113 @@ var ts; return checkArrayType(node); case 168 /* TupleType */: return checkTupleType(node); - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: + case 169 /* OptionalType */: + case 170 /* RestType */: return checkSourceElement(node.type); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return checkTypeOperator(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return checkConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return checkInferType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return checkImportType(node); - case 290 /* JSDocAugmentsTag */: + case 293 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 298 /* JSDocTypedefTag */: - case 292 /* JSDocCallbackTag */: + case 301 /* JSDocTypedefTag */: + case 295 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 296 /* JSDocTypeTag */: + case 299 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 293 /* JSDocParameterTag */: + case 296 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 282 /* JSDocNonNullableType */: - case 281 /* JSDocNullableType */: - case 279 /* JSDocAllType */: - case 280 /* JSDocUnknownType */: - case 287 /* JSDocTypeLiteral */: + case 285 /* JSDocNonNullableType */: + case 284 /* JSDocNullableType */: + case 282 /* JSDocAllType */: + case 283 /* JSDocUnknownType */: + case 290 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 285 /* JSDocVariadicType */: + case 288 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 278 /* JSDocTypeExpression */: + case 281 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return checkMappedType(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 213 /* Block */: - case 240 /* ModuleBlock */: + case 216 /* Block */: + case 243 /* ModuleBlock */: return checkBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return checkVariableStatement(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return checkExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return checkIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return checkDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return checkWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return checkForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return checkForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return checkForOfStatement(node); - case 223 /* ContinueStatement */: - case 224 /* BreakStatement */: + case 226 /* ContinueStatement */: + case 227 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return checkReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return checkWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return checkSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return checkLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return checkThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return checkTryStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return checkBindingElement(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return checkClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return checkImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return checkExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return checkExportAssignment(node); - case 215 /* EmptyStatement */: - case 231 /* DebuggerStatement */: + case 218 /* EmptyStatement */: + case 234 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -52583,15 +53212,15 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkNodeDeferred(node) { if (deferredNodes) { - deferredNodes.push(node); + var id = "" + getNodeId(node); + deferredNodes.set(id, node); } } function checkDeferredNodes() { - for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { - var node = _a[_i]; + deferredNodes.forEach(function (node) { switch (node.kind) { - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); @@ -52600,11 +53229,17 @@ var ts; case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: checkClassExpressionDeferred(node); break; + case 259 /* JsxSelfClosingElement */: + checkJsxSelfClosingElementDeferred(node); + break; + case 258 /* JsxElement */: + checkJsxElementDeferred(node); + break; } - } + }); } function checkSourceFile(node) { ts.performance.mark("beforeCheck"); @@ -52639,7 +53274,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - deferredNodes = []; + deferredNodes = ts.createMap(); ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalOrCommonJsModule(node)) { @@ -52733,13 +53368,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -52747,8 +53382,8 @@ var ts; // falls 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 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* 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. @@ -52757,7 +53392,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -52806,10 +53441,10 @@ var ts; function isTypeDeclaration(node) { switch (node.kind) { case 148 /* TypeParameter */: - case 235 /* ClassDeclaration */: - case 236 /* InterfaceDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 238 /* ClassDeclaration */: + case 239 /* InterfaceDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return true; default: return false; @@ -52823,10 +53458,10 @@ var ts; return node.parent.kind === 162 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 185 /* PropertyAccessExpression */) { + while (node.parent.kind === 187 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 207 /* ExpressionWithTypeArguments */; + return node.parent.kind === 209 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -52857,10 +53492,10 @@ var ts; while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 246 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 252 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -52886,7 +53521,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 181 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -52896,7 +53531,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 185 /* PropertyAccessExpression */ && + entityName.parent.kind === 187 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -52904,7 +53539,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 252 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -52914,7 +53549,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 243 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 246 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -52932,7 +53567,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 === 207 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 209 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -52948,10 +53583,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 293 /* JSDocParameterTag */) { + if (entityName.parent.kind === 296 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 297 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 300 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -52968,12 +53603,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { + else if (entityName.kind === 187 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 185 /* PropertyAccessExpression */) { + if (entityName.kind === 187 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -52986,7 +53621,7 @@ var ts; var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 262 /* JsxAttribute */) { + else if (entityName.parent.kind === 265 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } if (entityName.parent.kind === 161 /* TypePredicate */) { @@ -52996,7 +53631,7 @@ var ts; return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -53016,8 +53651,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 182 /* BindingElement */ && - grandParent.kind === 180 /* ObjectBindingPattern */ && + else if (parent.kind === 184 /* BindingElement */ && + grandParent.kind === 182 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); @@ -53028,7 +53663,7 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: @@ -53043,7 +53678,7 @@ var ts; return checkExpression(node).symbol; } // falls through - case 174 /* ThisType */: + case 176 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; @@ -53061,7 +53696,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 247 /* ImportDeclaration */ || node.parent.kind === 253 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -53079,14 +53714,14 @@ var ts; case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 274 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -53159,28 +53794,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 186 /* ObjectLiteralExpression */ || expr.kind === 185 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 222 /* ForOfStatement */) { + if (expr.parent.kind === 225 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 200 /* BinaryExpression */) { + if (expr.parent.kind === 202 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 270 /* PropertyAssignment */) { + if (expr.parent.kind === 273 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 185 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; @@ -53259,7 +53894,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 187 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -53315,7 +53950,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 277 /* SourceFile */) { var symbolFile = parentSymbol_1.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. @@ -53370,7 +54005,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 === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 216 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -53411,16 +54046,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: - case 245 /* ImportClause */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 246 /* ImportEqualsDeclaration */: + case 248 /* ImportClause */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -53430,7 +54065,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 277 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -53511,22 +54146,23 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 273 /* EnumMember */: - case 185 /* PropertyAccessExpression */: - case 186 /* ElementAccessExpression */: + case 276 /* EnumMember */: + case 187 /* PropertyAccessExpression */: + case 188 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 273 /* EnumMember */) { + if (node.kind === 276 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & 8 /* EnumMember */)) { // inline property\index accesses only for const enums - if (ts.isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + var member = symbol.valueDeclaration; + if (ts.isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } return undefined; @@ -53664,7 +54300,7 @@ var ts; return undefined; } function isLiteralConstDeclaration(node) { - if (ts.isConst(node)) { + if (ts.isVariableDeclaration(node) && ts.isVarConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } @@ -53761,7 +54397,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; + return node.parent && node.parent.kind === 209 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 271 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -53773,7 +54409,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 67901928 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 187 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -53824,7 +54460,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 277 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -53839,12 +54475,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 239 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 242 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 274 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 277 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -53852,10 +54488,14 @@ var ts; var file = _a[_i]; ts.bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = ts.createMap(); // Initialize global symbol table var augmentations; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; + if (file.redirectInfo) { + continue; + } if (!ts.isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals); } @@ -53929,6 +54569,32 @@ var ts; } } } + amalgamatedDuplicates.forEach(function (_a) { + var firstFile = _a.firstFile, secondFile = _a.secondFile, firstFileInstances = _a.firstFileInstances, secondFileInstances = _a.secondFileInstances; + var conflictingKeys = ts.arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + var list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file))); + diagnostics.add(addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file))); + }); + amalgamatedDuplicates = undefined; + function addErrorsForDuplicates(secondFileInstances, firstFileInstances) { + secondFileInstances.forEach(function (locations, symbolName) { + var firstFileEquivalent = firstFileInstances.get(symbolName); + var message = locations.blockScoped + ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : ts.Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(function (node) { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { @@ -54022,7 +54688,7 @@ var ts; } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { + if (node.kind !== 241 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -54042,7 +54708,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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -54065,7 +54731,7 @@ 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 === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + else if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } else if (node.kind === 149 /* Parameter */) { @@ -54101,7 +54767,7 @@ 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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } else if (node.kind === 149 /* Parameter */) { @@ -54110,8 +54776,8 @@ var ts; flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 277 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 242 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -54123,13 +54789,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 240 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 243 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -54139,14 +54805,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 238 /* ClassDeclaration */) { if (node.kind !== 154 /* MethodDeclaration */ && node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 156 /* GetAccessor */ && node.kind !== 157 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 238 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -54188,7 +54854,7 @@ var ts; } return false; } - else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 247 /* ImportDeclaration */ || node.kind === 246 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { @@ -54223,29 +54889,29 @@ var ts; case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 160 /* IndexSignature */: - case 239 /* ModuleDeclaration */: - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 242 /* ModuleDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: case 149 /* Parameter */: return false; default: - if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { return false; } switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 236 /* InterfaceDeclaration */: - case 214 /* VariableStatement */: - case 237 /* TypeAliasDeclaration */: + case 239 /* InterfaceDeclaration */: + case 217 /* VariableStatement */: + case 240 /* TypeAliasDeclaration */: return true; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -54259,9 +54925,9 @@ var ts; function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { case 154 /* MethodDeclaration */: - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: - case 193 /* ArrowFunction */: + case 237 /* FunctionDeclaration */: + case 194 /* FunctionExpression */: + case 195 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -54394,7 +55060,7 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 206 /* OmittedExpression */) { + if (arg.kind === 208 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -54475,15 +55141,15 @@ var ts; return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 202 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 234 /* FunctionDeclaration */ || - node.kind === 192 /* FunctionExpression */ || + ts.Debug.assert(node.kind === 237 /* FunctionDeclaration */ || + node.kind === 194 /* FunctionExpression */ || node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); @@ -54507,7 +55173,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 272 /* SpreadAssignment */) { + if (prop.kind === 275 /* SpreadAssignment */) { continue; } var name = prop.name; @@ -54515,7 +55181,7 @@ var ts; // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 271 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 274 /* 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); @@ -54539,8 +55205,8 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -54590,7 +55256,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 264 /* JsxSpreadAttribute */) { + if (attr.kind === 267 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -54600,7 +55266,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 268 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -54609,12 +55275,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 225 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 233 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 236 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -54629,20 +55295,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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 === 221 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 224 /* 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); @@ -54711,7 +55377,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 71 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -54749,7 +55415,7 @@ var ts; return true; } if (node.kind === 154 /* MethodDeclaration */) { - if (node.parent.kind === 184 /* ObjectLiteralExpression */) { + if (node.parent.kind === 186 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -54778,7 +55444,7 @@ var ts; return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (node.parent.kind === 166 /* TypeLiteral */) { @@ -54792,11 +55458,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 223 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 226 /* 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); @@ -54804,8 +55470,8 @@ var ts; return false; } break; - case 227 /* SwitchStatement */: - if (node.kind === 224 /* BreakStatement */ && !node.label) { + case 230 /* SwitchStatement */: + if (node.kind === 227 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -54820,13 +55486,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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 === 224 /* BreakStatement */ + var message = node.kind === 227 /* 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); @@ -54839,7 +55505,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { + if (node.name.kind === 183 /* ArrayBindingPattern */ || node.name.kind === 182 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -54853,14 +55519,14 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 200 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { + if (node.parent.parent.kind !== 224 /* ForInStatement */ && node.parent.parent.kind !== 225 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { - if (ts.isConst(node) && !node.type) { + if (ts.isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -54871,7 +55537,7 @@ var ts; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(ts.isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(ts.isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer var equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -54881,19 +55547,19 @@ var ts; if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) { return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (ts.isConst(node)) { + if (ts.isVarConst(node)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); } } } - if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 217 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } - var checkLetConstNames = (ts.isLet(node) || ts.isConst(node)); + var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -54948,15 +55614,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 217 /* IfStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 226 /* WithStatement */: - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 220 /* IfStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: return false; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -54966,7 +55632,7 @@ var ts; if (ts.isLet(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (ts.isConst(node.declarationList)) { + else if (ts.isVarConst(node.declarationList)) { return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -55033,7 +55699,7 @@ var ts; return true; } } - else if (node.parent.kind === 236 /* InterfaceDeclaration */) { + else if (node.parent.kind === 239 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -55070,13 +55736,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 236 /* InterfaceDeclaration */ || - node.kind === 237 /* TypeAliasDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 243 /* ImportEqualsDeclaration */ || - node.kind === 250 /* ExportDeclaration */ || - node.kind === 249 /* ExportAssignment */ || - node.kind === 242 /* NamespaceExportDeclaration */ || + if (node.kind === 239 /* InterfaceDeclaration */ || + node.kind === 240 /* TypeAliasDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 246 /* ImportEqualsDeclaration */ || + node.kind === 253 /* ExportDeclaration */ || + node.kind === 252 /* ExportAssignment */ || + node.kind === 245 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -55085,7 +55751,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 === 214 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 217 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -55112,7 +55778,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 === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { + if (node.parent.kind === 216 /* Block */ || node.parent.kind === 243 /* ModuleBlock */ || node.parent.kind === 277 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -55134,10 +55800,10 @@ var ts; 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, 178 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 180 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 276 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -55192,8 +55858,8 @@ var ts; /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -55201,14 +55867,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 245 /* ImportClause */: // For default import - case 243 /* ImportEqualsDeclaration */: - case 246 /* NamespaceImport */: - case 248 /* ImportSpecifier */: // For rename import `x as y` + case 248 /* ImportClause */: // For default import + case 246 /* ImportEqualsDeclaration */: + case 249 /* NamespaceImport */: + case 251 /* ImportSpecifier */: // For rename import `x as y` return true; case 71 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 248 /* ImportSpecifier */; + return decl.parent.kind === 251 /* ImportSpecifier */; default: return false; } @@ -55224,8 +55890,12 @@ var ts; JsxNames.Element = "Element"; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; + JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; // tslint:enable variable-name })(JsxNames || (JsxNames = {})); + function typeIsLiteralType(type) { + return !!(type.flags & 448 /* Literal */); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -55391,7 +56061,7 @@ var ts; } ts.createFileLevelUniqueName = createFileLevelUniqueName; function getGeneratedNameForNode(node, flags) { - var name = createIdentifier(ts.isIdentifier(node) ? ts.idText(node) : ""); + var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : ""); name.autoGenerateFlags = 4 /* Node */ | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; @@ -55484,10 +56154,9 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { - return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 303 /* CommaListExpression */ ? - createParen(expression) : - expression; + return ts.isCommaSequence(expression) + ? createParen(expression) + : expression; } function createComputedPropertyName(expression) { var node = createSynthesizedNode(147 /* ComputedPropertyName */); @@ -55850,14 +56519,38 @@ var ts; return node; } ts.createTupleTypeNode = createTupleTypeNode; - function updateTypleTypeNode(node, elementTypes) { + function updateTupleTypeNode(node, elementTypes) { return node.elementTypes !== elementTypes ? updateNode(createTupleTypeNode(elementTypes), node) : node; } - ts.updateTypleTypeNode = updateTypleTypeNode; + ts.updateTupleTypeNode = updateTupleTypeNode; + function createOptionalTypeNode(type) { + var node = createSynthesizedNode(169 /* OptionalType */); + node.type = ts.parenthesizeArrayTypeMember(type); + return node; + } + ts.createOptionalTypeNode = createOptionalTypeNode; + function updateOptionalTypeNode(node, type) { + return node.type !== type + ? updateNode(createOptionalTypeNode(type), node) + : node; + } + ts.updateOptionalTypeNode = updateOptionalTypeNode; + function createRestTypeNode(type) { + var node = createSynthesizedNode(170 /* RestType */); + node.type = type; + return node; + } + ts.createRestTypeNode = createRestTypeNode; + function updateRestTypeNode(node, type) { + return node.type !== type + ? updateNode(createRestTypeNode(type), node) + : node; + } + ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(171 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -55865,7 +56558,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(172 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -55884,7 +56577,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(171 /* ConditionalType */); + var node = createSynthesizedNode(173 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -55902,7 +56595,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(172 /* InferType */); + var node = createSynthesizedNode(174 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -55914,7 +56607,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(179 /* ImportType */); + var node = createSynthesizedNode(181 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -55932,7 +56625,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(173 /* ParenthesizedType */); + var node = createSynthesizedNode(175 /* ParenthesizedType */); node.type = type; return node; } @@ -55944,11 +56637,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(174 /* ThisType */); + return createSynthesizedNode(176 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(175 /* TypeOperator */); + var node = createSynthesizedNode(177 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -55959,7 +56652,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(176 /* IndexedAccessType */); + var node = createSynthesizedNode(178 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -55973,7 +56666,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(177 /* MappedType */); + var node = createSynthesizedNode(179 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -55991,7 +56684,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(178 /* LiteralType */); + var node = createSynthesizedNode(180 /* LiteralType */); node.literal = literal; return node; } @@ -56004,7 +56697,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ObjectBindingPattern */); + var node = createSynthesizedNode(182 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56016,7 +56709,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(181 /* ArrayBindingPattern */); + var node = createSynthesizedNode(183 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -56028,7 +56721,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(182 /* BindingElement */); + var node = createSynthesizedNode(184 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -56047,7 +56740,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(185 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -56061,7 +56754,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(186 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -56075,7 +56768,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(185 /* PropertyAccessExpression */); + var node = createSynthesizedNode(187 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); @@ -56092,7 +56785,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(186 /* ElementAccessExpression */); + var node = createSynthesizedNode(188 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -56106,7 +56799,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* CallExpression */); + var node = createSynthesizedNode(189 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -56122,7 +56815,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(188 /* NewExpression */); + var node = createSynthesizedNode(190 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -56138,7 +56831,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(191 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -56161,7 +56854,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(190 /* TypeAssertionExpression */); + var node = createSynthesizedNode(192 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -56175,7 +56868,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(191 /* ParenthesizedExpression */); + var node = createSynthesizedNode(193 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -56187,7 +56880,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(192 /* FunctionExpression */); + var node = createSynthesizedNode(194 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -56211,7 +56904,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(193 /* ArrowFunction */); + var node = createSynthesizedNode(195 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -56245,7 +56938,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(194 /* DeleteExpression */); + var node = createSynthesizedNode(196 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56257,7 +56950,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(195 /* TypeOfExpression */); + var node = createSynthesizedNode(197 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56269,7 +56962,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(196 /* VoidExpression */); + var node = createSynthesizedNode(198 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56281,7 +56974,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(197 /* AwaitExpression */); + var node = createSynthesizedNode(199 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -56293,7 +56986,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(200 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -56306,7 +56999,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(201 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -56319,7 +57012,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(200 /* BinaryExpression */); + var node = createSynthesizedNode(202 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -56336,7 +57029,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(201 /* ConditionalExpression */); + var node = createSynthesizedNode(203 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -56366,7 +57059,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(202 /* TemplateExpression */); + var node = createSynthesizedNode(204 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -56404,7 +57097,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(203 /* YieldExpression */); + var node = createSynthesizedNode(205 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -56418,7 +57111,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(204 /* SpreadElement */); + var node = createSynthesizedNode(206 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -56430,7 +57123,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(205 /* ClassExpression */); + var node = createSynthesizedNode(207 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56451,11 +57144,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(206 /* OmittedExpression */); + return createSynthesizedNode(208 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(209 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -56469,7 +57162,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(208 /* AsExpression */); + var node = createSynthesizedNode(210 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -56483,7 +57176,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(209 /* NonNullExpression */); + var node = createSynthesizedNode(211 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -56495,7 +57188,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(210 /* MetaProperty */); + var node = createSynthesizedNode(212 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -56509,7 +57202,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(211 /* TemplateSpan */); + var node = createSynthesizedNode(214 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -56523,25 +57216,18 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(212 /* SemicolonClassElement */); + return createSynthesizedNode(215 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(213 /* Block */); + var block = createSynthesizedNode(216 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; return block; } ts.createBlock = createBlock; - /* @internal */ - function createExpressionStatement(expression) { - var node = createSynthesizedNode(216 /* ExpressionStatement */); - node.expression = expression; - return node; - } - ts.createExpressionStatement = createExpressionStatement; function updateBlock(node, statements) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -56549,7 +57235,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(214 /* VariableStatement */); + var node = createSynthesizedNode(217 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -56564,21 +57250,27 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(215 /* EmptyStatement */); + return createSynthesizedNode(218 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression) { - return createExpressionStatement(ts.parenthesizeExpressionForExpressionStatement(expression)); + function createExpressionStatement(expression) { + var node = createSynthesizedNode(219 /* ExpressionStatement */); + node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.createStatement = createStatement; - function updateStatement(node, expression) { + ts.createExpressionStatement = createExpressionStatement; + function updateExpressionStatement(node, expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } - ts.updateStatement = updateStatement; + ts.updateExpressionStatement = updateExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + ts.createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(217 /* IfStatement */); + var node = createSynthesizedNode(220 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -56594,7 +57286,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(218 /* DoStatement */); + var node = createSynthesizedNode(221 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -56608,7 +57300,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(219 /* WhileStatement */); + var node = createSynthesizedNode(222 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -56622,7 +57314,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(220 /* ForStatement */); + var node = createSynthesizedNode(223 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -56640,7 +57332,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForInStatement */); + var node = createSynthesizedNode(224 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -56656,7 +57348,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(222 /* ForOfStatement */); + var node = createSynthesizedNode(225 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -56674,7 +57366,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(223 /* ContinueStatement */); + var node = createSynthesizedNode(226 /* ContinueStatement */); node.label = asName(label); return node; } @@ -56686,7 +57378,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(224 /* BreakStatement */); + var node = createSynthesizedNode(227 /* BreakStatement */); node.label = asName(label); return node; } @@ -56698,7 +57390,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(225 /* ReturnStatement */); + var node = createSynthesizedNode(228 /* ReturnStatement */); node.expression = expression; return node; } @@ -56710,7 +57402,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(226 /* WithStatement */); + var node = createSynthesizedNode(229 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -56724,7 +57416,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(227 /* SwitchStatement */); + var node = createSynthesizedNode(230 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -56738,7 +57430,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(228 /* LabeledStatement */); + var node = createSynthesizedNode(231 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -56752,7 +57444,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(229 /* ThrowStatement */); + var node = createSynthesizedNode(232 /* ThrowStatement */); node.expression = expression; return node; } @@ -56764,7 +57456,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(230 /* TryStatement */); + var node = createSynthesizedNode(233 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -56780,11 +57472,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(231 /* DebuggerStatement */); + return createSynthesizedNode(234 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(232 /* VariableDeclaration */); + var node = createSynthesizedNode(235 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -56801,7 +57493,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(233 /* VariableDeclarationList */); + var node = createSynthesizedNode(236 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -56814,7 +57506,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(234 /* FunctionDeclaration */); + var node = createSynthesizedNode(237 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -56840,7 +57532,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* ClassDeclaration */); + var node = createSynthesizedNode(238 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56862,7 +57554,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(236 /* InterfaceDeclaration */); + var node = createSynthesizedNode(239 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56884,7 +57576,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(240 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56904,7 +57596,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(238 /* EnumDeclaration */); + var node = createSynthesizedNode(241 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56923,7 +57615,7 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* ModuleDeclaration */); + var node = createSynthesizedNode(242 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -56942,7 +57634,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(240 /* ModuleBlock */); + var node = createSynthesizedNode(243 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -56954,7 +57646,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(241 /* CaseBlock */); + var node = createSynthesizedNode(244 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -56966,7 +57658,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(245 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -56978,7 +57670,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(246 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -56996,7 +57688,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(244 /* ImportDeclaration */); + var node = createSynthesizedNode(247 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -57014,7 +57706,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(245 /* ImportClause */); + var node = createSynthesizedNode(248 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -57028,7 +57720,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(246 /* NamespaceImport */); + var node = createSynthesizedNode(249 /* NamespaceImport */); node.name = name; return node; } @@ -57040,7 +57732,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(247 /* NamedImports */); + var node = createSynthesizedNode(250 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -57052,7 +57744,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(248 /* ImportSpecifier */); + var node = createSynthesizedNode(251 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -57066,7 +57758,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(249 /* ExportAssignment */); + var node = createSynthesizedNode(252 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -57083,7 +57775,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ExportDeclaration */); + var node = createSynthesizedNode(253 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -57101,7 +57793,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(251 /* NamedExports */); + var node = createSynthesizedNode(254 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -57113,7 +57805,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(252 /* ExportSpecifier */); + var node = createSynthesizedNode(255 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -57128,7 +57820,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(254 /* ExternalModuleReference */); + var node = createSynthesizedNode(257 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -57141,7 +57833,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(255 /* JsxElement */); + var node = createSynthesizedNode(258 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -57157,7 +57849,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(259 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57173,7 +57865,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(257 /* JsxOpeningElement */); + var node = createSynthesizedNode(260 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -57189,7 +57881,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(258 /* JsxClosingElement */); + var node = createSynthesizedNode(261 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -57201,7 +57893,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(259 /* JsxFragment */); + var node = createSynthesizedNode(262 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -57217,7 +57909,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(262 /* JsxAttribute */); + var node = createSynthesizedNode(265 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -57231,7 +57923,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(263 /* JsxAttributes */); + var node = createSynthesizedNode(266 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -57243,7 +57935,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(267 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -57255,7 +57947,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(265 /* JsxExpression */); + var node = createSynthesizedNode(268 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -57269,7 +57961,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(266 /* CaseClause */); + var node = createSynthesizedNode(269 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -57283,7 +57975,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(267 /* DefaultClause */); + var node = createSynthesizedNode(270 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -57295,7 +57987,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(268 /* HeritageClause */); + var node = createSynthesizedNode(271 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -57308,7 +58000,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(269 /* CatchClause */); + var node = createSynthesizedNode(272 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -57323,7 +58015,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(270 /* PropertyAssignment */); + var node = createSynthesizedNode(273 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -57338,7 +58030,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(274 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -57352,7 +58044,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(272 /* SpreadAssignment */); + var node = createSynthesizedNode(275 /* SpreadAssignment */); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } @@ -57365,7 +58057,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(273 /* EnumMember */); + var node = createSynthesizedNode(276 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -57386,7 +58078,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(274 /* SourceFile */); + var updated = createSynthesizedNode(277 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -57470,7 +58162,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(301 /* NotEmittedStatement */); + var node = createSynthesizedNode(304 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -57482,7 +58174,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(305 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(308 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57494,7 +58186,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(304 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(307 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -57509,7 +58201,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(302 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(305 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -57525,7 +58217,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 303 /* CommaListExpression */) { + if (node.kind === 306 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -57535,7 +58227,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(303 /* CommaListExpression */); + var node = createSynthesizedNode(306 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -57548,14 +58240,14 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(275 /* Bundle */); + var node = ts.createNode(278 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text, mapPath, map) { - var node = ts.createNode(276 /* UnparsedSource */); + var node = ts.createNode(279 /* UnparsedSource */); node.text = text; node.sourceMapPath = mapPath; node.sourceMapText = map; @@ -57563,7 +58255,7 @@ var ts; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration, javascriptMapPath, javascriptMapText, declarationMapPath, declarationMapText) { - var node = ts.createNode(277 /* InputFiles */); + var node = ts.createNode(280 /* InputFiles */); node.javascriptText = javascript; node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; @@ -57706,7 +58398,7 @@ var ts; // 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 === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -58217,7 +58909,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 231 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -58235,13 +58927,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -58268,7 +58960,7 @@ var ts; } else { switch (callee.kind) { - case 185 /* PropertyAccessExpression */: { + case 187 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58281,7 +58973,7 @@ var ts; } break; } - case 186 /* ElementAccessExpression */: { + case 188 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -58341,9 +59033,9 @@ var ts; case 156 /* GetAccessor */: case 157 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); @@ -58668,7 +59360,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 191 /* ParenthesizedExpression */) { + if (skipped.kind === 193 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -58702,8 +59394,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(200 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(202 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -58712,7 +59404,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 203 /* YieldExpression */) { + && operand.kind === 205 /* YieldExpression */) { return false; } return true; @@ -58800,7 +59492,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -58815,7 +59507,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(203 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -58829,8 +59521,7 @@ var ts; // 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 var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 303 /* CommaListExpression */ + return isCommaSequence(emittedExpression) ? ts.createParen(e) : e; } @@ -58848,10 +59539,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 205 /* ClassExpression */ || - check.kind === 192 /* FunctionExpression */ || - check.kind === 303 /* CommaListExpression */ || - ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) + return check.kind === 207 /* ClassExpression */ || + check.kind === 194 /* FunctionExpression */ || + isCommaSequence(check) ? ts.createParen(e) : e; } @@ -58865,9 +59555,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.createParen(expression); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -58890,7 +59580,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 190 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -58928,7 +59618,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(202 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -58939,27 +59629,27 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { + if (kind === 194 /* FunctionExpression */ || kind === 195 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { + if (leftmostExpressionKind === 186 /* ObjectLiteralExpression */ || leftmostExpressionKind === 194 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 173 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 169 /* UnionType */: - case 170 /* IntersectionType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: return ts.createParenthesizedType(member); @@ -58970,8 +59660,8 @@ var ts; function parenthesizeArrayTypeMember(member) { switch (member.kind) { case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 172 /* InferType */: + case 177 /* TypeOperator */: + case 174 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -58997,25 +59687,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: node = node.operand; continue; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: node = node.left; continue; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: node = node.condition; continue; - case 187 /* CallExpression */: + case 189 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 186 /* ElementAccessExpression */: - case 185 /* PropertyAccessExpression */: - node = node.expression; - continue; - case 302 /* PartiallyEmittedExpression */: + case 210 /* AsExpression */: + case 188 /* ElementAccessExpression */: + case 187 /* PropertyAccessExpression */: + case 211 /* NonNullExpression */: + case 305 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -59023,12 +59713,17 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 186 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + function isCommaSequence(node) { + return node.kind === 202 /* BinaryExpression */ && node.operatorToken.kind === 26 /* CommaToken */ || + node.kind === 306 /* CommaListExpression */; + } + ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; @@ -59039,13 +59734,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: - case 209 /* NonNullExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: + case 211 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -59070,7 +59765,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 211 /* NonNullExpression */) { node = node.expression; } return node; @@ -59078,11 +59773,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 191 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 208 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 209 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 302 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 193 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 210 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -59100,7 +59795,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 191 /* ParenthesizedExpression */ + return node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -59165,10 +59860,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 247 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 253 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -59287,7 +59982,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -59299,11 +59994,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -59336,11 +60031,11 @@ var ts; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { case 149 /* Parameter */: - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 204 /* SpreadElement */: - case 272 /* SpreadAssignment */: + case 206 /* SpreadElement */: + case 275 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -59352,7 +60047,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 182 /* BindingElement */: + case 184 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -59364,7 +60059,7 @@ var ts; : propertyName; } break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -59376,7 +60071,7 @@ var ts; : propertyName; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -59394,13 +60089,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -59440,11 +60135,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 181 /* ArrayBindingPattern */: - case 183 /* ArrayLiteralExpression */: + case 183 /* ArrayBindingPattern */: + case 185 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 180 /* ObjectBindingPattern */: - case 184 /* ObjectLiteralExpression */: + case 182 /* ObjectBindingPattern */: + case 186 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -59568,7 +60263,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements)), statements); + statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); } var declarations = context.endLexicalEnvironment(); return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); @@ -59605,7 +60300,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 176 /* ThisType */) { return node; } switch (kind) { @@ -59660,217 +60355,221 @@ var ts; case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168 /* TupleType */: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 169 /* UnionType */: + return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 169 /* OptionalType */: + return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* RestType */: + return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 172 /* InferType */: + case 174 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 179 /* ImportType */: + case 181 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 177 /* MappedType */: + case 179 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 208 /* AsExpression */: + case 210 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 213 /* Block */: + case 216 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 216 /* ExpressionStatement */: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* IfStatement */: + case 219 /* ExpressionStatement */: + return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForStatement */: + case 223 /* 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, ts.liftToBlock)); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -59916,17 +60615,17 @@ var ts; return initial; } // We do not yet support types. - if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 180 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 212 /* SemicolonClassElement */: - case 215 /* EmptyStatement */: - case 206 /* OmittedExpression */: - case 231 /* DebuggerStatement */: - case 301 /* NotEmittedStatement */: + case 215 /* SemicolonClassElement */: + case 218 /* EmptyStatement */: + case 208 /* OmittedExpression */: + case 234 /* DebuggerStatement */: + case 304 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -59993,49 +60692,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 182 /* BindingElement */: + case 184 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 187 /* CallExpression */: + case 189 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* NewExpression */: + case 190 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -60043,123 +60742,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 193 /* ArrowFunction */: + case 195 /* 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 191 /* ParenthesizedExpression */: - case 194 /* DeleteExpression */: - case 195 /* TypeOfExpression */: - case 196 /* VoidExpression */: - case 197 /* AwaitExpression */: - case 203 /* YieldExpression */: - case 204 /* SpreadElement */: - case 209 /* NonNullExpression */: + case 193 /* ParenthesizedExpression */: + case 196 /* DeleteExpression */: + case 197 /* TypeOfExpression */: + case 198 /* VoidExpression */: + case 199 /* AwaitExpression */: + case 205 /* YieldExpression */: + case 206 /* SpreadElement */: + case 211 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 205 /* ClassExpression */: + case 207 /* 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 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 208 /* AsExpression */: + case 210 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 213 /* Block */: + case 216 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 218 /* DoStatement */: + case 221 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 219 /* WhileStatement */: - case 226 /* WithStatement */: + case 222 /* WhileStatement */: + case 229 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForStatement */: + case 223 /* 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 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 225 /* ReturnStatement */: - case 229 /* ThrowStatement */: + case 228 /* ReturnStatement */: + case 232 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60168,7 +60867,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -60176,139 +60875,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* EnumDeclaration */: + case 241 /* 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 239 /* ModuleDeclaration */: + case 242 /* 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 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 243 /* ImportEqualsDeclaration */: + case 246 /* 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 244 /* ImportDeclaration */: + case 247 /* 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 245 /* ImportClause */: + case 248 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 247 /* NamedImports */: - case 251 /* NamedExports */: + case 250 /* NamedImports */: + case 254 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 248 /* ImportSpecifier */: - case 252 /* ExportSpecifier */: + case 251 /* ImportSpecifier */: + case 255 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 250 /* ExportDeclaration */: + case 253 /* 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 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 258 /* JsxClosingElement */: + case 261 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 274 /* SourceFile */: + case 277 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -60381,7 +61080,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) && node.kind !== 207 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 209 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -60625,7 +61324,6 @@ var ts; } return positions; } - sourcemaps.calculateDecodedMappings = calculateDecodedMappings; function hasCompletedDecoding(state) { return state.decodingIndex === state.encodedText.length; } @@ -60772,7 +61470,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 277 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -60818,7 +61516,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -60826,13 +61524,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 243 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { + case 246 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 257 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -60862,13 +61560,13 @@ var ts; } } break; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -60876,7 +61574,7 @@ var ts; } } break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -60896,7 +61594,7 @@ var ts; } } break; - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -61512,13 +62210,14 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; - var currentScope; + var currentLexicalScope; + var currentNameScope; var currentScopeFirstDeclarationsOfName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -61542,14 +62241,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; @@ -61577,16 +62276,18 @@ var ts; */ function saveStateAndInvoke(node, f) { // Save state - var savedCurrentScope = currentScope; + var savedCurrentScope = currentLexicalScope; + var savedCurrentNameScope = currentNameScope; var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state - if (currentScope !== savedCurrentScope) { + if (currentLexicalScope !== savedCurrentScope) { currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; } - currentScope = savedCurrentScope; + currentLexicalScope = savedCurrentScope; + currentNameScope = savedCurrentNameScope; return visited; } /** @@ -61596,15 +62297,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 274 /* SourceFile */: - case 241 /* CaseBlock */: - case 240 /* ModuleBlock */: - case 213 /* Block */: - currentScope = node; + case 277 /* SourceFile */: + case 244 /* CaseBlock */: + case 243 /* ModuleBlock */: + case 216 /* Block */: + currentLexicalScope = node; + currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 235 /* ClassDeclaration */: - case 234 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 237 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -61616,7 +62318,11 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 238 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + } + if (ts.isClassDeclaration(node)) { + // XXX: should probably also cover interfaces and type aliases that can have type variables? + currentNameScope = node; } break; } @@ -61660,10 +62366,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 249 /* ExportAssignment */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 252 /* ExportAssignment */: + case 253 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -61684,13 +62390,13 @@ var ts; return node; } switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -61710,11 +62416,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 250 /* ExportDeclaration */ || - node.kind === 244 /* ImportDeclaration */ || - node.kind === 245 /* ImportClause */ || - (node.kind === 243 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 254 /* ExternalModuleReference */)) { + if (node.kind === 253 /* ExportDeclaration */ || + node.kind === 247 /* ImportDeclaration */ || + node.kind === 248 /* ImportClause */ || + (node.kind === 246 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 257 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -61756,7 +62462,7 @@ var ts; case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -61797,6 +62503,8 @@ var ts; // TypeScript accessibility and readonly modifiers are elided. case 167 /* ArrayType */: case 168 /* TupleType */: + case 169 /* OptionalType */: + case 170 /* RestType */: case 166 /* TypeLiteral */: case 161 /* TypePredicate */: case 148 /* TypeParameter */: @@ -61812,36 +62520,36 @@ var ts; case 163 /* FunctionType */: case 165 /* TypeQuery */: case 162 /* TypeReference */: - case 169 /* UnionType */: - case 170 /* IntersectionType */: - case 171 /* ConditionalType */: - case 173 /* ParenthesizedType */: - case 174 /* ThisType */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: - case 178 /* LiteralType */: + case 171 /* UnionType */: + case 172 /* IntersectionType */: + case 173 /* ConditionalType */: + case 175 /* ParenthesizedType */: + case 176 /* ThisType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: + case 180 /* LiteralType */: // TypeScript type nodes are elided. case 160 /* IndexSignature */: // TypeScript index signatures are elided. case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; case 152 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; case 155 /* Constructor */: return visitConstructor(node); - case 236 /* InterfaceDeclaration */: + case 239 /* 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61852,7 +62560,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -61863,13 +62571,13 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); case 154 /* MethodDeclaration */: @@ -61882,13 +62590,13 @@ var ts; case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case 149 /* Parameter */: @@ -61901,35 +62609,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 190 /* TypeAssertionExpression */: - case 208 /* AsExpression */: + case 192 /* TypeAssertionExpression */: + case 210 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -61965,7 +62673,7 @@ var ts; var facts = 0 /* None */; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) @@ -62008,7 +62716,7 @@ var ts; var statements = [classStatement]; // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { - statements.push(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; // Emit static property assignment. Because classDeclaration is lexically evaluated, @@ -62369,7 +63077,7 @@ var ts; // // super(...arguments); // - statements.push(ts.createStatement(ts.createCall(ts.createSuper(), + statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } // Add the property initializers. Transforms this: @@ -62411,7 +63119,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -62448,7 +63156,7 @@ var ts; ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); var localName = ts.getMutableClone(name); ts.setEmitFlags(localName, 1536 /* NoComments */); - return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); + return ts.startOnNewLine(ts.setEmitFlags(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), ts.moveRangePos(node, -1)), 1536 /* NoComments */)); } /** * Gets all property declarations with initializers on either the static or instance side of a class. @@ -62495,7 +63203,7 @@ var ts; function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { var property = properties_10[_i]; - var statement = ts.createStatement(transformInitializedProperty(property, receiver)); + var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -62798,7 +63506,7 @@ var ts; function addConstructorDecorationStatement(statements, node) { var expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); + statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node)); } } /** @@ -62925,8 +63633,8 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -62948,8 +63656,8 @@ var ts; return serializeTypeNode(node.type); case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 235 /* ClassDeclaration */: - case 205 /* ClassExpression */: + case 238 /* ClassDeclaration */: + case 207 /* ClassExpression */: case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: @@ -63037,7 +63745,7 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return serializeTypeNode(node.type); case 163 /* FunctionType */: case 164 /* ConstructorType */: @@ -63052,7 +63760,7 @@ var ts; return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 178 /* LiteralType */: + case 180 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -63072,18 +63780,18 @@ var ts; : ts.createIdentifier("Symbol"); case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 170 /* IntersectionType */: - case 169 /* UnionType */: + case 172 /* IntersectionType */: + case 171 /* UnionType */: return serializeUnionOrIntersectionType(node); case 165 /* TypeQuery */: - case 175 /* TypeOperator */: - case 176 /* IndexedAccessType */: - case 177 /* MappedType */: + case 177 /* TypeOperator */: + case 178 /* IndexedAccessType */: + case 179 /* MappedType */: case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: case 142 /* UnknownKeyword */: - case 174 /* ThisType */: - case 179 /* ImportType */: + case 176 /* ThisType */: + case 181 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63096,7 +63804,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 173 /* ParenthesizedType */) { + while (typeNode.kind === 175 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -63135,7 +63843,7 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); @@ -63182,7 +63890,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. + name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -63516,7 +64224,7 @@ var ts; // elide statement if there are no initialized variables. return undefined; } - return ts.setTextRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } else { return ts.visitEachChild(node, visitor, context); @@ -63597,7 +64305,7 @@ var ts; * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node) { - return !ts.isConst(node) + return !ts.isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -63621,7 +64329,7 @@ var ts; // enum body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63646,7 +64354,7 @@ var ts; // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63694,7 +64402,7 @@ var ts; var outerAssignment = valueExpression.kind === 9 /* StringLiteral */ ? innerAssignment : ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name); - return ts.setTextRange(ts.createStatement(ts.setTextRange(outerAssignment, member)), member); + return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); } /** * Transforms the value of an enum member. @@ -63772,12 +64480,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentScope.kind === 274 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 277 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 238 /* EnumDeclaration */) { + if (node.kind === 241 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -63839,7 +64547,7 @@ var ts; // module body. if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. - if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { + if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= 512 /* NoLeadingComments */; } } @@ -63863,7 +64571,7 @@ var ts; // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, @@ -63896,7 +64604,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 240 /* ModuleBlock */) { + if (body.kind === 243 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -63942,13 +64650,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 !== 240 /* ModuleBlock */) { + if (body.kind !== 243 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 242 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -63989,7 +64697,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 246 /* NamespaceImport */) { + if (node.kind === 249 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -64144,17 +64852,17 @@ var ts; * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression) { - return ts.createStatement(expression); + return ts.createExpressionStatement(expression); } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end)); - var statement = ts.createStatement(expression); + var statement = ts.createExpressionStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.setTextRange(ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); + return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue)), location); } function createNamespaceExportExpression(exportName, exportValue, location) { return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location); @@ -64221,16 +64929,16 @@ 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(71 /* Identifier */); - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(239 /* ModuleDeclaration */); + context.enableEmitNotification(242 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 242 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 241 /* EnumDeclaration */; } /** * Hook for node emit. @@ -64291,9 +64999,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -64331,9 +65039,9 @@ 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 !== 274 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); + if (container && container.kind !== 277 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 242 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 241 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -64468,15 +65176,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -64485,27 +65193,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 213 /* Block */: - case 227 /* SwitchStatement */: - case 241 /* CaseBlock */: - case 266 /* CaseClause */: - case 267 /* DefaultClause */: - case 230 /* TryStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: - case 217 /* IfStatement */: - case 226 /* WithStatement */: - case 228 /* LabeledStatement */: + case 216 /* Block */: + case 230 /* SwitchStatement */: + case 244 /* CaseBlock */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: + case 233 /* TryStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: + case 220 /* IfStatement */: + case 229 /* WithStatement */: + case 231 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -64540,7 +65248,7 @@ var ts; function visitVariableStatementInAsyncBody(node) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? ts.createStatement(expression) : undefined; + return expression ? ts.createExpressionStatement(expression) : undefined; } return ts.visitEachChild(node, visitor, context); } @@ -64706,7 +65414,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 === 193 /* ArrowFunction */; + var isArrowFunction = node.kind === 195 /* 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 @@ -64779,11 +65487,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -64827,11 +65535,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -64863,7 +65571,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -64962,25 +65670,25 @@ var ts; return node; } switch (node.kind) { - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return visitAwaitExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return visitVoidExpression(node); case 155 /* Constructor */: return visitConstructorDeclaration(node); @@ -64990,19 +65698,19 @@ var ts; return visitGetAccessorDeclaration(node); case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); case 149 /* Parameter */: return visitParameter(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -65036,7 +65744,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 225 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -65048,7 +65756,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 272 /* SpreadAssignment */) { + if (e.kind === 275 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -65057,7 +65765,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 273 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -65075,7 +65783,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 !== 184 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 186 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -65214,13 +65922,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -65388,11 +66096,11 @@ 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(187 /* CallExpression */); - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(186 /* ElementAccessExpression */); + context.enableSubstitution(189 /* CallExpression */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(188 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(238 /* ClassDeclaration */); context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); @@ -65436,11 +66144,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -65472,7 +66180,7 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 235 /* ClassDeclaration */ + return kind === 238 /* ClassDeclaration */ || kind === 155 /* Constructor */ || kind === 154 /* MethodDeclaration */ || kind === 156 /* GetAccessor */ @@ -65585,13 +66293,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -65601,13 +66309,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return visitJsxExpression(node); - case 255 /* JsxElement */: + case 258 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -65682,7 +66390,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 265 /* JsxExpression */) { + else if (node.kind === 268 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -65776,7 +66484,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 255 /* JsxElement */) { + if (node.kind === 258 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -66082,7 +66790,7 @@ var ts; return node; } switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66315,13 +67023,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 225 /* ReturnStatement */ + && node.kind === 228 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 216 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -66349,63 +67057,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return visitClassExpression(node); case 149 /* Parameter */: return visitParameter(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return visitArrowFunction(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 224 /* BreakStatement */: - case 223 /* ContinueStatement */: + case 227 /* BreakStatement */: + case 226 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -66416,28 +67124,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return visitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return visitMetaProperty(node); case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -66524,14 +67232,14 @@ 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 === 224 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 227 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -66542,7 +67250,7 @@ var ts; } } else { - if (node.kind === 224 /* BreakStatement */) { + if (node.kind === 227 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -66659,7 +67367,7 @@ var ts; if (node.name) { enableSubstitutionsForBlockScopedBindings(); } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var classFunction = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -66723,7 +67431,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.setTextRange(ts.createStatement(createExtendsHelper(context, ts.getInternalName(node))), + statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), /*location*/ extendsClauseElement)); } } @@ -66842,11 +67550,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 225 /* ReturnStatement */) { + if (statement.kind === 228 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 217 /* IfStatement */) { + else if (statement.kind === 220 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -66854,7 +67562,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 213 /* Block */) { + else if (statement.kind === 216 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -66912,7 +67620,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 219 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -66922,8 +67630,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 200 /* BinaryExpression */ - || superCallExpression.left.kind !== 187 /* CallExpression */) { + if (superCallExpression.kind !== 202 /* BinaryExpression */ + || superCallExpression.left.kind !== 189 /* 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. @@ -67038,7 +67746,7 @@ var ts; /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -67052,7 +67760,7 @@ 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.setTextRange(ts.createBlock([ - ts.createStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); @@ -67104,7 +67812,7 @@ var ts; var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) ]), 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 + ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) @@ -67120,7 +67828,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 195 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -67140,7 +67848,7 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return statements; case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -67154,8 +67862,8 @@ var ts; // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 234 /* FunctionDeclaration */: - case 192 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 194 /* 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 */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -67186,7 +67894,7 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; case 154 /* MethodDeclaration */: @@ -67230,7 +67938,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createStatement(ts.createAssignment(memberName, memberFunction)), + var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); @@ -67248,7 +67956,7 @@ var ts; * @param accessors The set of related get/set accessors. */ function transformAccessorsToStatement(receiver, accessors, container) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false)); + var statement = ts.createExpressionStatement(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. @@ -67391,7 +68099,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 237 /* FunctionDeclaration */ || node.kind === 194 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -67436,7 +68144,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 193 /* ArrowFunction */); + ts.Debug.assert(node.kind === 195 /* 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 @@ -67504,10 +68212,10 @@ 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 191 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + case 193 /* ParenthesizedExpression */: + return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 202 /* BinaryExpression */: + return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); } @@ -67525,9 +68233,9 @@ var ts; // 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 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -67569,7 +68277,7 @@ var ts; } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.inlineExpressions(assignments)), node); + updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -67728,14 +68436,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -67793,11 +68501,11 @@ var ts; var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); - statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); + statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -67886,13 +68594,13 @@ var ts; return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ ts.createPropertyAssignment("error", catchVariable) ]))) ]), 1 /* SingleLine */)), ts.createBlock([ ts.createTry( /*tryBlock*/ ts.createBlock([ - ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ @@ -67991,11 +68699,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 220 /* ForStatement */: - case 221 /* ForInStatement */: - case 222 /* ForOfStatement */: + case 223 /* ForStatement */: + case 224 /* ForInStatement */: + case 225 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 236 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -68159,7 +68867,7 @@ var ts; function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { @@ -68176,7 +68884,7 @@ var ts; ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); + statements.push(ts.createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { @@ -68285,10 +68993,10 @@ var ts; case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -68540,7 +69248,7 @@ var ts; statements.push(funcStatements[classBodyStart]); classBodyStart++; // Add the class alias following the declaration. - statements.push(ts.createStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier)))); } // Find the trailing 'return' statement (4) while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) { @@ -68677,7 +69385,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 185 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -68944,9 +69652,9 @@ var ts; context.enableEmitNotification(154 /* MethodDeclaration */); context.enableEmitNotification(156 /* GetAccessor */); context.enableEmitNotification(157 /* SetAccessor */); - context.enableEmitNotification(193 /* ArrowFunction */); - context.enableEmitNotification(192 /* FunctionExpression */); - context.enableEmitNotification(234 /* FunctionDeclaration */); + context.enableEmitNotification(195 /* ArrowFunction */); + context.enableEmitNotification(194 /* FunctionExpression */); + context.enableEmitNotification(237 /* FunctionDeclaration */); } } /** @@ -68987,10 +69695,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: - case 238 /* EnumDeclaration */: - case 232 /* VariableDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: + case 241 /* EnumDeclaration */: + case 235 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -69072,11 +69780,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 219 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 189 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -69084,7 +69792,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 206 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -69137,15 +69845,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(257 /* JsxOpeningElement */); - context.enableEmitNotification(258 /* JsxClosingElement */); - context.enableEmitNotification(256 /* JsxSelfClosingElement */); + context.enableEmitNotification(260 /* JsxOpeningElement */); + context.enableEmitNotification(261 /* JsxClosingElement */); + context.enableEmitNotification(259 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(185 /* PropertyAccessExpression */); - context.enableSubstitution(270 /* PropertyAssignment */); + context.enableSubstitution(187 /* PropertyAccessExpression */); + context.enableSubstitution(273 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -69164,9 +69872,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 257 /* JsxOpeningElement */: - case 258 /* JsxClosingElement */: - case 256 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: + case 261 /* JsxClosingElement */: + case 259 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -69498,13 +70206,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -69517,24 +70225,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); case 156 /* GetAccessor */: case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return visitBreakStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return visitContinueStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -69555,21 +70263,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return visitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return visitConditionalExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return visitYieldExpression(node); - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return visitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -69582,9 +70290,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -69760,7 +70468,7 @@ var ts; if (variables.length === 0) { return undefined; } - return ts.setSourceMapRange(ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); + return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node); } } /** @@ -69812,7 +70520,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -69824,7 +70532,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -69948,7 +70656,7 @@ var ts; } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [ts.createStatement(ts.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* Statement */, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -70101,7 +70809,7 @@ var ts; return ts.inlineExpressions(expressions); function reduceProperty(expressions, property) { if (containsYield(property) && expressions.length > 0) { - emitStatement(ts.createStatement(ts.inlineExpressions(expressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions))); expressions = []; } var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp); @@ -70200,35 +70908,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: return transformAndEmitBlock(node); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return transformAndEmitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return transformAndEmitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return transformAndEmitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return transformAndEmitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -70265,7 +70973,7 @@ var ts; pendingExpressions.push(transformInitializedVariable(variable)); } if (pendingExpressions.length) { - emitStatement(ts.createStatement(ts.inlineExpressions(pendingExpressions))); + emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -70416,7 +71124,7 @@ var ts; transformAndEmitVariableDeclarationList(initializer); } else { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer)); } } markLabel(conditionLabel); @@ -70426,7 +71134,7 @@ var ts; transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); if (node.incrementor) { - emitStatement(ts.setTextRange(ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); + emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor)); } emitBreak(conditionLabel); endLoopBlock(); @@ -70487,7 +71195,7 @@ var ts; var initializer = node.initializer; hoistVariableDeclaration(keysIndex); emitAssignment(keysArray, ts.createArrayLiteral()); - emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), + emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, [key])))); emitAssignment(keysIndex, ts.createLiteral(0)); var conditionLabel = defineLabel(); @@ -70510,7 +71218,7 @@ var ts; emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex)); transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(ts.createStatement(ts.createPostfixIncrement(keysIndex))); + emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); } @@ -70658,7 +71366,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 270 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -70671,7 +71379,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 266 /* CaseClause */) { + if (clause.kind === 269 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -71534,7 +72242,7 @@ var ts; // indicate entry into a protected region by pushing the label numbers // for each block in the protected region. var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, [ ts.createArrayLiteral([ createLabel(startLabel), @@ -71548,7 +72256,7 @@ var ts; if (markLabelEnd) { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); + statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } } clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); @@ -71706,7 +72414,7 @@ var ts; * @param operationLocation The source map location for the operation. */ function writeAssign(left, right, operationLocation) { - writeStatement(ts.setTextRange(ts.createStatement(ts.createAssignment(left, right)), operationLocation)); + writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation)); } /** * Writes a Throw operation to the current label's statement list. @@ -71900,11 +72608,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(277 /* 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. @@ -71997,7 +72705,7 @@ var ts; // // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(define, + ts.createExpressionStatement(ts.createCall(define, /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ // Add the dependency array argument: // @@ -72048,9 +72756,9 @@ var ts; 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.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(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"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), @@ -72074,7 +72782,7 @@ var ts; // } // })(function ...) var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(umdHeader, + ts.createExpressionStatement(ts.createCall(umdHeader, /*typeArguments*/ undefined, [ // Add the module body function argument: // @@ -72153,7 +72861,7 @@ var ts; if (expr === name) { return undefined; } - return ts.createStatement(ts.createAssignment(name, expr)); + return ts.createExpressionStatement(ts.createAssignment(name, expr)); } /** * Transforms a SourceFile into an AMD or UMD module body. @@ -72208,7 +72916,7 @@ var ts; statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 1536 /* NoComments */); statements.push(statement); @@ -72226,23 +72934,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return visitExportDeclaration(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -72269,17 +72977,17 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } @@ -72373,7 +73081,7 @@ var ts; ts.createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; var body = ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("require"), + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject])) ]); var func; @@ -72468,7 +73176,7 @@ var ts; if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return ts.setTextRange(ts.createStatement(createRequireCall(node)), node); + return ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node); } else { var variables = []; @@ -72536,7 +73244,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node)); } else { statements = ts.append(statements, ts.setTextRange(ts.createVariableStatement( @@ -72549,7 +73257,7 @@ var ts; } else { if (ts.hasModifier(node, 1 /* Export */)) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node)); } } if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -72588,13 +73296,13 @@ var ts; 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)); + statements.push(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier)); } return ts.singleOrMany(statements); } else { // export * from "mod"; - return ts.setTextRange(ts.createStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); + return ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node); } } /** @@ -72700,7 +73408,7 @@ var ts; 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)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } } else { @@ -72761,7 +73469,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -72816,10 +73524,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -72949,10 +73657,10 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); + statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { - statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ ts.createIdentifier("exports"), ts.createLiteral("__esModule"), @@ -72973,7 +73681,7 @@ var ts; * @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); + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -73018,7 +73726,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -73082,10 +73790,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 199 /* PostfixUnaryExpression */: - case 198 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -73106,7 +73814,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -73181,7 +73889,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -73257,11 +73965,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(274 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(274 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(202 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(200 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(201 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(277 /* 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. @@ -73323,7 +74031,7 @@ var ts; 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.setTextRange(ts.createNodeArray([ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) @@ -73482,7 +74190,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 253 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -73507,7 +74215,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 250 /* ExportDeclaration */) { + if (externalImport.kind !== 253 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -73561,9 +74269,9 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1 /* SingleLine */) ])), - ts.createStatement(ts.createCall(exportFunction, + ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exports])) ], /*multiline*/ true)); } @@ -73585,19 +74293,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -73613,7 +74321,7 @@ var ts; var e = _d[_c]; properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name))))); } - statements.push(ts.createStatement(ts.createCall(exportFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*multiline*/ true)]))); } else { @@ -73622,7 +74330,7 @@ var ts; // emit as: // // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, + statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, /*typeArguments*/ undefined, [parameterName]))); } break; @@ -73647,15 +74355,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return visitImportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -73756,7 +74464,7 @@ 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.setTextRange(ts.createStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node)); if (hasAssociatedEndOfDeclarationMarker(node)) { @@ -73793,7 +74501,7 @@ var ts; } var statements; if (expressions) { - statements = ts.append(statements, ts.setTextRange(ts.createStatement(ts.inlineExpressions(expressions)), node)); + statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -73831,7 +74539,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 274 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 277 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -73895,7 +74603,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 === 214 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 217 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -73957,10 +74665,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -74112,7 +74820,7 @@ var ts; * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name, value, allowComments) { - var statement = ts.createStatement(createExportExpression(name, value)); + var statement = ts.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -74140,43 +74848,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return visitVariableStatement(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return visitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return visitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return visitForOfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return visitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return visitWhileStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return visitLabeledStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return visitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return visitSwitchStatement(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return visitCaseBlock(node); - case 266 /* CaseClause */: + case 269 /* CaseClause */: return visitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return visitDefaultClause(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return visitTryStatement(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return visitCatchClause(node); - case 213 /* Block */: + case 216 /* Block */: return visitBlock(node); - case 304 /* MergeDeclarationMarker */: + case 307 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 305 /* EndOfDeclarationMarker */: + case 308 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -74359,7 +75067,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 200 /* BinaryExpression */) { + && node.kind === 202 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -74424,7 +75132,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 274 /* SourceFile */; + return container !== undefined && container.kind === 277 /* SourceFile */; } else { return false; @@ -74457,7 +75165,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 274 /* SourceFile */) { + if (node.kind === 277 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -74505,7 +75213,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -74541,10 +75249,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PrefixUnaryExpression */: - case 199 /* PostfixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -74637,14 +75345,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 199 /* PostfixUnaryExpression */ + var expression = node.kind === 201 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 199 /* PostfixUnaryExpression */) { + if (node.kind === 201 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -74666,7 +75374,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 277 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -74705,7 +75413,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(274 /* SourceFile */); + context.enableEmitNotification(277 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -74734,10 +75442,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -74844,7 +75552,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -74873,7 +75581,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -74920,7 +75628,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { 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 : @@ -74939,7 +75647,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 === 235 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { + else if (node.parent.kind === 238 /* ClassDeclaration */ || node.kind === 149 /* Parameter */) { 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 : @@ -75030,7 +75738,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 === 235 /* ClassDeclaration */) { + else if (node.parent.kind === 238 /* 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 : @@ -75044,7 +75752,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 234 /* FunctionDeclaration */: + case 237 /* 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 : @@ -75100,7 +75808,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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 : @@ -75113,7 +75821,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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: case 163 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -75128,10 +75836,10 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; case 159 /* ConstructSignature */: @@ -75145,17 +75853,17 @@ var ts; 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 === 235 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 238 /* 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 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -75170,7 +75878,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 235 /* ClassDeclaration */) { + if (node.parent.parent.kind === 238 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = node.parent.token === 108 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -75267,7 +75975,13 @@ var ts; necessaryTypeRefernces.set(ref, true); } } - function trackReferencedAmbientModule(node) { + function trackReferencedAmbientModule(node, symbol) { + // If it is visible via `// `, then we should just use that + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + if (ts.length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference var container = ts.getSourceFileOfNode(node); refs.set("" + ts.getOriginalNodeId(container), container); } @@ -75322,10 +76036,10 @@ var ts; } } function transformRoot(node) { - if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 277 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 275 /* Bundle */) { + if (node.kind === 278 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; @@ -75353,7 +76067,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 277 /* InputFiles */) { + if (prepend.kind === 280 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); @@ -75451,7 +76165,7 @@ var ts; return name; } else { - if (name.kind === 181 /* ArrayBindingPattern */) { + if (name.kind === 183 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -75459,7 +76173,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 206 /* OmittedExpression */) { + if (elem.kind === 208 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -75517,7 +76231,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { + if (node.kind === 235 /* VariableDeclaration */ || node.kind === 184 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } if (node.kind === 149 /* Parameter */ @@ -75539,20 +76253,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 243 /* ImportEqualsDeclaration */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 246 /* ImportEqualsDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return false; } return false; @@ -75606,7 +76320,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 242 /* ModuleDeclaration */ && parent.kind !== 181 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -75618,7 +76332,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 257 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -75645,7 +76359,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 246 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 249 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -75750,14 +76464,14 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 179 /* MappedType */) && input.parent.kind !== 240 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 207 /* ExpressionWithTypeArguments */: { + case 209 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } @@ -75811,7 +76525,7 @@ var ts; return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 232 /* VariableDeclaration */: { + case 235 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -75825,7 +76539,7 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 171 /* ConditionalType */: { + case 173 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -75843,7 +76557,7 @@ var ts; case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 179 /* ImportType */: { + case 181 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -75882,7 +76596,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 250 /* ExportDeclaration */: { + case 253 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -75891,7 +76605,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 249 /* ExportAssignment */: { + case 252 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -75921,10 +76635,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 243 /* ImportEqualsDeclaration */: { + case 246 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 244 /* ImportDeclaration */: { + case 247 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -75945,24 +76659,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 240 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 236 /* InterfaceDeclaration */: { + case 239 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 234 /* FunctionDeclaration */: { + case 237 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type return cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); } - case 239 /* ModuleDeclaration */: { + case 242 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 240 /* ModuleBlock */) { + if (inner && inner.kind === 243 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -75983,7 +76697,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 235 /* ClassDeclaration */: { + case 238 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -76023,7 +76737,7 @@ var ts; getSymbolAccessibilityDiagnostic = oldDiag_1; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); - var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); + var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 @@ -76053,10 +76767,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 214 /* VariableStatement */: { + case 217 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 238 /* EnumDeclaration */: { + case 241 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -76075,7 +76789,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 239 /* ModuleDeclaration */) { + if (input.kind === 242 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -76096,7 +76810,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 206 /* OmittedExpression */) { + if (e.kind === 208 /* OmittedExpression */) { return; } if (e.name) { @@ -76150,7 +76864,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 274 /* SourceFile */; + var parentIsFile = node.parent.kind === 277 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -76171,7 +76885,7 @@ var ts; var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); if (leadingsSyntheticCommentRanges) { - var _loop_10 = function (range) { + var _loop_9 = function (range) { if (range.kind === 3 /* MultiLineCommentTrivia */) { var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); var lines = text.split(/\r\n?|\n/g); @@ -76185,7 +76899,7 @@ var ts; }; for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_10(range); + _loop_9(range); } } return prop; @@ -76198,7 +76912,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 236 /* InterfaceDeclaration */) { + if (node.kind === 239 /* InterfaceDeclaration */) { return true; } return false; @@ -76227,7 +76941,7 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 152 /* PropertyDeclaration */: case 151 /* PropertySignature */: case 149 /* Parameter */: @@ -76237,17 +76951,17 @@ var ts; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 234 /* FunctionDeclaration */: - case 239 /* ModuleDeclaration */: - case 243 /* ImportEqualsDeclaration */: - case 236 /* InterfaceDeclaration */: - case 235 /* ClassDeclaration */: - case 237 /* TypeAliasDeclaration */: - case 238 /* EnumDeclaration */: - case 214 /* VariableStatement */: - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 242 /* ModuleDeclaration */: + case 246 /* ImportEqualsDeclaration */: + case 239 /* InterfaceDeclaration */: + case 238 /* ClassDeclaration */: + case 240 /* TypeAliasDeclaration */: + case 241 /* EnumDeclaration */: + case 217 /* VariableStatement */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: + case 252 /* ExportAssignment */: return true; } return false; @@ -76264,14 +76978,14 @@ var ts; case 153 /* MethodSignature */: case 158 /* CallSignature */: case 160 /* IndexSignature */: - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 148 /* TypeParameter */: - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: case 162 /* TypeReference */: - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: case 163 /* FunctionType */: case 164 /* ConstructorType */: - case 179 /* ImportType */: + case 181 /* ImportType */: return true; } return false; @@ -76347,7 +77061,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(306 /* Count */); + var enabledSyntaxKindFeatures = new Array(309 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -76682,7 +77396,6 @@ var ts; sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the // relative paths of the sources list in the sourcemap @@ -76692,7 +77405,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 277 /* 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 = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -76783,7 +77496,6 @@ var ts; lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** * Emits a mapping. @@ -76843,6 +77555,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { + var _a; if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } @@ -76853,50 +77566,55 @@ var ts; try { parsed = JSON.parse(text); } - catch (_a) { + catch (_b) { // empty } if (!parsed || !isPossiblySourceMap(parsed)) { return emitCallback(hint, node); } - var offsetLine_1 = writer.getLine(); - var firstLineColumnOffset_1 = writer.getColumn(); + var offsetLine = writer.getLine(); + var firstLineColumnOffset = writer.getColumn(); // First, decode the old component sourcemap - var originalMap_1 = parsed; - var sourcesDirectoryPath_1 = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var resolvedPathCache_1 = ts.createMap(); - ts.sourcemaps.calculateDecodedMappings(originalMap_1, function (raw) { + var originalMap = parsed; + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + var resolvedPathCache = ts.createMap(); + var absolutePathCache = ts.createMap(); + var sourcemapIterator = ts.sourcemaps.decodeMappings(originalMap); + for (var _c = sourcemapIterator.next(), raw = _c.value, done = _c.done; !done; _a = sourcemapIterator.next(), raw = _a.value, done = _a.done, _a) { + var pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - var rawPath = originalMap_1.sources[raw.sourceIndex]; - var relativePath = originalMap_1.sourceRoot ? ts.combinePaths(originalMap_1.sourceRoot, rawPath) : rawPath; - var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); - if (!resolvedPathCache_1.has(combinedPath)) { - resolvedPathCache_1.set(combinedPath, ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath_1, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true)); - } - var resolvedPath = resolvedPathCache_1.get(combinedPath); - var absolutePath = ts.getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath_1); + if (!resolvedPathCache.has(pathCacheKey)) { + var rawPath = originalMap.sources[raw.sourceIndex]; + var relativePath = originalMap.sourceRoot ? ts.combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + var combinedPath = ts.combinePaths(ts.getDirectoryPath(node.sourceMapPath), relativePath); + var resolvedPath_1 = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + resolvedPathCache.set(pathCacheKey, resolvedPath_1); + absolutePathCache.set(pathCacheKey, ts.getNormalizedAbsolutePath(resolvedPath_1, sourcesDirectoryPath)); + } + var resolvedPath = resolvedPathCache.get(pathCacheKey); + var absolutePath = absolutePathCache.get(pathCacheKey); // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap_1.sourcesContent ? originalMap_1.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? var newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine_1, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset_1) : raw.emittedColumn, sourceIndex: newIndex }); - }); + lastRecordedSourceMapSpan = __assign({}, raw, { emittedLine: raw.emittedLine + offsetLine, emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; - var _b = range || node, pos = _b.pos, end = _b.end; + var _d = range || node, pos = _d.pos, end = _d.end; var source = range && range.source; var oldSource = currentSource; if (source === oldSource) source = undefined; if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -76913,7 +77631,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 301 /* NotEmittedStatement */ + if (node.kind !== 304 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -76968,13 +77686,15 @@ var ts; } setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName, content) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName, content, source) { + if (!source) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { sourceMapSourceIndex = sourceMapData.sourceMapSources.length; @@ -77090,7 +77810,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 301 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 304 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 10 /* JsxText */; @@ -77111,7 +77831,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 === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -77453,7 +78173,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 275 /* Bundle */) { + if (sourceFile.kind === 278 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; @@ -77588,6 +78308,11 @@ var ts; // Setup and perform the transformation to retrieve declarations from the input files var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJavaScript); var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + if (emitOnlyDtsFiles && !compilerOptions.declaration) { + // Checker wont collect the linked aliases since thats only done when declaration is enabled. + // Do that here when emitting only dts files + nonJsFiles.forEach(collectLinkedAliases); + } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, ts.concatenate([ts.transformDeclarations], declarationTransformers), /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) { @@ -77615,9 +78340,22 @@ var ts; } declarationTransform.dispose(); } + function collectLinkedAliases(node) { + if (ts.isExportAssignment(node)) { + if (node.expression.kind === 71 /* Identifier */) { + resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); + } + return; + } + else if (ts.isExportSpecifier(node)) { + resolver.collectLinkedAliases(node.propertyName || node.name, /*setVisibility*/ true); + return; + } + ts.forEachChild(node, collectLinkedAliases); + } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 278 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 277 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -77717,9 +78455,9 @@ var ts; break; } switch (node.kind) { - case 274 /* SourceFile */: return printFile(node); - case 275 /* Bundle */: return printBundle(node); - case 276 /* UnparsedSource */: return printUnparsedSource(node); + case 277 /* SourceFile */: return printFile(node); + case 278 /* Bundle */: return printBundle(node); + case 279 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -77864,7 +78602,7 @@ var ts; } return pipelineEmitWithoutComments; case 2 /* SourceMaps */: - if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { + if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */) { return pipelineEmitWithSourceMap; } // falls through @@ -77890,7 +78628,7 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); + ts.Debug.assert(hint !== 0 /* SourceFile */); ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { @@ -77909,7 +78647,7 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 276 /* UnparsedSource */: + case 279 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: @@ -77954,7 +78692,7 @@ var ts; return emitTypeReference(node); case 163 /* FunctionType */: return emitFunctionType(node); - case 284 /* JSDocFunctionType */: + case 287 /* JSDocFunctionType */: return emitJSDocFunctionType(node); case 164 /* ConstructorType */: return emitConstructorType(node); @@ -77966,178 +78704,181 @@ var ts; return emitArrayType(node); case 168 /* TupleType */: return emitTupleType(node); - case 169 /* UnionType */: + case 169 /* OptionalType */: + return emitOptionalType(node); + case 171 /* UnionType */: return emitUnionType(node); - case 170 /* IntersectionType */: + case 172 /* IntersectionType */: return emitIntersectionType(node); - case 171 /* ConditionalType */: + case 173 /* ConditionalType */: return emitConditionalType(node); - case 172 /* InferType */: + case 174 /* InferType */: return emitInferType(node); - case 173 /* ParenthesizedType */: + case 175 /* ParenthesizedType */: return emitParenthesizedType(node); - case 207 /* ExpressionWithTypeArguments */: + case 209 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 174 /* ThisType */: + case 176 /* ThisType */: return emitThisType(); - case 175 /* TypeOperator */: + case 177 /* TypeOperator */: return emitTypeOperator(node); - case 176 /* IndexedAccessType */: + case 178 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 177 /* MappedType */: + case 179 /* MappedType */: return emitMappedType(node); - case 178 /* LiteralType */: + case 180 /* LiteralType */: return emitLiteralType(node); - case 179 /* ImportType */: + case 181 /* ImportType */: return emitImportTypeNode(node); - case 279 /* JSDocAllType */: + case 282 /* JSDocAllType */: write("*"); return; - case 280 /* JSDocUnknownType */: + case 283 /* JSDocUnknownType */: write("?"); return; - case 281 /* JSDocNullableType */: + case 284 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 282 /* JSDocNonNullableType */: + case 285 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 283 /* JSDocOptionalType */: + case 286 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 285 /* JSDocVariadicType */: - return emitJSDocVariadicType(node); + case 170 /* RestType */: + case 288 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); // Binding patterns - case 180 /* ObjectBindingPattern */: + case 182 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 181 /* ArrayBindingPattern */: + case 183 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 182 /* BindingElement */: + case 184 /* BindingElement */: return emitBindingElement(node); // Misc - case 211 /* TemplateSpan */: + case 214 /* TemplateSpan */: return emitTemplateSpan(node); - case 212 /* SemicolonClassElement */: + case 215 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 213 /* Block */: + case 216 /* Block */: return emitBlock(node); - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: return emitVariableStatement(node); - case 215 /* EmptyStatement */: + case 218 /* EmptyStatement */: return emitEmptyStatement(); - case 216 /* ExpressionStatement */: + case 219 /* ExpressionStatement */: return emitExpressionStatement(node); - case 217 /* IfStatement */: + case 220 /* IfStatement */: return emitIfStatement(node); - case 218 /* DoStatement */: + case 221 /* DoStatement */: return emitDoStatement(node); - case 219 /* WhileStatement */: + case 222 /* WhileStatement */: return emitWhileStatement(node); - case 220 /* ForStatement */: + case 223 /* ForStatement */: return emitForStatement(node); - case 221 /* ForInStatement */: + case 224 /* ForInStatement */: return emitForInStatement(node); - case 222 /* ForOfStatement */: + case 225 /* ForOfStatement */: return emitForOfStatement(node); - case 223 /* ContinueStatement */: + case 226 /* ContinueStatement */: return emitContinueStatement(node); - case 224 /* BreakStatement */: + case 227 /* BreakStatement */: return emitBreakStatement(node); - case 225 /* ReturnStatement */: + case 228 /* ReturnStatement */: return emitReturnStatement(node); - case 226 /* WithStatement */: + case 229 /* WithStatement */: return emitWithStatement(node); - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: return emitSwitchStatement(node); - case 228 /* LabeledStatement */: + case 231 /* LabeledStatement */: return emitLabeledStatement(node); - case 229 /* ThrowStatement */: + case 232 /* ThrowStatement */: return emitThrowStatement(node); - case 230 /* TryStatement */: + case 233 /* TryStatement */: return emitTryStatement(node); - case 231 /* DebuggerStatement */: + case 234 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: return emitClassDeclaration(node); - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 240 /* ModuleBlock */: + case 243 /* ModuleBlock */: return emitModuleBlock(node); - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: return emitCaseBlock(node); - case 242 /* NamespaceExportDeclaration */: + case 245 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: return emitImportDeclaration(node); - case 245 /* ImportClause */: + case 248 /* ImportClause */: return emitImportClause(node); - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: return emitNamespaceImport(node); - case 247 /* NamedImports */: + case 250 /* NamedImports */: return emitNamedImports(node); - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: return emitImportSpecifier(node); - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: return emitExportAssignment(node); - case 250 /* ExportDeclaration */: + case 253 /* ExportDeclaration */: return emitExportDeclaration(node); - case 251 /* NamedExports */: + case 254 /* NamedExports */: return emitNamedExports(node); - case 252 /* ExportSpecifier */: + case 255 /* ExportSpecifier */: return emitExportSpecifier(node); - case 253 /* MissingDeclaration */: + case 256 /* MissingDeclaration */: return; // Module references - case 254 /* ExternalModuleReference */: + case 257 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 257 /* JsxOpeningElement */: - case 260 /* JsxOpeningFragment */: + case 260 /* JsxOpeningElement */: + case 263 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 258 /* JsxClosingElement */: - case 261 /* JsxClosingFragment */: + case 261 /* JsxClosingElement */: + case 264 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 262 /* JsxAttribute */: + case 265 /* JsxAttribute */: return emitJsxAttribute(node); - case 263 /* JsxAttributes */: + case 266 /* JsxAttributes */: return emitJsxAttributes(node); - case 264 /* JsxSpreadAttribute */: + case 267 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 265 /* JsxExpression */: + case 268 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 266 /* CaseClause */: + case 269 /* CaseClause */: return emitCaseClause(node); - case 267 /* DefaultClause */: + case 270 /* DefaultClause */: return emitDefaultClause(node); - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: return emitHeritageClause(node); - case 269 /* CatchClause */: + case 272 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 270 /* PropertyAssignment */: + case 273 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 271 /* ShorthandPropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 272 /* SpreadAssignment */: + case 275 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 273 /* EnumMember */: + case 276 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -78172,71 +78913,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 183 /* ArrayLiteralExpression */: + case 185 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 184 /* ObjectLiteralExpression */: + case 186 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 185 /* PropertyAccessExpression */: + case 187 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 186 /* ElementAccessExpression */: + case 188 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 187 /* CallExpression */: + case 189 /* CallExpression */: return emitCallExpression(node); - case 188 /* NewExpression */: + case 190 /* NewExpression */: return emitNewExpression(node); - case 189 /* TaggedTemplateExpression */: + case 191 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 191 /* ParenthesizedExpression */: + case 193 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 192 /* FunctionExpression */: + case 194 /* FunctionExpression */: return emitFunctionExpression(node); - case 193 /* ArrowFunction */: + case 195 /* ArrowFunction */: return emitArrowFunction(node); - case 194 /* DeleteExpression */: + case 196 /* DeleteExpression */: return emitDeleteExpression(node); - case 195 /* TypeOfExpression */: + case 197 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 196 /* VoidExpression */: + case 198 /* VoidExpression */: return emitVoidExpression(node); - case 197 /* AwaitExpression */: + case 199 /* AwaitExpression */: return emitAwaitExpression(node); - case 198 /* PrefixUnaryExpression */: + case 200 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 199 /* PostfixUnaryExpression */: + case 201 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 200 /* BinaryExpression */: + case 202 /* BinaryExpression */: return emitBinaryExpression(node); - case 201 /* ConditionalExpression */: + case 203 /* ConditionalExpression */: return emitConditionalExpression(node); - case 202 /* TemplateExpression */: + case 204 /* TemplateExpression */: return emitTemplateExpression(node); - case 203 /* YieldExpression */: + case 205 /* YieldExpression */: return emitYieldExpression(node); - case 204 /* SpreadElement */: + case 206 /* SpreadElement */: return emitSpreadExpression(node); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return emitClassExpression(node); - case 206 /* OmittedExpression */: + case 208 /* OmittedExpression */: return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: return emitAsExpression(node); - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: return emitNonNullExpression(node); - case 210 /* MetaProperty */: + case 212 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 255 /* JsxElement */: + case 258 /* JsxElement */: return emitJsxElement(node); - case 256 /* JsxSelfClosingElement */: + case 259 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 259 /* JsxFragment */: + case 262 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 302 /* PartiallyEmittedExpression */: + case 305 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 303 /* CommaListExpression */: + case 306 /* CommaListExpression */: return emitCommaList(node); } } @@ -78253,7 +78994,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 275 /* Bundle */ ? node : undefined; + var bundle = node.kind === 278 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -78379,7 +79120,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 287 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -78548,7 +79289,7 @@ var ts; writePunctuation("["); writePunctuation("]"); } - function emitJSDocVariadicType(node) { + function emitRestOrJSDocVariadicType(node) { write("..."); emit(node.type); } @@ -78557,6 +79298,10 @@ var ts; emitList(node, node.elementTypes, 272 /* TupleTypeElements */); writePunctuation("]"); } + function emitOptionalType(node) { + emit(node.type); + write("?"); + } function emitUnionType(node) { emitList(node, node.types, 260 /* UnionTypeConstituents */); } @@ -78838,7 +79583,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 === 198 /* PrefixUnaryExpression */ + return operand.kind === 200 /* PrefixUnaryExpression */ && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } @@ -78958,7 +79703,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 217 /* IfStatement */) { + if (node.elseStatement.kind === 220 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -79029,7 +79774,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 233 /* VariableDeclarationList */) { + if (node.kind === 236 /* VariableDeclarationList */) { emit(node); } else { @@ -79131,7 +79876,7 @@ var ts; emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); } function emitVariableDeclarationList(node) { - writeKeyword(ts.isLet(node) ? "let" : ts.isConst(node) ? "const" : "var"); + writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, 272 /* VariableDeclarationList */); } @@ -79324,7 +80069,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 239 /* ModuleDeclaration */) { + while (body.kind === 242 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -80249,7 +80994,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 193 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -80314,81 +81059,81 @@ var ts; if (!node) return; switch (node.kind) { - case 213 /* Block */: + case 216 /* Block */: ts.forEach(node.statements, generateNames); break; - case 228 /* LabeledStatement */: - case 226 /* WithStatement */: - case 218 /* DoStatement */: - case 219 /* WhileStatement */: + case 231 /* LabeledStatement */: + case 229 /* WithStatement */: + case 221 /* DoStatement */: + case 222 /* WhileStatement */: generateNames(node.statement); break; - case 217 /* IfStatement */: + case 220 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 220 /* ForStatement */: - case 222 /* ForOfStatement */: - case 221 /* ForInStatement */: + case 223 /* ForStatement */: + case 225 /* ForOfStatement */: + case 224 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 227 /* SwitchStatement */: + case 230 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 241 /* CaseBlock */: + case 244 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 266 /* CaseClause */: - case 267 /* DefaultClause */: + case 269 /* CaseClause */: + case 270 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 230 /* TryStatement */: + case 233 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 269 /* CatchClause */: + case 272 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: generateNames(node.declarationList); break; - case 233 /* VariableDeclarationList */: + case 236 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 232 /* VariableDeclaration */: + case 235 /* VariableDeclaration */: case 149 /* Parameter */: - case 182 /* BindingElement */: - case 235 /* ClassDeclaration */: + case 184 /* BindingElement */: + case 238 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 234 /* FunctionDeclaration */: + case 237 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 180 /* ObjectBindingPattern */: - case 181 /* ArrayBindingPattern */: + case 182 /* ObjectBindingPattern */: + case 183 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 244 /* ImportDeclaration */: + case 247 /* ImportDeclaration */: generateNames(node.importClause); break; - case 245 /* ImportClause */: + case 248 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 246 /* NamespaceImport */: + case 249 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 247 /* NamedImports */: + case 250 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 248 /* ImportSpecifier */: + case 251 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -80397,8 +81142,8 @@ var ts; if (!node) return; switch (node.kind) { - case 270 /* PropertyAssignment */: - case 271 /* ShorthandPropertyAssignment */: + case 273 /* PropertyAssignment */: + case 274 /* ShorthandPropertyAssignment */: case 152 /* PropertyDeclaration */: case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -80584,17 +81329,17 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 239 /* ModuleDeclaration */: - case 238 /* EnumDeclaration */: + case 242 /* ModuleDeclaration */: + case 241 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 244 /* ImportDeclaration */: - case 250 /* ExportDeclaration */: + case 247 /* ImportDeclaration */: + case 253 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 234 /* FunctionDeclaration */: - case 235 /* ClassDeclaration */: - case 249 /* ExportAssignment */: + case 237 /* FunctionDeclaration */: + case 238 /* ClassDeclaration */: + case 252 /* ExportAssignment */: return generateNameForExportDefault(); - case 205 /* ClassExpression */: + case 207 /* ClassExpression */: return generateNameForClassExpression(); case 154 /* MethodDeclaration */: case 156 /* GetAccessor */: @@ -81255,17 +82000,20 @@ var ts; } return context; } - function formatLocation(file, start, host) { + /* @internal */ + function formatLocation(file, start, host, color) { + if (color === void 0) { color = formatColorAndReset; } var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } + ts.formatLocation = formatLocation; function formatDiagnosticsWithColorAndContext(diagnostics, host) { var output = ""; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { @@ -81284,11 +82032,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_4 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_5 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_4, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_5, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -82015,7 +82763,16 @@ var ts; } function getEmitHost(writeFileCallback) { return __assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})); + getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + // Use local caches + var path = toPath(f); + if (getSourceFileByPath(path)) + return true; + if (ts.contains(missingFilePaths, path)) + return false; + // Before falling back to the host + return host.fileExists(f); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); } }); } function getProjectReferences() { if (!resolvedProjectReferences) @@ -82275,10 +83032,10 @@ var ts; case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: - case 232 /* VariableDeclaration */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: + case 235 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -82286,41 +83043,41 @@ var ts; } } switch (node.kind) { - case 243 /* ImportEqualsDeclaration */: + case 246 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 249 /* ExportAssignment */: + case 252 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 268 /* HeritageClause */: + case 271 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 236 /* InterfaceDeclaration */: + case 239 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 239 /* ModuleDeclaration */: + case 242 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 237 /* TypeAliasDeclaration */: + case 240 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 238 /* EnumDeclaration */: + case 241 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 209 /* NonNullExpression */: + case 211 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 208 /* AsExpression */: + case 210 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 190 /* TypeAssertionExpression */: + case 192 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -82333,25 +83090,25 @@ 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 235 /* ClassDeclaration */: + case 238 /* ClassDeclaration */: case 154 /* MethodDeclaration */: case 153 /* MethodSignature */: case 155 /* Constructor */: case 156 /* GetAccessor */: case 157 /* SetAccessor */: - case 192 /* FunctionExpression */: - case 234 /* FunctionDeclaration */: - case 193 /* ArrowFunction */: + case 194 /* FunctionExpression */: + case 237 /* FunctionDeclaration */: + case 195 /* ArrowFunction */: // 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; } // falls through - case 214 /* VariableStatement */: + case 217 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 217 /* VariableStatement */); } break; case 152 /* PropertyDeclaration */: @@ -82373,11 +83130,11 @@ var ts; return; } break; - case 187 /* CallExpression */: - case 188 /* NewExpression */: - case 207 /* ExpressionWithTypeArguments */: - case 256 /* JsxSelfClosingElement */: - case 257 /* JsxOpeningElement */: + case 189 /* CallExpression */: + case 190 /* NewExpression */: + case 209 /* ExpressionWithTypeArguments */: + case 259 /* JsxSelfClosingElement */: + case 260 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -83043,14 +83800,14 @@ var ts; if (options.composite && rootNames.length < files.length) { var normalizedRootNames = rootNames.map(function (r) { return ts.normalizePath(r).toLowerCase(); }); var sourceFiles = files.filter(function (f) { return !f.isDeclarationFile; }).map(function (f) { return ts.normalizePath(f.path).toLowerCase(); }); - var _loop_11 = function (file) { + var _loop_10 = function (file) { if (normalizedRootNames.every(function (r) { return r !== file; })) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file)); } }; for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var file = sourceFiles_4[_i]; - _loop_11(file); + _loop_10(file); } } if (options.paths) { @@ -84704,11 +85461,12 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - // Note: fromSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + // Note: importingSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences) { if (preferences === void 0) { preferences = {}; } - var info = getInfo(compilerOptions, fromSourceFile, fromSourceFileName, host); - return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); + return ts.firstDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }) || ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; @@ -84721,7 +85479,7 @@ var ts; if (!files) { return ts.Debug.fail("Files list must be present to resolve symlinks in specifier resolution"); } - var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration), info.getCanonicalFileName, host); + var modulePaths = getAllModulePaths(files, ts.getSourceFileOfNode(moduleSymbol.valueDeclaration).fileName, info.getCanonicalFileName, host); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); @@ -84739,13 +85497,13 @@ var ts; function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -84815,11 +85573,12 @@ var ts; var result = ts.createMap(); if (symlinks) { var currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; var resolvedParts = ts.getPathComponents(ts.toPath(resolvedPath, currentDirectory, getCanonicalFileName)); var originalParts = ts.getPathComponents(ts.toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === 0 /* EqualTo */) { resolvedParts.pop(); originalParts.pop(); } @@ -84853,17 +85612,16 @@ var ts; return [target]; } /** - * Looks for a existing imports that use symlinks to this module. + * Looks for existing imports that use symlinks to this module. * Only if no symlink is available, the real path will be used. */ - function getAllModulePaths(files, _a, getCanonicalFileName, host) { - var fileName = _a.fileName; + function getAllModulePaths(files, importedFileName, getCanonicalFileName, host) { var symlinks = ts.mapDefined(files, function (sf) { return sf.resolvedModules && ts.firstDefinedIterator(sf.resolvedModules.values(), function (res) { - return res && res.resolvedFileName === fileName ? res.originalPath : undefined; + return res && res.resolvedFileName === importedFileName ? res.originalPath : undefined; }); }); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, ts.getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath) { var components = ts.getPathComponents(relativePath); @@ -84939,7 +85697,7 @@ var ts; var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); @@ -85347,7 +86105,7 @@ var ts; } var trace = host.trace && (function (s) { host.trace(s + newLine); }); var watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? ts.WatchLogLevel.Verbose : - compilerOptions.diagnostis ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; + compilerOptions.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; // TODO: GH#18217 var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -85879,16 +86637,20 @@ var ts; function getOutputJavaScriptFileName(inputFileName, configFile) { var relativePath = ts.getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); var outputPath = ts.resolvePath(configFile.options.outDir || ts.getDirectoryPath(configFile.options.configFilePath), relativePath); - return ts.changeExtension(outputPath, (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */) ? ".jsx" /* Jsx */ : ".js" /* Js */); + var newExtension = ts.fileExtensionIs(inputFileName, ".json" /* Json */) ? ".json" /* Json */ : + ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; + return ts.changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName, configFile) { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) { return ts.emptyArray; } var outputs = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - var dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (configFile.options.declaration && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -86060,9 +86822,6 @@ var ts; function addProject(projectSpecification) { var fileName = ts.resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); var refPath = ts.resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(ts.Diagnostics.File_0_does_not_exist, projectSpecification); - } if (!compilerHost.fileExists(refPath)) { return buildHost.error(ts.Diagnostics.File_0_does_not_exist, fileName); } @@ -86112,7 +86871,7 @@ var ts; // Everything is broken - we don't even know what to watch. Give up. return; } - var _loop_12 = function (resolved) { + var _loop_11 = function (resolved) { var cfg = configFileCache.parseConfigFile(resolved); if (cfg) { // Watch this file @@ -86139,7 +86898,7 @@ var ts; }; for (var _i = 0, _a = graph.buildQueue; _i < _a.length; _i++) { var resolved = _a[_i]; - _loop_12(resolved); + _loop_11(resolved); } function invalidateProjectAndScheduleBuilds(resolved) { invalidateProject(resolved); @@ -86344,14 +87103,18 @@ var ts; return resultFlags; } var newestDeclarationFileContentChangedTime = minimumDate; + var anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, function (fileName, content, writeBom, onError) { var priorChangeTime; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, ts.emptyArray); if (priorChangeTime !== undefined) { @@ -86359,7 +87122,11 @@ var ts; context.unchangedOutputs.setValue(fileName, priorChangeTime); } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime }); + var status = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } function updateOutputTimestamps(proj) { @@ -86655,12 +87422,12 @@ var ts; } // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -86729,7 +87496,7 @@ var ts; return formatMessage(ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(configFileName), relName(status.missingOutputFileName)); case UpToDateStatusType.UpToDate: if (status.newestInputFileTime !== undefined) { - return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName), relName(status.oldestOutputFileName)); + return formatMessage(ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), relName(status.newestInputFileName || ""), relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; diff --git a/lib/zh-cn/diagnosticMessages.generated.json b/lib/zh-cn/diagnosticMessages.generated.json index 2d2168ab78199..aaf6a7101a8a3 100644 --- a/lib/zh-cn/diagnosticMessages.generated.json +++ b/lib/zh-cn/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "命名空间声明不能位于与之合并的类或函数前", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "只允许在命名空间或模块中使用命名空间声明。", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "命名空间样式导入不能调用或构造,并将在运行时导致失败。", - "A_non_dry_build_would_build_project_0_6357": "非干燥生成将生成项目“{0}”", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非干燥生成将删除以下文件: {0}", + "A_non_dry_build_would_build_project_0_6357": "非 -dry 生成将生成项目“{0}”", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 -dry 生成将删除以下文件: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "只允许在函数或构造函数实现中使用参数初始化表达式。", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "不能使用 rest 参数声明参数属性。", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "只允许在构造函数实现中使用参数属性。", diff --git a/lib/zh-tw/diagnosticMessages.generated.json b/lib/zh-tw/diagnosticMessages.generated.json index c1e5fd594a653..0ffe456d72853 100644 --- a/lib/zh-tw/diagnosticMessages.generated.json +++ b/lib/zh-tw/diagnosticMessages.generated.json @@ -49,8 +49,8 @@ "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434": "命名空間宣告的位置不得先於其要合併的類別或函式。", "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235": "只有命名空間或模組才允許命名空間宣告。", "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038": "命名空間樣式的匯入無法加以呼叫或建構,而且會導致執行階段失敗。", - "A_non_dry_build_would_build_project_0_6357": "非 DRY 的組建會建置專案 '{0}'", - "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 DRY 的組建會刪除下列檔案: {0}", + "A_non_dry_build_would_build_project_0_6357": "非 -dry 組建會建置專案 '{0}'", + "A_non_dry_build_would_delete_the_following_files_Colon_0_6356": "非 -dry 組建會刪除下列檔案: {0}", "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371": "只有函式或建構函式實作才可使用參數初始設定式。", "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317": "無法使用剩餘參數宣告參數屬性。", "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369": "建構函式實作中只可有一個參數屬性。", diff --git a/package-lock.json b/package-lock.json index 638adaf2e0f2d..c180bb97ed159 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,22 +5,22 @@ "requires": true, "dependencies": { "@gulp-sourcemaps/identity-map": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-1.0.1.tgz", - "integrity": "sha1-z6I7xYQPkQTOMqZedNt+epdLvuE=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-1.0.2.tgz", + "integrity": "sha512-ciiioYMLdo16ShmfHBXJBOFm3xPC4AuwO4xeRpFeHz7WK9PYsWCmigagG2XyzZpubK4a3qNKoUBDhbzHfa50LQ==", "dev": true, "requires": { - "acorn": "5.7.1", - "css": "2.2.3", - "normalize-path": "2.1.1", - "source-map": "0.5.7", - "through2": "2.0.3" + "acorn": "^5.0.3", + "css": "^2.2.1", + "normalize-path": "^2.1.1", + "source-map": "^0.6.0", + "through2": "^2.0.3" }, "dependencies": { - "acorn": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", - "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true } } @@ -31,24 +31,24 @@ "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", "dev": true, "requires": { - "normalize-path": "2.1.1", - "through2": "2.0.3" + "normalize-path": "^2.0.1", + "through2": "^2.0.3" } }, "@octokit/rest": { - "version": "15.9.2", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-15.9.2.tgz", - "integrity": "sha512-UpV9ZTI9ok73E0iFK+LH//c2/WIm6w/FGQ9LFF5GZFANsXut7z75LE0TCcgMZYdCS4eFm525qa3s+0INkPXigA==", - "dev": true, - "requires": { - "before-after-hook": "1.1.0", - "btoa-lite": "1.0.0", - "debug": "3.1.0", - "http-proxy-agent": "2.1.0", - "https-proxy-agent": "2.2.1", - "lodash": "4.17.10", - "node-fetch": "2.1.2", - "url-template": "2.0.8" + "version": "15.9.4", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-15.9.4.tgz", + "integrity": "sha512-v3CS1qW4IjriMvGgm4lDnYFBJlkwvzIbTxiipOcwVP8xeK8ih2pJofRhk7enmLngTtNEa+sIApJNkXxyyDKqLg==", + "dev": true, + "requires": { + "before-after-hook": "^1.1.0", + "btoa-lite": "^1.0.0", + "debug": "^3.1.0", + "http-proxy-agent": "^2.1.0", + "https-proxy-agent": "^2.2.0", + "lodash": "^4.17.4", + "node-fetch": "^2.1.1", + "url-template": "^2.0.8" }, "dependencies": { "debug": { @@ -74,8 +74,8 @@ "integrity": "sha512-mY6dYfq1Ns3Xqz/JFUcyoWaXtm0XDoNhkU1vCwM/ULM5zqNL+SbtacJhce/JCgPeCdbqdVqq77tJ4HwdtypSxg==", "dev": true, "requires": { - "@types/insert-module-globals": "7.0.0", - "@types/node": "8.5.5" + "@types/insert-module-globals": "*", + "@types/node": "*" } }, "@types/chai": { @@ -96,7 +96,7 @@ "integrity": "sha512-y6qRq6raBuu965clKgx6FHuiPu3oHdtmzMPXi8Uahsjdq1L6DL5fS/aY5/s71YwM7k6K1QIWvem5vNwlnNGIkQ==", "dev": true, "requires": { - "@types/glob": "5.0.35" + "@types/glob": "*" } }, "@types/events": { @@ -111,9 +111,9 @@ "integrity": "sha512-wc+VveszMLyMWFvXLkloixT4n0harUIVZjnpzztaZ0nKLuul7Z32iMt2fUFGAaZ4y1XWjFRMtCI5ewvyh4aIeg==", "dev": true, "requires": { - "@types/events": "1.2.0", - "@types/minimatch": "3.0.3", - "@types/node": "8.5.5" + "@types/events": "*", + "@types/minimatch": "*", + "@types/node": "*" } }, "@types/gulp": { @@ -122,9 +122,9 @@ "integrity": "sha512-u6/zWPzYRNPAtvyFJ3/RSXjmBaBM1dVs5kW22/jU6J786ZGLfSndhLoNOpFI6FGQvqTA+QzFHjSMhpkAN+wxcQ==", "dev": true, "requires": { - "@types/node": "8.5.5", - "@types/orchestrator": "0.3.2", - "@types/vinyl": "2.0.2" + "@types/node": "*", + "@types/orchestrator": "*", + "@types/vinyl": "*" } }, "@types/gulp-concat": { @@ -133,7 +133,7 @@ "integrity": "sha512-CUCFADlITzzBfBa2bdGzhKtvBr4eFh+evb+4igVbvPoO5RyPfHifmyQlZl6lM7q19+OKncRlFXDU7B4X9Ayo2g==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/gulp-help": { @@ -142,9 +142,9 @@ "integrity": "sha512-MkW7psZznxxJg2MBk2P2qHE+T8jEZVFz3FG/qGjUYazkyJt7hBJWx5Nuewmay5RVNtUvSWPrdZLr/WTXY3T/6A==", "dev": true, "requires": { - "@types/gulp": "3.8.36", - "@types/node": "8.5.5", - "@types/orchestrator": "0.3.2" + "@types/gulp": "*", + "@types/node": "*", + "@types/orchestrator": "*" } }, "@types/gulp-if": { @@ -153,8 +153,8 @@ "integrity": "sha512-J5lzff21X7r1x/4hSzn02GgIUEyjCqYIXZ9GgGBLhbsD3RiBdqwnkFWgF16/0jO5rcVZ52Zp+6MQMQdvIsWuKg==", "dev": true, "requires": { - "@types/node": "8.5.5", - "@types/vinyl": "2.0.2" + "@types/node": "*", + "@types/vinyl": "*" } }, "@types/gulp-newer": { @@ -163,7 +163,7 @@ "integrity": "sha512-e7J/Zv5Wd7CC0WpuA2syWVitgwrkG0u221e41w7r07XUR6hMH6kHPkq9tUrusHkbeW8QbuLbis5fODOwQCyggQ==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/gulp-rename": { @@ -172,7 +172,7 @@ "integrity": "sha512-FIZQvbZJj6V1gHPTzO+g/BCWpDur7fJrroae4gwV3LaoHBQ+MrR9sB+2HssK8fHv4WdY6hVNxkcft9bYatuPIA==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/gulp-sourcemaps": { @@ -181,7 +181,7 @@ "integrity": "sha512-+7BAmptW2bxyJnJcCEuie7vLoop3FwWgCdBMzyv7MYXED/HeNMeQuX7uPCkp4vfU1TTu4CYFH0IckNPvo0VePA==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/insert-module-globals": { @@ -190,7 +190,7 @@ "integrity": "sha512-zudCJPwluh1VUDB6Gl/OQdRp+fYy3+47huJB/JMQubMS2p+sH18MCVK4WUz3FqaWLB12yh5ELxVR/+tqwlm/qA==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/jake": { @@ -199,7 +199,7 @@ "integrity": "sha512-F5txkK3aW+fAi4YExGq4Q0W+jJXIhjUvqwMNFPh8kmM+ZU90S/KdDcEV4H+Ug9fHFPAVHG+veaHE8ZHmJJxHCw==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/merge2": { @@ -208,7 +208,7 @@ "integrity": "sha512-GjaXY4OultxbaOOk7lCLO7xvEcFpdjExC605YmfI6X29vhHKpJfMWKCDZd3x+BITrZaXKg97DgV/SdGVSwdzxA==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/minimatch": { @@ -229,13 +229,13 @@ "integrity": "sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/mocha": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.3.tgz", - "integrity": "sha512-C1wVVr7xhKu6c3Mb27dFzNYR05qvHwgtpN+JOYTGc1pKA7dCEDDYpscn7kul+bCUwa3NoGDbzI1pdznSOa397w==", + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.4.tgz", + "integrity": "sha512-XMHApnKWI0jvXU5gLcSTsRjJBpSzP0BG+2oGv98JFyS4a5R0tRy0oshHBRndb3BuHb9AwDKaUL8Ja7GfUvsG4g==", "dev": true }, "@types/node": { @@ -250,8 +250,8 @@ "integrity": "sha512-cKB4yTX0wGaRCSkdHDX2fkGQbMAA8UOshC2U7DQky1CE5o+5q2iQQ8VkbPbE/88uaTtsusvBPMcCX7dgmjxBhQ==", "dev": true, "requires": { - "@types/node": "8.5.5", - "@types/q": "1.5.0" + "@types/node": "*", + "@types/q": "*" } }, "@types/q": { @@ -266,8 +266,8 @@ "integrity": "sha512-XwGr1b4yCGUILKeBkzmeWcxmGHQ0vFFFpA6D6y1yLO6gKmYorF+PHqdU5KG+nWt38OvtrkDptmrSmlHX/XtpLw==", "dev": true, "requires": { - "@types/gulp": "3.8.36", - "@types/node": "8.5.5" + "@types/gulp": "*", + "@types/node": "*" } }, "@types/source-map-support": { @@ -276,7 +276,7 @@ "integrity": "sha512-eoyZxYGwaeHq5zCVeoNgY1dQy6dVdm1b7K9k1FRnWkf997Tji3NLBoLAjK5WCobeh1Qs6Q5KUV1rZCmHvzaDBw==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/through2": { @@ -285,7 +285,7 @@ "integrity": "sha1-H/LoihAN+1sUDnu5h5HxGUQA0TE=", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/travis-fold": { @@ -300,7 +300,7 @@ "integrity": "sha512-2iYpNuOl98SrLPBZfEN9Mh2JCJ2EI9HU35SfgBEb51DcmaHkhp8cKMblYeBqMQiwXMgAD3W60DbQ4i/UdLiXhw==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" } }, "@types/xml2js": { @@ -309,7 +309,17 @@ "integrity": "sha512-8aKUBSj3oGcnuiBmDLm3BIk09RYg01mz9HlQ2u4aS17oJ25DxjQrEUVGFSBVNOfM45pQW4OjcBPplq6r/exJdA==", "dev": true, "requires": { - "@types/node": "8.5.5" + "@types/node": "*" + } + }, + "JSONStream": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.3.tgz", + "integrity": "sha512-3Sp6WZZ/lXl+nTDoGpGWHEpTnnC6X5fnkolYZR6nwIfzbxxvA8utPWe1gCt7i0m9uVGsSz2IS8K8mJ7HmlduMg==", + "dev": true, + "requires": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" } }, "abbrev": { @@ -319,36 +329,38 @@ "dev": true }, "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", + "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", "dev": true }, + "acorn-dynamic-import": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", + "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==", + "dev": true, + "requires": { + "acorn": "^5.0.0" + } + }, "acorn-node": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.3.0.tgz", - "integrity": "sha512-efP54n3d1aLfjL2UMdaXa6DsswwzJeI5rqhbFvXMrKiJ6eJFpf+7R0zN7t8IC+XKn2YOAFAv6xbBNgHUkoHWLw==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.5.2.tgz", + "integrity": "sha512-krFKvw/d1F17AN3XZbybIUzEY4YEPNiGo05AfP3dBlfVKrMHETKpgjpuZkSF8qDNt9UkQcqj7am8yJLseklCMg==", "dev": true, "requires": { - "acorn": "5.6.2", - "xtend": "4.0.1" - }, - "dependencies": { - "acorn": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.6.2.tgz", - "integrity": "sha512-zUzo1E5dI2Ey8+82egfnttyMlMZ2y0D8xOCO3PNPPlYXpl8NZvF6Qk9L9BEtJs+43FqEmfBViDqc5d1ckRDguw==", - "dev": true - } + "acorn": "^5.7.1", + "acorn-dynamic-import": "^3.0.0", + "xtend": "^4.0.1" } }, "agent-base": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.0.tgz", - "integrity": "sha512-c+R/U5X+2zz2+UCrCFv6odQzJdoqI+YecuhnAJLa1zYaMc13zPfwMwZrr91Pd1DYNo/yPRbiM4WVf9whgwFsIg==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", + "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", "dev": true, "requires": { - "es6-promisify": "5.0.0" + "es6-promisify": "^5.0.0" } }, "align-text": { @@ -357,9 +369,9 @@ "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, "requires": { - "kind-of": "3.2.2", - "longest": "1.0.1", - "repeat-string": "1.6.1" + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" }, "dependencies": { "kind-of": { @@ -368,7 +380,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -380,9 +392,9 @@ "dev": true }, "ansi-colors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-2.0.1.tgz", - "integrity": "sha512-qUIXfMVe0LoHCFPD6dGtjDDuVoP7B2DWBXIfd5aN/hGNIZDndQmqCwNjCChzxi8TPPGmBV4TB3XPc0VfgR7iIQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-2.0.2.tgz", + "integrity": "sha512-lqxzclDUlcMM72ab/b4imVvMCyO+jELG+a5DPuE2qFAwGkzQilb6iEgzQPhSmNCM7onBHsq/9Mggh4HaqilTlA==", "dev": true }, "ansi-cyan": { @@ -424,7 +436,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.1" + "color-convert": "^1.9.0" } }, "ansi-wrap": { @@ -439,7 +451,7 @@ "integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=", "dev": true, "requires": { - "buffer-equal": "1.0.0" + "buffer-equal": "^1.0.0" } }, "archy": { @@ -454,7 +466,7 @@ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "sprintf-js": "1.0.3" + "sprintf-js": "~1.0.2" } }, "arr-diff": { @@ -517,7 +529,7 @@ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { - "array-uniq": "1.0.3" + "array-uniq": "^1.0.1" } }, "array-uniq": { @@ -538,9 +550,9 @@ "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, "requires": { - "bn.js": "4.11.8", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" } }, "assert": { @@ -581,15 +593,6 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, - "astw": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", - "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", - "dev": true, - "requires": { - "acorn": "4.0.13" - } - }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", @@ -608,9 +611,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" }, "dependencies": { "ansi-styles": { @@ -625,11 +628,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "supports-color": { @@ -652,13 +655,13 @@ "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, "requires": { - "cache-base": "1.0.1", - "class-utils": "0.3.6", - "component-emitter": "1.2.1", - "define-property": "1.0.0", - "isobject": "3.0.1", - "mixin-deep": "1.3.1", - "pascalcase": "0.1.1" + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" }, "dependencies": { "define-property": { @@ -667,7 +670,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "is-accessor-descriptor": { @@ -676,7 +679,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -685,7 +688,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -694,9 +697,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } } } @@ -731,7 +734,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -741,16 +744,16 @@ "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" }, "dependencies": { "extend-shallow": { @@ -759,7 +762,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -776,12 +779,12 @@ "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { - "combine-source-map": "0.8.0", - "defined": "1.0.0", - "JSONStream": "1.3.3", - "safe-buffer": "5.1.2", - "through2": "2.0.3", - "umd": "3.0.3" + "JSONStream": "^1.0.3", + "combine-source-map": "~0.8.0", + "defined": "^1.0.0", + "safe-buffer": "^5.1.1", + "through2": "^2.0.0", + "umd": "^3.0.0" } }, "browser-resolve": { @@ -805,54 +808,54 @@ "integrity": "sha512-fMES05wq1Oukts6ksGUU2TMVHHp06LyQt0SIwbXIHm7waSrQmNBZePsU0iM/4f94zbvb/wHma+D1YrdzWYnF/A==", "dev": true, "requires": { - "assert": "1.4.1", - "browser-pack": "6.1.0", - "browser-resolve": "1.11.2", - "browserify-zlib": "0.2.0", - "buffer": "5.1.0", - "cached-path-relative": "1.0.1", - "concat-stream": "1.6.2", - "console-browserify": "1.1.0", - "constants-browserify": "1.0.0", - "crypto-browserify": "3.12.0", - "defined": "1.0.0", - "deps-sort": "2.0.0", - "domain-browser": "1.2.0", - "duplexer2": "0.1.4", - "events": "2.1.0", - "glob": "7.1.2", - "has": "1.0.3", - "htmlescape": "1.1.1", - "https-browserify": "1.0.0", - "inherits": "2.0.3", - "insert-module-globals": "7.1.0", - "JSONStream": "1.3.3", - "labeled-stream-splicer": "2.0.1", - "mkdirp": "0.5.1", - "module-deps": "6.1.0", - "os-browserify": "0.3.0", - "parents": "1.0.1", - "path-browserify": "0.0.0", - "process": "0.11.10", - "punycode": "1.4.1", - "querystring-es3": "0.2.1", - "read-only-stream": "2.0.0", - "readable-stream": "2.3.6", - "resolve": "1.1.7", - "shasum": "1.0.2", - "shell-quote": "1.6.1", - "stream-browserify": "2.0.1", - "stream-http": "2.8.3", - "string_decoder": "1.1.1", - "subarg": "1.0.0", - "syntax-error": "1.4.0", - "through2": "2.0.3", - "timers-browserify": "1.4.2", + "JSONStream": "^1.0.3", + "assert": "^1.4.0", + "browser-pack": "^6.0.1", + "browser-resolve": "^1.11.0", + "browserify-zlib": "~0.2.0", + "buffer": "^5.0.2", + "cached-path-relative": "^1.0.0", + "concat-stream": "^1.6.0", + "console-browserify": "^1.1.0", + "constants-browserify": "~1.0.0", + "crypto-browserify": "^3.0.0", + "defined": "^1.0.0", + "deps-sort": "^2.0.0", + "domain-browser": "^1.2.0", + "duplexer2": "~0.1.2", + "events": "^2.0.0", + "glob": "^7.1.0", + "has": "^1.0.0", + "htmlescape": "^1.1.0", + "https-browserify": "^1.0.0", + "inherits": "~2.0.1", + "insert-module-globals": "^7.0.0", + "labeled-stream-splicer": "^2.0.0", + "mkdirp": "^0.5.0", + "module-deps": "^6.0.0", + "os-browserify": "~0.3.0", + "parents": "^1.0.1", + "path-browserify": "~0.0.0", + "process": "~0.11.0", + "punycode": "^1.3.2", + "querystring-es3": "~0.2.0", + "read-only-stream": "^2.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.4", + "shasum": "^1.0.0", + "shell-quote": "^1.6.1", + "stream-browserify": "^2.0.0", + "stream-http": "^2.0.0", + "string_decoder": "^1.1.1", + "subarg": "^1.0.0", + "syntax-error": "^1.1.1", + "through2": "^2.0.0", + "timers-browserify": "^1.0.1", "tty-browserify": "0.0.1", - "url": "0.11.0", - "util": "0.10.4", - "vm-browserify": "1.0.1", - "xtend": "4.0.1" + "url": "~0.11.0", + "util": "~0.10.1", + "vm-browserify": "^1.0.0", + "xtend": "^4.0.0" } }, "browserify-aes": { @@ -861,12 +864,12 @@ "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { - "buffer-xor": "1.0.3", - "cipher-base": "1.0.4", - "create-hash": "1.2.0", - "evp_bytestokey": "1.0.3", - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "browserify-cipher": { @@ -875,9 +878,9 @@ "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { - "browserify-aes": "1.2.0", - "browserify-des": "1.0.1", - "evp_bytestokey": "1.0.3" + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" } }, "browserify-des": { @@ -886,9 +889,9 @@ "integrity": "sha512-zy0Cobe3hhgpiOM32Tj7KQ3Vl91m0njwsjzZQK1L+JDf11dzP9qIvjreVinsvXrgfjhStXwUWAEpB9D7Gwmayw==", "dev": true, "requires": { - "cipher-base": "1.0.4", - "des.js": "1.0.0", - "inherits": "2.0.3" + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1" } }, "browserify-rsa": { @@ -897,8 +900,8 @@ "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { - "bn.js": "4.11.8", - "randombytes": "2.0.6" + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" } }, "browserify-sign": { @@ -907,13 +910,13 @@ "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", "dev": true, "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "elliptic": "6.4.0", - "inherits": "2.0.3", - "parse-asn1": "5.1.1" + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" } }, "browserify-zlib": { @@ -922,7 +925,7 @@ "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { - "pako": "1.0.6" + "pako": "~1.0.5" } }, "btoa-lite": { @@ -937,8 +940,8 @@ "integrity": "sha512-YkIRgwsZwJWTnyQrsBTWefizHh+8GYj3kbL1BTiAQ/9pwpino0G7B2gp5tx/FUBqUlvtxV85KNR3mwfAtv15Yw==", "dev": true, "requires": { - "base64-js": "1.3.0", - "ieee754": "1.1.12" + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" } }, "buffer-equal": { @@ -977,15 +980,15 @@ "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, "requires": { - "collection-visit": "1.0.0", - "component-emitter": "1.2.1", - "get-value": "2.0.6", - "has-value": "1.0.0", - "isobject": "3.0.1", - "set-value": "2.0.0", - "to-object-path": "0.3.0", - "union-value": "1.0.0", - "unset-value": "1.0.0" + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" } }, "cached-path-relative": { @@ -1008,8 +1011,8 @@ "dev": true, "optional": true, "requires": { - "align-text": "0.1.4", - "lazy-cache": "1.0.4" + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" } }, "chai": { @@ -1018,12 +1021,12 @@ "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", "dev": true, "requires": { - "assertion-error": "1.1.0", - "check-error": "1.0.2", - "deep-eql": "3.0.1", - "get-func-name": "2.0.0", - "pathval": "1.1.0", - "type-detect": "4.0.8" + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^3.0.0", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" } }, "chalk": { @@ -1032,9 +1035,9 @@ "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.4.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "check-error": { @@ -1049,8 +1052,8 @@ "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "class-utils": { @@ -1059,10 +1062,10 @@ "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, "requires": { - "arr-union": "3.1.0", - "define-property": "0.2.5", - "isobject": "3.0.1", - "static-extend": "0.1.2" + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" }, "dependencies": { "define-property": { @@ -1071,7 +1074,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } } } @@ -1083,8 +1086,8 @@ "dev": true, "optional": true, "requires": { - "center-align": "0.1.3", - "right-align": "0.1.3", + "center-align": "^0.1.1", + "right-align": "^0.1.1", "wordwrap": "0.0.2" }, "dependencies": { @@ -1121,9 +1124,9 @@ "integrity": "sha512-Bq6+4t+lbM8vhTs/Bef5c5AdEMtapp/iFb6+s4/Hh9MVTt8OLKH7ZOOZSCT+Ys7hsHvqv0GuMPJ1lnQJVHvxpg==", "dev": true, "requires": { - "inherits": "2.0.3", - "process-nextick-args": "2.0.0", - "readable-stream": "2.3.6" + "inherits": "^2.0.1", + "process-nextick-args": "^2.0.0", + "readable-stream": "^2.3.5" } }, "code-point-at": { @@ -1138,23 +1141,23 @@ "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, "requires": { - "map-visit": "1.0.0", - "object-visit": "1.0.1" + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" } }, "color-convert": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", + "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", "dev": true, "requires": { - "color-name": "1.1.3" + "color-name": "1.1.1" } }, "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=", "dev": true }, "color-support": { @@ -1169,10 +1172,10 @@ "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, "requires": { - "convert-source-map": "1.1.3", - "inline-source-map": "0.6.2", - "lodash.memoize": "3.0.4", - "source-map": "0.5.7" + "convert-source-map": "~1.1.0", + "inline-source-map": "~0.6.0", + "lodash.memoize": "~3.0.3", + "source-map": "~0.5.3" }, "dependencies": { "convert-source-map": { @@ -1207,19 +1210,19 @@ "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, "requires": { - "buffer-from": "1.1.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "typedarray": "0.0.6" + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" } }, "concat-with-sourcemaps": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/concat-with-sourcemaps/-/concat-with-sourcemaps-1.0.7.tgz", - "integrity": "sha512-5i4Spc9NNvVXzkR77x2kjcYCDZMNPLzP7ZBzJMNKZjXzk+E6tRVL/lPlYw60VM3hb7gf+iBQn2x1T8TpMN0SEw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz", + "integrity": "sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==", "dev": true, "requires": { - "source-map": "0.6.1" + "source-map": "^0.6.1" }, "dependencies": { "source-map": { @@ -1236,7 +1239,7 @@ "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "dev": true, "requires": { - "date-now": "0.1.4" + "date-now": "^0.1.4" } }, "constants-browserify": { @@ -1269,8 +1272,8 @@ "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, "requires": { - "bn.js": "4.11.8", - "elliptic": "6.4.0" + "bn.js": "^4.1.0", + "elliptic": "^6.0.0" } }, "create-hash": { @@ -1279,11 +1282,11 @@ "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { - "cipher-base": "1.0.4", - "inherits": "2.0.3", - "md5.js": "1.3.4", - "ripemd160": "2.0.2", - "sha.js": "2.4.11" + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" } }, "create-hmac": { @@ -1292,12 +1295,12 @@ "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { - "cipher-base": "1.0.4", - "create-hash": "1.2.0", - "inherits": "2.0.3", - "ripemd160": "2.0.2", - "safe-buffer": "5.1.2", - "sha.js": "2.4.11" + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" } }, "cross-spawn": { @@ -1306,9 +1309,9 @@ "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "dev": true, "requires": { - "lru-cache": "4.1.3", - "shebang-command": "1.2.0", - "which": "1.3.0" + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" }, "dependencies": { "lru-cache": { @@ -1317,8 +1320,8 @@ "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", "dev": true, "requires": { - "pseudomap": "1.0.2", - "yallist": "2.1.2" + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" } } } @@ -1329,17 +1332,17 @@ "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { - "browserify-cipher": "1.0.1", - "browserify-sign": "4.0.4", - "create-ecdh": "4.0.3", - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "diffie-hellman": "5.0.3", - "inherits": "2.0.3", - "pbkdf2": "3.0.16", - "public-encrypt": "4.0.2", - "randombytes": "2.0.6", - "randomfill": "1.0.4" + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" } }, "css": { @@ -1348,10 +1351,10 @@ "integrity": "sha512-0W171WccAjQGGTKLhw4m2nnl0zPHUlTO/I8td4XzJgIB8Hg3ZZx71qT4G4eX8OVsSiaAKiUMy73E3nsbPlg2DQ==", "dev": true, "requires": { - "inherits": "2.0.3", - "source-map": "0.1.43", - "source-map-resolve": "0.5.1", - "urix": "0.1.0" + "inherits": "^2.0.1", + "source-map": "^0.1.38", + "source-map-resolve": "^0.5.1", + "urix": "^0.1.0" }, "dependencies": { "source-map": { @@ -1360,7 +1363,7 @@ "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", "dev": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } } } @@ -1371,7 +1374,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.45" + "es5-ext": "^0.10.9" } }, "date-now": { @@ -1401,9 +1404,9 @@ "integrity": "sha512-GZqvGIgKNlUnHUPQhepnUZFIMoi3dgZKQBzKDeL2g7oJF9SNAji/AAu36dusFUas0O+pae74lNeoIPHqXWDkLg==", "dev": true, "requires": { - "debug": "3.1.0", - "memoizee": "0.4.12", - "object-assign": "4.1.1" + "debug": "3.X", + "memoizee": "0.4.X", + "object-assign": "4.X" }, "dependencies": { "debug": { @@ -1435,7 +1438,7 @@ "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", "dev": true, "requires": { - "type-detect": "4.0.8" + "type-detect": "^4.0.0" } }, "deep-is": { @@ -1450,7 +1453,7 @@ "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", "dev": true, "requires": { - "clone": "1.0.4" + "clone": "^1.0.2" } }, "define-properties": { @@ -1459,8 +1462,8 @@ "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", "dev": true, "requires": { - "foreach": "2.0.5", - "object-keys": "1.0.12" + "foreach": "^2.0.5", + "object-keys": "^1.0.8" } }, "define-property": { @@ -1469,8 +1472,8 @@ "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, "requires": { - "is-descriptor": "1.0.2", - "isobject": "3.0.1" + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" }, "dependencies": { "is-accessor-descriptor": { @@ -1479,7 +1482,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -1488,7 +1491,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -1497,9 +1500,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } } } @@ -1516,12 +1519,12 @@ "integrity": "sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=", "dev": true, "requires": { - "globby": "6.1.0", - "is-path-cwd": "1.0.0", - "is-path-in-cwd": "1.0.1", - "p-map": "1.2.0", - "pify": "3.0.0", - "rimraf": "2.6.2" + "globby": "^6.1.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "p-map": "^1.1.1", + "pify": "^3.0.0", + "rimraf": "^2.2.8" } }, "deprecated": { @@ -1536,10 +1539,10 @@ "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", "dev": true, "requires": { - "JSONStream": "1.3.3", - "shasum": "1.0.2", - "subarg": "1.0.0", - "through2": "2.0.3" + "JSONStream": "^1.0.3", + "shasum": "^1.0.0", + "subarg": "^1.0.0", + "through2": "^2.0.0" } }, "des.js": { @@ -1548,8 +1551,8 @@ "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", "dev": true, "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" } }, "detect-file": { @@ -1570,9 +1573,9 @@ "integrity": "sha512-TFHMqfOvxlgrfVzTEkNBSh9SvSNX/HfF4OFI2QFGCyPm02EsyILqnUeb5P6q7JZ3SFNTBL5t2sePRgrN4epUWQ==", "dev": true, "requires": { - "acorn-node": "1.3.0", - "defined": "1.0.0", - "minimist": "1.2.0" + "acorn-node": "^1.3.0", + "defined": "^1.0.0", + "minimist": "^1.1.1" } }, "diff": { @@ -1587,9 +1590,9 @@ "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { - "bn.js": "4.11.8", - "miller-rabin": "4.0.1", - "randombytes": "2.0.6" + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" } }, "domain-browser": { @@ -1604,7 +1607,7 @@ "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.2" } }, "duplexify": { @@ -1613,10 +1616,10 @@ "integrity": "sha512-fO3Di4tBKJpYTFHAxTU00BcfWMY9w24r/x21a6rZRbsD/ToUgGxsMbiGRmB7uVAXeGKXD9MwiLZa5E97EVgIRQ==", "dev": true, "requires": { - "end-of-stream": "1.4.1", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "stream-shift": "1.0.0" + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" }, "dependencies": { "end-of-stream": { @@ -1625,7 +1628,7 @@ "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "dev": true, "requires": { - "once": "1.4.0" + "once": "^1.4.0" } } } @@ -1636,13 +1639,13 @@ "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", "dev": true, "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0", - "hash.js": "1.1.3", - "hmac-drbg": "1.0.1", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1", - "minimalistic-crypto-utils": "1.0.1" + "bn.js": "^4.4.0", + "brorand": "^1.0.1", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.0" } }, "end-of-stream": { @@ -1651,7 +1654,7 @@ "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", "dev": true, "requires": { - "once": "1.3.3" + "once": "~1.3.0" }, "dependencies": { "once": { @@ -1660,7 +1663,7 @@ "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } } } @@ -1671,9 +1674,9 @@ "integrity": "sha512-FkfM6Vxxfmztilbxxz5UKSD4ICMf5tSpRFtDNtkAhOxZ0EKtX6qwmXNyH/sFyIbX2P/nU5AMiA9jilWsUGJzCQ==", "dev": true, "requires": { - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1", - "next-tick": "1.0.0" + "es6-iterator": "~2.0.3", + "es6-symbol": "~3.1.1", + "next-tick": "1" } }, "es6-iterator": { @@ -1682,26 +1685,24 @@ "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45", - "es6-symbol": "3.1.1" + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" } }, + "es6-promise": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", + "dev": true + }, "es6-promisify": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", "dev": true, "requires": { - "es6-promise": "4.2.4" - }, - "dependencies": { - "es6-promise": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", - "dev": true - } + "es6-promise": "^4.0.3" } }, "es6-symbol": { @@ -1710,8 +1711,8 @@ "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45" + "d": "1", + "es5-ext": "~0.10.14" } }, "es6-weak-map": { @@ -1720,10 +1721,10 @@ "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45", - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1" + "d": "1", + "es5-ext": "^0.10.14", + "es6-iterator": "^2.0.1", + "es6-symbol": "^3.1.1" } }, "escape-string-regexp": { @@ -1738,11 +1739,11 @@ "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", "dev": true, "requires": { - "esprima": "2.7.3", - "estraverse": "1.9.3", - "esutils": "2.0.2", - "optionator": "0.8.2", - "source-map": "0.2.0" + "esprima": "^2.7.1", + "estraverse": "^1.9.1", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.2.0" }, "dependencies": { "source-map": { @@ -1752,7 +1753,7 @@ "dev": true, "optional": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } } } @@ -1781,8 +1782,8 @@ "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45" + "d": "1", + "es5-ext": "~0.10.14" } }, "events": { @@ -1797,8 +1798,8 @@ "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { - "md5.js": "1.3.4", - "safe-buffer": "5.1.2" + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" } }, "execa": { @@ -1807,13 +1808,13 @@ "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", "dev": true, "requires": { - "cross-spawn": "5.1.0", - "get-stream": "3.0.0", - "is-stream": "1.1.0", - "npm-run-path": "2.0.2", - "p-finally": "1.0.0", - "signal-exit": "3.0.2", - "strip-eof": "1.0.0" + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" } }, "expand-brackets": { @@ -1822,13 +1823,13 @@ "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -1837,7 +1838,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -1846,7 +1847,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -1857,7 +1858,7 @@ "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", "dev": true, "requires": { - "homedir-polyfill": "1.0.1" + "homedir-polyfill": "^1.0.1" } }, "extend": { @@ -1872,8 +1873,8 @@ "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, "requires": { - "assign-symbols": "1.0.0", - "is-extendable": "1.0.1" + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" }, "dependencies": { "is-extendable": { @@ -1882,7 +1883,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "2.0.4" + "is-plain-object": "^2.0.4" } } } @@ -1893,14 +1894,14 @@ "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" }, "dependencies": { "define-property": { @@ -1909,7 +1910,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "extend-shallow": { @@ -1918,7 +1919,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "is-accessor-descriptor": { @@ -1927,7 +1928,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -1936,7 +1937,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -1945,9 +1946,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } } } @@ -1958,9 +1959,9 @@ "integrity": "sha1-9BEl49hPLn2JpD0G2VjI94vha+E=", "dev": true, "requires": { - "ansi-gray": "0.1.1", - "color-support": "1.1.3", - "time-stamp": "1.1.0" + "ansi-gray": "^0.1.1", + "color-support": "^1.1.3", + "time-stamp": "^1.0.0" } }, "fast-levenshtein": { @@ -1975,8 +1976,8 @@ "integrity": "sha1-WKZBrR9XV0on/oekQO8xiDS1Vxk=", "dev": true, "requires": { - "minimatch": "3.0.4", - "utilities": "0.0.37" + "minimatch": "^3.0.3", + "utilities": "^0.0.37" }, "dependencies": { "utilities": { @@ -1993,10 +1994,10 @@ "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" }, "dependencies": { "extend-shallow": { @@ -2005,7 +2006,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -2022,7 +2023,7 @@ "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", "dev": true, "requires": { - "locate-path": "2.0.0" + "locate-path": "^2.0.0" } }, "findup-sync": { @@ -2031,10 +2032,10 @@ "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", "dev": true, "requires": { - "detect-file": "1.0.0", - "is-glob": "3.1.0", - "micromatch": "3.1.10", - "resolve-dir": "1.0.1" + "detect-file": "^1.0.0", + "is-glob": "^3.1.0", + "micromatch": "^3.0.4", + "resolve-dir": "^1.0.1" } }, "fined": { @@ -2043,11 +2044,11 @@ "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "is-plain-object": "2.0.4", - "object.defaults": "1.1.0", - "object.pick": "1.3.0", - "parse-filepath": "1.0.2" + "expand-tilde": "^2.0.2", + "is-plain-object": "^2.0.3", + "object.defaults": "^1.1.0", + "object.pick": "^1.2.0", + "parse-filepath": "^1.0.1" } }, "first-chunk-stream": { @@ -2068,8 +2069,8 @@ "integrity": "sha512-calZMC10u0FMUqoiunI2AiGIIUtUIvifNwkHhNupZH4cbNnW1Itkoh/Nf5HFYmDrwWPjrUxpkZT0KhuCq0jmGw==", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.6" + "inherits": "^2.0.1", + "readable-stream": "^2.0.4" } }, "for-in": { @@ -2084,7 +2085,7 @@ "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } }, "foreach": { @@ -2105,7 +2106,7 @@ "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, "requires": { - "map-cache": "0.2.2" + "map-cache": "^0.2.2" } }, "fs-extra": { @@ -2114,9 +2115,9 @@ "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "jsonfile": "4.0.0", - "universalify": "0.1.1" + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" }, "dependencies": { "graceful-fs": { @@ -2133,8 +2134,8 @@ "integrity": "sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "through2": "2.0.3" + "graceful-fs": "^4.1.11", + "through2": "^2.0.3" }, "dependencies": { "graceful-fs": { @@ -2163,9 +2164,15 @@ "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", "dev": true, "requires": { - "globule": "0.1.0" + "globule": "~0.1.0" } }, + "get-assigned-identifiers": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", + "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", + "dev": true + }, "get-caller-file": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", @@ -2196,12 +2203,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "glob-parent": { @@ -2210,8 +2217,8 @@ "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, "requires": { - "is-glob": "3.1.0", - "path-dirname": "1.0.2" + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" } }, "glob-stream": { @@ -2220,12 +2227,12 @@ "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", "dev": true, "requires": { - "glob": "4.5.3", - "glob2base": "0.0.12", - "minimatch": "2.0.10", - "ordered-read-streams": "0.1.0", - "through2": "0.6.5", - "unique-stream": "1.0.0" + "glob": "^4.3.1", + "glob2base": "^0.0.12", + "minimatch": "^2.0.1", + "ordered-read-streams": "^0.1.0", + "through2": "^0.6.1", + "unique-stream": "^1.0.0" }, "dependencies": { "glob": { @@ -2234,10 +2241,10 @@ "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", "dev": true, "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "2.0.10", - "once": "1.4.0" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^2.0.1", + "once": "^1.3.0" } }, "isarray": { @@ -2252,7 +2259,7 @@ "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", "dev": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.0.0" } }, "readable-stream": { @@ -2261,10 +2268,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "string_decoder": { @@ -2279,8 +2286,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } } } @@ -2291,7 +2298,7 @@ "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", "dev": true, "requires": { - "gaze": "0.5.2" + "gaze": "^0.5.1" } }, "glob2base": { @@ -2300,7 +2307,7 @@ "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", "dev": true, "requires": { - "find-index": "0.1.1" + "find-index": "^0.1.1" } }, "global-modules": { @@ -2309,9 +2316,9 @@ "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, "requires": { - "global-prefix": "1.0.2", - "is-windows": "1.0.2", - "resolve-dir": "1.0.1" + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" } }, "global-prefix": { @@ -2320,11 +2327,11 @@ "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "homedir-polyfill": "1.0.1", - "ini": "1.3.5", - "is-windows": "1.0.2", - "which": "1.3.0" + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" } }, "globby": { @@ -2333,11 +2340,11 @@ "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { - "array-union": "1.0.2", - "glob": "7.1.2", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" }, "dependencies": { "pify": { @@ -2354,9 +2361,9 @@ "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", "dev": true, "requires": { - "glob": "3.1.21", - "lodash": "1.0.2", - "minimatch": "0.2.14" + "glob": "~3.1.21", + "lodash": "~1.0.1", + "minimatch": "~0.2.11" }, "dependencies": { "glob": { @@ -2365,9 +2372,9 @@ "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", "dev": true, "requires": { - "graceful-fs": "1.2.3", - "inherits": "1.0.2", - "minimatch": "0.2.14" + "graceful-fs": "~1.2.0", + "inherits": "1", + "minimatch": "~0.2.11" } }, "graceful-fs": { @@ -2388,8 +2395,8 @@ "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", "dev": true, "requires": { - "lru-cache": "2.7.3", - "sigmund": "1.0.1" + "lru-cache": "2", + "sigmund": "~1.0.0" } } } @@ -2400,7 +2407,7 @@ "integrity": "sha512-ynYqXLoluBKf9XGR1gA59yEJisIL7YHEH4xr3ZziHB5/yl4qWfaK8Js9jGe6gBGCSCKVqiyO30WnRZADvemUNw==", "dev": true, "requires": { - "sparkles": "1.0.0" + "sparkles": "^1.0.0" } }, "graceful-fs": { @@ -2409,7 +2416,7 @@ "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", "dev": true, "requires": { - "natives": "1.1.3" + "natives": "^1.1.0" } }, "growl": { @@ -2424,19 +2431,19 @@ "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", "dev": true, "requires": { - "archy": "1.0.0", - "chalk": "1.1.3", - "deprecated": "0.0.1", - "gulp-util": "3.0.8", - "interpret": "1.1.0", - "liftoff": "2.5.0", - "minimist": "1.2.0", - "orchestrator": "0.3.8", - "pretty-hrtime": "1.0.3", - "semver": "4.3.6", - "tildify": "1.2.0", - "v8flags": "2.1.1", - "vinyl-fs": "0.3.14" + "archy": "^1.0.0", + "chalk": "^1.0.0", + "deprecated": "^0.0.1", + "gulp-util": "^3.0.0", + "interpret": "^1.0.0", + "liftoff": "^2.1.0", + "minimist": "^1.1.0", + "orchestrator": "^0.3.0", + "pretty-hrtime": "^1.0.0", + "semver": "^4.1.0", + "tildify": "^1.0.0", + "v8flags": "^2.0.2", + "vinyl-fs": "^0.3.0" }, "dependencies": { "ansi-styles": { @@ -2451,11 +2458,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "supports-color": { @@ -2472,8 +2479,8 @@ "integrity": "sha512-SLg/KsHBbinR/pCX3PF5l1YlR28hLp0X+bcpf77PtMJ6zvAQ5kRjtCPV5Wt1wHXsXWZN0eTUZ15R8ZYpi/CdCA==", "dev": true, "requires": { - "plugin-error": "0.1.2", - "through2": "2.0.3" + "plugin-error": "^0.1.2", + "through2": "^2.0.3" }, "dependencies": { "arr-diff": { @@ -2482,8 +2489,8 @@ "integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-slice": "0.2.3" + "arr-flatten": "^1.0.1", + "array-slice": "^0.2.3" } }, "arr-union": { @@ -2504,7 +2511,7 @@ "integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=", "dev": true, "requires": { - "kind-of": "1.1.0" + "kind-of": "^1.1.0" } }, "kind-of": { @@ -2519,11 +2526,11 @@ "integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=", "dev": true, "requires": { - "ansi-cyan": "0.1.1", - "ansi-red": "0.1.1", - "arr-diff": "1.1.0", - "arr-union": "2.1.0", - "extend-shallow": "1.1.4" + "ansi-cyan": "^0.1.1", + "ansi-red": "^0.1.1", + "arr-diff": "^1.0.1", + "arr-union": "^2.0.1", + "extend-shallow": "^1.1.2" } } } @@ -2534,9 +2541,9 @@ "integrity": "sha1-Yz0WyV2IUEYorQJmVmPO5aR5M1M=", "dev": true, "requires": { - "concat-with-sourcemaps": "1.0.7", - "through2": "2.0.3", - "vinyl": "2.1.0" + "concat-with-sourcemaps": "^1.0.0", + "through2": "^2.0.0", + "vinyl": "^2.0.0" } }, "gulp-help": { @@ -2545,8 +2552,8 @@ "integrity": "sha1-Jh2xhuGDl/7z9qLCLpwxW/qIrgw=", "dev": true, "requires": { - "chalk": "1.1.3", - "object-assign": "3.0.0" + "chalk": "^1.0.0", + "object-assign": "^3.0.0" }, "dependencies": { "ansi-styles": { @@ -2561,11 +2568,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "object-assign": { @@ -2588,9 +2595,9 @@ "integrity": "sha1-pJe351cwBQQcqivIt92jyARE1ik=", "dev": true, "requires": { - "gulp-match": "1.0.3", - "ternary-stream": "2.0.1", - "through2": "2.0.3" + "gulp-match": "^1.0.3", + "ternary-stream": "^2.0.1", + "through2": "^2.0.1" } }, "gulp-insert": { @@ -2599,7 +2606,7 @@ "integrity": "sha1-MjE/E+SiPPWsylzl8MCAkjx3hgI=", "dev": true, "requires": { - "readable-stream": "1.1.14", + "readable-stream": "^1.0.26-4", "streamqueue": "0.0.6" }, "dependencies": { @@ -2615,10 +2622,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "string_decoder": { @@ -2635,7 +2642,7 @@ "integrity": "sha1-kcfA1/Kb7NZgbVfYCn+Hdqh6uo4=", "dev": true, "requires": { - "minimatch": "3.0.4" + "minimatch": "^3.0.3" } }, "gulp-newer": { @@ -2644,9 +2651,9 @@ "integrity": "sha512-h79fGO55S/P9eAADbLAP9aTtVYpLSR1ONj08VPaSdVVNVYhTS8p1CO1TW7kEMu+hC+sytmCqcUr5LesvZEtDoQ==", "dev": true, "requires": { - "glob": "7.1.2", - "kew": "0.7.0", - "plugin-error": "0.1.2" + "glob": "^7.0.3", + "kew": "^0.7.0", + "plugin-error": "^0.1.2" }, "dependencies": { "arr-diff": { @@ -2655,8 +2662,8 @@ "integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-slice": "0.2.3" + "arr-flatten": "^1.0.1", + "array-slice": "^0.2.3" } }, "arr-union": { @@ -2677,7 +2684,7 @@ "integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=", "dev": true, "requires": { - "kind-of": "1.1.0" + "kind-of": "^1.1.0" } }, "kind-of": { @@ -2692,11 +2699,11 @@ "integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=", "dev": true, "requires": { - "ansi-cyan": "0.1.1", - "ansi-red": "0.1.1", - "arr-diff": "1.1.0", - "arr-union": "2.1.0", - "extend-shallow": "1.1.4" + "ansi-cyan": "^0.1.1", + "ansi-red": "^0.1.1", + "arr-diff": "^1.0.1", + "arr-union": "^2.0.1", + "extend-shallow": "^1.1.2" } } } @@ -2713,25 +2720,19 @@ "integrity": "sha1-y7IAhFCxvM5s0jv5gze+dRv24wo=", "dev": true, "requires": { - "@gulp-sourcemaps/identity-map": "1.0.1", - "@gulp-sourcemaps/map-sources": "1.0.0", - "acorn": "5.7.1", - "convert-source-map": "1.5.1", - "css": "2.2.3", - "debug-fabulous": "1.1.0", - "detect-newline": "2.1.0", - "graceful-fs": "4.1.11", - "source-map": "0.6.1", - "strip-bom-string": "1.0.0", - "through2": "2.0.3" + "@gulp-sourcemaps/identity-map": "1.X", + "@gulp-sourcemaps/map-sources": "1.X", + "acorn": "5.X", + "convert-source-map": "1.X", + "css": "2.X", + "debug-fabulous": "1.X", + "detect-newline": "2.X", + "graceful-fs": "4.X", + "source-map": "~0.6.0", + "strip-bom-string": "1.X", + "through2": "2.X" }, "dependencies": { - "acorn": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", - "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", - "dev": true - }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", @@ -2747,17 +2748,17 @@ } }, "gulp-typescript": { - "version": "5.0.0-alpha.2", - "resolved": "https://registry.npmjs.org/gulp-typescript/-/gulp-typescript-5.0.0-alpha.2.tgz", - "integrity": "sha512-B4kcjtODEthCTdt0VYzCFQtM4fm9i/up0Mh1n63SX9j9orI6fEuwEyvKwAanmjjPOpCq8zbn77scIgpoXBULqA==", + "version": "5.0.0-alpha.3", + "resolved": "https://registry.npmjs.org/gulp-typescript/-/gulp-typescript-5.0.0-alpha.3.tgz", + "integrity": "sha512-6iSBjqBXAUqRsLUh/9XtlOnSzpPMbLrr5rqGj4UPLtGpDwFHW/fVTuRgv6LAWiKesLIUDDM0ourxvcpu2trecQ==", "dev": true, "requires": { - "ansi-colors": "2.0.1", - "plugin-error": "1.0.1", - "source-map": "0.7.3", - "through2": "2.0.3", - "vinyl": "2.1.0", - "vinyl-fs": "3.0.3" + "ansi-colors": "^2.0.2", + "plugin-error": "^1.0.1", + "source-map": "^0.7.3", + "through2": "^2.0.3", + "vinyl": "^2.1.0", + "vinyl-fs": "^3.0.3" }, "dependencies": { "glob-stream": { @@ -2766,16 +2767,16 @@ "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", "dev": true, "requires": { - "extend": "3.0.1", - "glob": "7.1.2", - "glob-parent": "3.1.0", - "is-negated-glob": "1.0.0", - "ordered-read-streams": "1.0.1", - "pumpify": "1.5.1", - "readable-stream": "2.3.6", - "remove-trailing-separator": "1.1.0", - "to-absolute-glob": "2.0.2", - "unique-stream": "2.2.1" + "extend": "^3.0.0", + "glob": "^7.1.1", + "glob-parent": "^3.1.0", + "is-negated-glob": "^1.0.0", + "ordered-read-streams": "^1.0.0", + "pumpify": "^1.3.5", + "readable-stream": "^2.1.5", + "remove-trailing-separator": "^1.0.1", + "to-absolute-glob": "^2.0.0", + "unique-stream": "^2.0.2" } }, "graceful-fs": { @@ -2790,7 +2791,7 @@ "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "ordered-read-streams": { @@ -2799,7 +2800,7 @@ "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.1" } }, "source-map": { @@ -2814,8 +2815,8 @@ "integrity": "sha1-WqADz76Uxf+GbE59ZouxxNuts2k=", "dev": true, "requires": { - "json-stable-stringify": "1.0.1", - "through2-filter": "2.0.0" + "json-stable-stringify": "^1.0.0", + "through2-filter": "^2.0.0" } }, "vinyl-fs": { @@ -2824,23 +2825,23 @@ "integrity": "sha512-vIu34EkyNyJxmP0jscNzWBSygh7VWhqun6RmqVfXePrOwi9lhvRs//dOaGOTRUQr4tx7/zd26Tk5WeSVZitgng==", "dev": true, "requires": { - "fs-mkdirp-stream": "1.0.0", - "glob-stream": "6.1.0", - "graceful-fs": "4.1.11", - "is-valid-glob": "1.0.0", - "lazystream": "1.0.0", - "lead": "1.0.0", - "object.assign": "4.1.0", - "pumpify": "1.5.1", - "readable-stream": "2.3.6", - "remove-bom-buffer": "3.0.0", - "remove-bom-stream": "1.2.0", - "resolve-options": "1.1.0", - "through2": "2.0.3", - "to-through": "2.0.0", - "value-or-function": "3.0.0", - "vinyl": "2.1.0", - "vinyl-sourcemap": "1.1.0" + "fs-mkdirp-stream": "^1.0.0", + "glob-stream": "^6.1.0", + "graceful-fs": "^4.0.0", + "is-valid-glob": "^1.0.0", + "lazystream": "^1.0.0", + "lead": "^1.0.0", + "object.assign": "^4.0.4", + "pumpify": "^1.3.5", + "readable-stream": "^2.3.3", + "remove-bom-buffer": "^3.0.0", + "remove-bom-stream": "^1.2.0", + "resolve-options": "^1.1.0", + "through2": "^2.0.0", + "to-through": "^2.0.0", + "value-or-function": "^3.0.0", + "vinyl": "^2.0.0", + "vinyl-sourcemap": "^1.1.0" } } } @@ -2851,24 +2852,24 @@ "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", "dev": true, "requires": { - "array-differ": "1.0.0", - "array-uniq": "1.0.3", - "beeper": "1.1.1", - "chalk": "1.1.3", - "dateformat": "2.2.0", - "fancy-log": "1.3.2", - "gulplog": "1.0.0", - "has-gulplog": "0.1.0", - "lodash._reescape": "3.0.0", - "lodash._reevaluate": "3.0.0", - "lodash._reinterpolate": "3.0.0", - "lodash.template": "3.6.2", - "minimist": "1.2.0", - "multipipe": "0.1.2", - "object-assign": "3.0.0", + "array-differ": "^1.0.0", + "array-uniq": "^1.0.2", + "beeper": "^1.0.0", + "chalk": "^1.0.0", + "dateformat": "^2.0.0", + "fancy-log": "^1.1.0", + "gulplog": "^1.0.0", + "has-gulplog": "^0.1.0", + "lodash._reescape": "^3.0.0", + "lodash._reevaluate": "^3.0.0", + "lodash._reinterpolate": "^3.0.0", + "lodash.template": "^3.0.0", + "minimist": "^1.1.0", + "multipipe": "^0.1.2", + "object-assign": "^3.0.0", "replace-ext": "0.0.1", - "through2": "2.0.3", - "vinyl": "0.5.3" + "through2": "^2.0.0", + "vinyl": "^0.5.0" }, "dependencies": { "ansi-styles": { @@ -2883,11 +2884,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "object-assign": { @@ -2908,8 +2909,8 @@ "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", "dev": true, "requires": { - "clone": "1.0.4", - "clone-stats": "0.0.1", + "clone": "^1.0.0", + "clone-stats": "^0.0.1", "replace-ext": "0.0.1" } } @@ -2921,7 +2922,7 @@ "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", "dev": true, "requires": { - "glogg": "1.0.1" + "glogg": "^1.0.0" } }, "handlebars": { @@ -2930,10 +2931,10 @@ "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", "dev": true, "requires": { - "async": "1.5.2", - "optimist": "0.6.1", - "source-map": "0.4.4", - "uglify-js": "2.8.29" + "async": "^1.4.0", + "optimist": "^0.6.1", + "source-map": "^0.4.4", + "uglify-js": "^2.6" }, "dependencies": { "source-map": { @@ -2942,7 +2943,7 @@ "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { - "amdefine": "1.0.1" + "amdefine": ">=0.0.4" } } } @@ -2953,7 +2954,7 @@ "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, "requires": { - "function-bind": "1.1.1" + "function-bind": "^1.1.1" } }, "has-ansi": { @@ -2962,7 +2963,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "has-color": { @@ -2983,7 +2984,7 @@ "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", "dev": true, "requires": { - "sparkles": "1.0.0" + "sparkles": "^1.0.0" } }, "has-symbols": { @@ -2998,9 +2999,9 @@ "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, "requires": { - "get-value": "2.0.6", - "has-values": "1.0.0", - "isobject": "3.0.1" + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" } }, "has-values": { @@ -3009,8 +3010,8 @@ "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" + "is-number": "^3.0.0", + "kind-of": "^4.0.0" }, "dependencies": { "kind-of": { @@ -3019,7 +3020,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -3030,18 +3031,18 @@ "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.4.tgz", + "integrity": "sha512-A6RlQvvZEtFS5fLU43IDu0QUmBy+fDO9VMdTXvufKwIkt/rFfvICAViCax5fbDO4zdNzaC3/27ZhKUok5bAJyw==", "dev": true, "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" } }, "he": { @@ -3056,9 +3057,9 @@ "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, "requires": { - "hash.js": "1.1.3", - "minimalistic-assert": "1.0.1", - "minimalistic-crypto-utils": "1.0.1" + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" } }, "homedir-polyfill": { @@ -3067,7 +3068,7 @@ "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", "dev": true, "requires": { - "parse-passwd": "1.0.0" + "parse-passwd": "^1.0.0" } }, "htmlescape": { @@ -3082,7 +3083,7 @@ "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", "dev": true, "requires": { - "agent-base": "4.2.0", + "agent-base": "4", "debug": "3.1.0" }, "dependencies": { @@ -3109,8 +3110,8 @@ "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", "dev": true, "requires": { - "agent-base": "4.2.0", - "debug": "3.1.0" + "agent-base": "^4.1.0", + "debug": "^3.1.0" }, "dependencies": { "debug": { @@ -3136,8 +3137,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -3158,24 +3159,25 @@ "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "~0.5.3" } }, "insert-module-globals": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.1.0.tgz", - "integrity": "sha512-LbYZdybvKjbbcKLp03lB323Cgc8f0iL0Rjh8U6JZ7K1gZSf7MxQH191iCNUcLX4qIQ6/yWe4Q4ZsQ+opcReNFg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", + "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", "dev": true, "requires": { - "combine-source-map": "0.8.0", - "concat-stream": "1.6.2", - "is-buffer": "1.1.6", - "JSONStream": "1.3.3", - "lexical-scope": "1.2.0", - "path-is-absolute": "1.0.1", - "process": "0.11.10", - "through2": "2.0.3", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "acorn-node": "^1.5.2", + "combine-source-map": "^0.8.0", + "concat-stream": "^1.6.1", + "is-buffer": "^1.1.0", + "path-is-absolute": "^1.0.1", + "process": "~0.11.0", + "through2": "^2.0.0", + "undeclared-identifiers": "^1.1.2", + "xtend": "^4.0.0" } }, "interpret": { @@ -3196,8 +3198,8 @@ "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", "dev": true, "requires": { - "is-relative": "1.0.0", - "is-windows": "1.0.2" + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" } }, "is-accessor-descriptor": { @@ -3206,7 +3208,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -3215,7 +3217,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -3232,7 +3234,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -3241,7 +3243,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -3252,9 +3254,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" }, "dependencies": { "kind-of": { @@ -3289,7 +3291,7 @@ "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, "requires": { - "is-extglob": "2.1.1" + "is-extglob": "^2.1.0" } }, "is-negated-glob": { @@ -3304,7 +3306,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -3313,7 +3315,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -3324,7 +3326,7 @@ "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", "dev": true, "requires": { - "is-number": "4.0.0" + "is-number": "^4.0.0" }, "dependencies": { "is-number": { @@ -3347,7 +3349,7 @@ "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", "dev": true, "requires": { - "is-path-inside": "1.0.1" + "is-path-inside": "^1.0.0" } }, "is-path-inside": { @@ -3356,7 +3358,7 @@ "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { - "path-is-inside": "1.0.2" + "path-is-inside": "^1.0.1" } }, "is-plain-object": { @@ -3365,7 +3367,7 @@ "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.1" } }, "is-promise": { @@ -3380,7 +3382,7 @@ "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", "dev": true, "requires": { - "is-unc-path": "1.0.0" + "is-unc-path": "^1.0.0" } }, "is-stream": { @@ -3395,7 +3397,7 @@ "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", "dev": true, "requires": { - "unc-path-regex": "0.1.2" + "unc-path-regex": "^0.1.2" } }, "is-utf8": { @@ -3440,20 +3442,20 @@ "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", "dev": true, "requires": { - "abbrev": "1.0.9", - "async": "1.5.2", - "escodegen": "1.8.1", - "esprima": "2.7.3", - "glob": "5.0.15", - "handlebars": "4.0.11", - "js-yaml": "3.11.0", - "mkdirp": "0.5.1", - "nopt": "3.0.6", - "once": "1.4.0", - "resolve": "1.1.7", - "supports-color": "3.2.3", - "which": "1.3.0", - "wordwrap": "1.0.0" + "abbrev": "1.0.x", + "async": "1.x", + "escodegen": "1.8.x", + "esprima": "2.7.x", + "glob": "^5.0.15", + "handlebars": "^4.0.1", + "js-yaml": "3.x", + "mkdirp": "0.5.x", + "nopt": "3.x", + "once": "1.x", + "resolve": "1.1.x", + "supports-color": "^3.1.0", + "which": "^1.1.1", + "wordwrap": "^1.0.0" }, "dependencies": { "glob": { @@ -3462,11 +3464,11 @@ "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true, "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "has-flag": { @@ -3481,7 +3483,7 @@ "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "dev": true, "requires": { - "has-flag": "1.0.0" + "has-flag": "^1.0.0" } } } @@ -3492,11 +3494,11 @@ "integrity": "sha512-qUTOVCKFkiz3tHgV1WMy7HTxDZgo+sO4X9GxFLAU+Mks4WsDGe9+ONHK6tPsSp8I3x6sPl0TwGbXHwTOhTyzog==", "dev": true, "requires": { - "async": "0.9.2", - "chalk": "0.4.0", - "filelist": "0.0.6", - "minimatch": "3.0.4", - "utilities": "1.0.5" + "async": "0.9.x", + "chalk": "0.4.x", + "filelist": "0.0.x", + "minimatch": "3.x", + "utilities": "1.0.x" }, "dependencies": { "ansi-styles": { @@ -3517,9 +3519,9 @@ "integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=", "dev": true, "requires": { - "ansi-styles": "1.0.0", - "has-color": "0.1.7", - "strip-ansi": "0.1.1" + "ansi-styles": "~1.0.0", + "has-color": "~0.1.0", + "strip-ansi": "~0.1.0" } }, "strip-ansi": { @@ -3537,13 +3539,13 @@ "dev": true }, "js-yaml": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", "dev": true, "requires": { - "argparse": "1.0.10", - "esprima": "4.0.0" + "argparse": "^1.0.7", + "esprima": "^4.0.0" }, "dependencies": { "esprima": { @@ -3560,7 +3562,7 @@ "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, "requires": { - "jsonify": "0.0.0" + "jsonify": "~0.0.0" } }, "jsonfile": { @@ -3569,7 +3571,7 @@ "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "dev": true, "requires": { - "graceful-fs": "4.1.11" + "graceful-fs": "^4.1.6" }, "dependencies": { "graceful-fs": { @@ -3593,16 +3595,6 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, - "JSONStream": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.3.tgz", - "integrity": "sha512-3Sp6WZZ/lXl+nTDoGpGWHEpTnnC6X5fnkolYZR6nwIfzbxxvA8utPWe1gCt7i0m9uVGsSz2IS8K8mJ7HmlduMg==", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "kew": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", @@ -3621,9 +3613,9 @@ "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", "dev": true, "requires": { - "inherits": "2.0.3", - "isarray": "2.0.4", - "stream-splicer": "2.0.0" + "inherits": "^2.0.1", + "isarray": "^2.0.4", + "stream-splicer": "^2.0.0" }, "dependencies": { "isarray": { @@ -3647,7 +3639,7 @@ "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.5" } }, "lcid": { @@ -3656,7 +3648,7 @@ "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", "dev": true, "requires": { - "invert-kv": "1.0.0" + "invert-kv": "^1.0.0" } }, "lead": { @@ -3665,7 +3657,7 @@ "integrity": "sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI=", "dev": true, "requires": { - "flush-write-stream": "1.0.3" + "flush-write-stream": "^1.0.2" } }, "levn": { @@ -3674,17 +3666,8 @@ "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, "requires": { - "prelude-ls": "1.1.2", - "type-check": "0.3.2" - } - }, - "lexical-scope": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", - "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", - "dev": true, - "requires": { - "astw": "2.2.0" + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" } }, "liftoff": { @@ -3693,14 +3676,14 @@ "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=", "dev": true, "requires": { - "extend": "3.0.1", - "findup-sync": "2.0.0", - "fined": "1.1.0", - "flagged-respawn": "1.0.0", - "is-plain-object": "2.0.4", - "object.map": "1.0.1", - "rechoir": "0.6.2", - "resolve": "1.1.7" + "extend": "^3.0.0", + "findup-sync": "^2.0.0", + "fined": "^1.0.1", + "flagged-respawn": "^1.0.0", + "is-plain-object": "^2.0.4", + "object.map": "^1.0.0", + "rechoir": "^0.6.2", + "resolve": "^1.1.7" } }, "locate-path": { @@ -3709,8 +3692,8 @@ "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", "dev": true, "requires": { - "p-locate": "2.0.0", - "path-exists": "3.0.0" + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" } }, "lodash": { @@ -3779,7 +3762,7 @@ "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", "dev": true, "requires": { - "lodash._root": "3.0.1" + "lodash._root": "^3.0.0" } }, "lodash.isarguments": { @@ -3800,9 +3783,9 @@ "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", "dev": true, "requires": { - "lodash._getnative": "3.9.1", - "lodash.isarguments": "3.1.0", - "lodash.isarray": "3.0.4" + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" } }, "lodash.memoize": { @@ -3823,15 +3806,15 @@ "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", "dev": true, "requires": { - "lodash._basecopy": "3.0.1", - "lodash._basetostring": "3.0.1", - "lodash._basevalues": "3.0.0", - "lodash._isiterateecall": "3.0.9", - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0", - "lodash.keys": "3.1.2", - "lodash.restparam": "3.6.1", - "lodash.templatesettings": "3.1.1" + "lodash._basecopy": "^3.0.0", + "lodash._basetostring": "^3.0.0", + "lodash._basevalues": "^3.0.0", + "lodash._isiterateecall": "^3.0.0", + "lodash._reinterpolate": "^3.0.0", + "lodash.escape": "^3.0.0", + "lodash.keys": "^3.0.0", + "lodash.restparam": "^3.0.0", + "lodash.templatesettings": "^3.0.0" } }, "lodash.templatesettings": { @@ -3840,8 +3823,8 @@ "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", "dev": true, "requires": { - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0" + "lodash._reinterpolate": "^3.0.0", + "lodash.escape": "^3.0.0" } }, "longest": { @@ -3862,7 +3845,7 @@ "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", "dev": true, "requires": { - "es5-ext": "0.10.45" + "es5-ext": "~0.10.2" } }, "make-iterator": { @@ -3871,7 +3854,7 @@ "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.2" } }, "map-cache": { @@ -3886,7 +3869,7 @@ "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, "requires": { - "object-visit": "1.0.1" + "object-visit": "^1.0.0" } }, "md5.js": { @@ -3895,8 +3878,8 @@ "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", "dev": true, "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" + "hash-base": "^3.0.0", + "inherits": "^2.0.1" } }, "mem": { @@ -3905,7 +3888,7 @@ "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", "dev": true, "requires": { - "mimic-fn": "1.2.0" + "mimic-fn": "^1.0.0" } }, "memoizee": { @@ -3914,14 +3897,14 @@ "integrity": "sha512-sprBu6nwxBWBvBOh5v2jcsGqiGLlL2xr2dLub3vR8dnE8YB17omwtm/0NSHl8jjNbcsJd5GMWJAnTSVe/O0Wfg==", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45", - "es6-weak-map": "2.0.2", - "event-emitter": "0.3.5", - "is-promise": "2.1.0", - "lru-queue": "0.1.0", - "next-tick": "1.0.0", - "timers-ext": "0.1.5" + "d": "1", + "es5-ext": "^0.10.30", + "es6-weak-map": "^2.0.2", + "event-emitter": "^0.3.5", + "is-promise": "^2.1", + "lru-queue": "0.1", + "next-tick": "1", + "timers-ext": "^0.1.2" } }, "merge-stream": { @@ -3930,7 +3913,7 @@ "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.1" } }, "merge2": { @@ -3945,19 +3928,19 @@ "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" } }, "miller-rabin": { @@ -3966,8 +3949,8 @@ "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0" + "bn.js": "^4.0.0", + "brorand": "^1.0.1" } }, "mimic-fn": { @@ -3994,7 +3977,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -4009,8 +3992,8 @@ "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", "dev": true, "requires": { - "for-in": "1.0.2", - "is-extendable": "1.0.1" + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" }, "dependencies": { "is-extendable": { @@ -4019,7 +4002,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "2.0.4" + "is-plain-object": "^2.0.4" } } } @@ -4083,30 +4066,30 @@ "integrity": "sha512-NPs5N511VD1rrVJihSso/LiBShRbJALYBKzDW91uZYy7BpjnO4bGnZL3HjZ9yKcFdZUWwaYjDz9zxbuP7vKMuQ==", "dev": true, "requires": { - "browser-resolve": "1.11.2", - "cached-path-relative": "1.0.1", - "concat-stream": "1.6.2", - "defined": "1.0.0", - "detective": "5.1.0", - "duplexer2": "0.1.4", - "inherits": "2.0.3", - "JSONStream": "1.3.3", - "parents": "1.0.1", - "readable-stream": "2.3.6", - "resolve": "1.7.1", - "stream-combiner2": "1.1.1", - "subarg": "1.0.0", - "through2": "2.0.3", - "xtend": "4.0.1" + "JSONStream": "^1.0.3", + "browser-resolve": "^1.7.0", + "cached-path-relative": "^1.0.0", + "concat-stream": "~1.6.0", + "defined": "^1.0.0", + "detective": "^5.0.2", + "duplexer2": "^0.1.2", + "inherits": "^2.0.1", + "parents": "^1.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.4.0", + "stream-combiner2": "^1.1.1", + "subarg": "^1.0.0", + "through2": "^2.0.0", + "xtend": "^4.0.0" }, "dependencies": { "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } } } @@ -4132,7 +4115,7 @@ "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", "dev": true, "requires": { - "readable-stream": "1.1.14" + "readable-stream": "~1.1.9" } }, "isarray": { @@ -4147,10 +4130,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "string_decoder": { @@ -4167,18 +4150,18 @@ "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "fragment-cache": "0.2.1", - "is-odd": "2.0.0", - "is-windows": "1.0.2", - "kind-of": "6.0.2", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-odd": "^2.0.0", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" } }, "natives": { @@ -4205,7 +4188,7 @@ "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "dev": true, "requires": { - "abbrev": "1.0.9" + "abbrev": "1" } }, "normalize-path": { @@ -4214,7 +4197,7 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "remove-trailing-separator": "1.1.0" + "remove-trailing-separator": "^1.0.1" } }, "now-and-later": { @@ -4223,7 +4206,7 @@ "integrity": "sha1-vGHLtFbXnLMiB85HygUTb/Ln1u4=", "dev": true, "requires": { - "once": "1.4.0" + "once": "^1.3.2" } }, "npm-run-path": { @@ -4232,7 +4215,7 @@ "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", "dev": true, "requires": { - "path-key": "2.0.1" + "path-key": "^2.0.0" } }, "number-is-nan": { @@ -4253,9 +4236,9 @@ "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, "requires": { - "copy-descriptor": "0.1.1", - "define-property": "0.2.5", - "kind-of": "3.2.2" + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" }, "dependencies": { "define-property": { @@ -4264,7 +4247,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "kind-of": { @@ -4273,7 +4256,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -4290,7 +4273,7 @@ "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.0" } }, "object.assign": { @@ -4299,10 +4282,10 @@ "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", "dev": true, "requires": { - "define-properties": "1.1.2", - "function-bind": "1.1.1", - "has-symbols": "1.0.0", - "object-keys": "1.0.12" + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" } }, "object.defaults": { @@ -4311,10 +4294,10 @@ "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", "dev": true, "requires": { - "array-each": "1.0.1", - "array-slice": "1.1.0", - "for-own": "1.0.0", - "isobject": "3.0.1" + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" } }, "object.map": { @@ -4323,8 +4306,8 @@ "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", "dev": true, "requires": { - "for-own": "1.0.0", - "make-iterator": "1.0.1" + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" } }, "object.pick": { @@ -4333,7 +4316,7 @@ "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, "requires": { - "isobject": "3.0.1" + "isobject": "^3.0.1" } }, "once": { @@ -4342,7 +4325,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "optimist": { @@ -4351,8 +4334,8 @@ "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { - "minimist": "0.0.10", - "wordwrap": "0.0.3" + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" }, "dependencies": { "minimist": { @@ -4375,12 +4358,12 @@ "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "dev": true, "requires": { - "deep-is": "0.1.3", - "fast-levenshtein": "2.0.6", - "levn": "0.3.0", - "prelude-ls": "1.1.2", - "type-check": "0.3.2", - "wordwrap": "1.0.0" + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" } }, "orchestrator": { @@ -4389,9 +4372,9 @@ "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", "dev": true, "requires": { - "end-of-stream": "0.1.5", - "sequencify": "0.0.7", - "stream-consume": "0.1.1" + "end-of-stream": "~0.1.5", + "sequencify": "~0.0.7", + "stream-consume": "~0.1.0" } }, "ordered-read-streams": { @@ -4418,9 +4401,9 @@ "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", "dev": true, "requires": { - "execa": "0.7.0", - "lcid": "1.0.0", - "mem": "1.1.0" + "execa": "^0.7.0", + "lcid": "^1.0.0", + "mem": "^1.1.0" } }, "p-finally": { @@ -4435,7 +4418,7 @@ "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", "dev": true, "requires": { - "p-try": "1.0.0" + "p-try": "^1.0.0" } }, "p-locate": { @@ -4444,7 +4427,7 @@ "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "p-limit": "1.3.0" + "p-limit": "^1.1.0" } }, "p-map": { @@ -4471,7 +4454,7 @@ "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, "requires": { - "path-platform": "0.11.15" + "path-platform": "~0.11.15" } }, "parse-asn1": { @@ -4480,11 +4463,11 @@ "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "dev": true, "requires": { - "asn1.js": "4.10.1", - "browserify-aes": "1.2.0", - "create-hash": "1.2.0", - "evp_bytestokey": "1.0.3", - "pbkdf2": "3.0.16" + "asn1.js": "^4.0.0", + "browserify-aes": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3" } }, "parse-filepath": { @@ -4493,9 +4476,9 @@ "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", "dev": true, "requires": { - "is-absolute": "1.0.0", - "map-cache": "0.2.2", - "path-root": "0.1.1" + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" } }, "parse-passwd": { @@ -4511,9 +4494,9 @@ "dev": true }, "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, "path-dirname": { @@ -4564,7 +4547,7 @@ "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", "dev": true, "requires": { - "path-root-regex": "0.1.2" + "path-root-regex": "^0.1.0" } }, "path-root-regex": { @@ -4585,11 +4568,11 @@ "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", "dev": true, "requires": { - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "ripemd160": "2.0.2", - "safe-buffer": "5.1.2", - "sha.js": "2.4.11" + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" } }, "pify": { @@ -4610,7 +4593,7 @@ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "requires": { - "pinkie": "2.0.4" + "pinkie": "^2.0.0" } }, "plugin-error": { @@ -4619,10 +4602,10 @@ "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", "dev": true, "requires": { - "ansi-colors": "1.1.0", - "arr-diff": "4.0.0", - "arr-union": "3.1.0", - "extend-shallow": "3.0.2" + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" }, "dependencies": { "ansi-colors": { @@ -4631,7 +4614,7 @@ "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", "dev": true, "requires": { - "ansi-wrap": "0.1.0" + "ansi-wrap": "^0.1.0" } } } @@ -4678,11 +4661,11 @@ "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", "dev": true, "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.2.0", - "parse-asn1": "5.1.1", - "randombytes": "2.0.6" + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1" } }, "pump": { @@ -4691,8 +4674,8 @@ "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", "dev": true, "requires": { - "end-of-stream": "1.4.1", - "once": "1.4.0" + "end-of-stream": "^1.1.0", + "once": "^1.3.1" }, "dependencies": { "end-of-stream": { @@ -4701,7 +4684,7 @@ "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "dev": true, "requires": { - "once": "1.4.0" + "once": "^1.4.0" } } } @@ -4712,9 +4695,9 @@ "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", "dev": true, "requires": { - "duplexify": "3.6.0", - "inherits": "2.0.3", - "pump": "2.0.1" + "duplexify": "^3.6.0", + "inherits": "^2.0.3", + "pump": "^2.0.0" } }, "punycode": { @@ -4747,7 +4730,7 @@ "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", "dev": true, "requires": { - "safe-buffer": "5.1.2" + "safe-buffer": "^5.1.0" } }, "randomfill": { @@ -4756,8 +4739,8 @@ "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, "requires": { - "randombytes": "2.0.6", - "safe-buffer": "5.1.2" + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" } }, "read-only-stream": { @@ -4766,7 +4749,7 @@ "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, "requires": { - "readable-stream": "2.3.6" + "readable-stream": "^2.0.2" } }, "readable-stream": { @@ -4775,13 +4758,13 @@ "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.2", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, "rechoir": { @@ -4790,7 +4773,7 @@ "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true, "requires": { - "resolve": "1.1.7" + "resolve": "^1.1.6" } }, "regex-not": { @@ -4799,8 +4782,8 @@ "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, "requires": { - "extend-shallow": "3.0.2", - "safe-regex": "1.1.0" + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" } }, "remove-bom-buffer": { @@ -4809,8 +4792,8 @@ "integrity": "sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ==", "dev": true, "requires": { - "is-buffer": "1.1.6", - "is-utf8": "0.2.1" + "is-buffer": "^1.1.5", + "is-utf8": "^0.2.1" } }, "remove-bom-stream": { @@ -4819,9 +4802,9 @@ "integrity": "sha1-BfGlk/FuQuH7kOv1nejlaVJflSM=", "dev": true, "requires": { - "remove-bom-buffer": "3.0.0", - "safe-buffer": "5.1.2", - "through2": "2.0.3" + "remove-bom-buffer": "^3.0.0", + "safe-buffer": "^5.1.0", + "through2": "^2.0.3" } }, "remove-internal": { @@ -4830,9 +4813,9 @@ "integrity": "sha512-+t02ljhWPIbmnamxlAHm0idgbSx4VUEGwjl0Ne1kxDthKfCKFhHeMbalkq5oacoxYlYeYMSXCZtzWuzGqPqZoA==", "dev": true, "requires": { - "mkdirp": "0.5.1", - "typescript": "2.9.1", - "yargs": "11.0.0" + "mkdirp": "^0.5.1", + "typescript": "^2.9.1", + "yargs": "^11.0.0" }, "dependencies": { "ansi-regex": { @@ -4847,9 +4830,9 @@ "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", "dev": true, "requires": { - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "wrap-ansi": "2.1.0" + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" } }, "strip-ansi": { @@ -4858,7 +4841,7 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } }, "typescript": { @@ -4873,18 +4856,18 @@ "integrity": "sha512-Rjp+lMYQOWtgqojx1dEWorjCofi1YN7AoFvYV7b1gx/7dAAeuI4kN5SZiEvr0ZmsZTOpDRcCqrpI10L31tFkBw==", "dev": true, "requires": { - "cliui": "4.1.0", - "decamelize": "1.2.0", - "find-up": "2.1.0", - "get-caller-file": "1.0.2", - "os-locale": "2.1.0", - "require-directory": "2.1.1", - "require-main-filename": "1.0.1", - "set-blocking": "2.0.0", - "string-width": "2.1.1", - "which-module": "2.0.0", - "y18n": "3.2.1", - "yargs-parser": "9.0.2" + "cliui": "^4.0.0", + "decamelize": "^1.1.1", + "find-up": "^2.1.0", + "get-caller-file": "^1.0.1", + "os-locale": "^2.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^9.0.2" } } } @@ -4937,8 +4920,8 @@ "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", "dev": true, "requires": { - "expand-tilde": "2.0.2", - "global-modules": "1.0.0" + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" } }, "resolve-options": { @@ -4947,7 +4930,7 @@ "integrity": "sha1-MrueOcBtZzONyTeMDW1gdFZq0TE=", "dev": true, "requires": { - "value-or-function": "3.0.0" + "value-or-function": "^3.0.0" } }, "resolve-url": { @@ -4969,7 +4952,7 @@ "dev": true, "optional": true, "requires": { - "align-text": "0.1.4" + "align-text": "^0.1.1" } }, "rimraf": { @@ -4978,7 +4961,7 @@ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "ripemd160": { @@ -4987,8 +4970,8 @@ "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" + "hash-base": "^3.0.0", + "inherits": "^2.0.1" } }, "run-sequence": { @@ -4997,9 +4980,9 @@ "integrity": "sha512-qkzZnQWMZjcKbh3CNly2srtrkaO/2H/SI5f2eliMCapdRD3UhMrwjfOAZJAnZ2H8Ju4aBzFZkBGXUqFs9V0yxw==", "dev": true, "requires": { - "chalk": "1.1.3", - "fancy-log": "1.3.2", - "plugin-error": "0.1.2" + "chalk": "^1.1.3", + "fancy-log": "^1.3.2", + "plugin-error": "^0.1.2" }, "dependencies": { "ansi-styles": { @@ -5014,8 +4997,8 @@ "integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=", "dev": true, "requires": { - "arr-flatten": "1.1.0", - "array-slice": "0.2.3" + "arr-flatten": "^1.0.1", + "array-slice": "^0.2.3" } }, "arr-union": { @@ -5036,11 +5019,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "extend-shallow": { @@ -5049,7 +5032,7 @@ "integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=", "dev": true, "requires": { - "kind-of": "1.1.0" + "kind-of": "^1.1.0" } }, "kind-of": { @@ -5064,11 +5047,11 @@ "integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=", "dev": true, "requires": { - "ansi-cyan": "0.1.1", - "ansi-red": "0.1.1", - "arr-diff": "1.1.0", - "arr-union": "2.1.0", - "extend-shallow": "1.1.4" + "ansi-cyan": "^0.1.1", + "ansi-red": "^0.1.1", + "arr-diff": "^1.0.1", + "arr-union": "^2.0.1", + "extend-shallow": "^1.1.2" } }, "supports-color": { @@ -5091,7 +5074,7 @@ "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { - "ret": "0.1.15" + "ret": "~0.1.10" } }, "sax": { @@ -5124,10 +5107,10 @@ "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "split-string": "3.1.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" }, "dependencies": { "extend-shallow": { @@ -5136,7 +5119,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -5147,8 +5130,8 @@ "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.2" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "shasum": { @@ -5157,8 +5140,8 @@ "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, "requires": { - "json-stable-stringify": "0.0.1", - "sha.js": "2.4.11" + "json-stable-stringify": "~0.0.0", + "sha.js": "~2.4.4" } }, "shebang-command": { @@ -5167,7 +5150,7 @@ "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "dev": true, "requires": { - "shebang-regex": "1.0.0" + "shebang-regex": "^1.0.0" } }, "shebang-regex": { @@ -5182,10 +5165,10 @@ "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", "dev": true, "requires": { - "array-filter": "0.0.1", - "array-map": "0.0.0", - "array-reduce": "0.0.0", - "jsonify": "0.0.0" + "array-filter": "~0.0.0", + "array-map": "~0.0.0", + "array-reduce": "~0.0.0", + "jsonify": "~0.0.0" } }, "sigmund": { @@ -5200,20 +5183,26 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", + "dev": true + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, "requires": { - "base": "0.11.2", - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "map-cache": "0.2.2", - "source-map": "0.5.7", - "source-map-resolve": "0.5.1", - "use": "3.1.0" + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" }, "dependencies": { "define-property": { @@ -5222,7 +5211,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } }, "extend-shallow": { @@ -5231,7 +5220,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } } } @@ -5242,9 +5231,9 @@ "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, "requires": { - "define-property": "1.0.0", - "isobject": "3.0.1", - "snapdragon-util": "3.0.1" + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" }, "dependencies": { "define-property": { @@ -5253,7 +5242,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "1.0.2" + "is-descriptor": "^1.0.0" } }, "is-accessor-descriptor": { @@ -5262,7 +5251,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-data-descriptor": { @@ -5271,7 +5260,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.0" } }, "is-descriptor": { @@ -5280,9 +5269,9 @@ "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" } } } @@ -5293,7 +5282,7 @@ "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.2.0" }, "dependencies": { "kind-of": { @@ -5302,7 +5291,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -5319,11 +5308,11 @@ "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==", "dev": true, "requires": { - "atob": "2.1.0", - "decode-uri-component": "0.2.0", - "resolve-url": "0.2.1", - "source-map-url": "0.4.0", - "urix": "0.1.0" + "atob": "^2.0.0", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" } }, "source-map-support": { @@ -5332,8 +5321,8 @@ "integrity": "sha512-N4KXEz7jcKqPf2b2vZF11lQIz9W5ZMuUcIOGj243lduidkf2fjkVKJS9vNxVWn3u/uxX38AcE8U9nnH9FPcq+g==", "dev": true, "requires": { - "buffer-from": "1.1.0", - "source-map": "0.6.1" + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" }, "dependencies": { "source-map": { @@ -5362,7 +5351,7 @@ "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, "requires": { - "extend-shallow": "3.0.2" + "extend-shallow": "^3.0.0" } }, "sprintf-js": { @@ -5377,8 +5366,8 @@ "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, "requires": { - "define-property": "0.2.5", - "object-copy": "0.1.0" + "define-property": "^0.2.5", + "object-copy": "^0.1.0" }, "dependencies": { "define-property": { @@ -5387,7 +5376,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "0.1.6" + "is-descriptor": "^0.1.0" } } } @@ -5398,8 +5387,8 @@ "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.6" + "inherits": "~2.0.1", + "readable-stream": "^2.0.2" } }, "stream-combiner2": { @@ -5408,8 +5397,8 @@ "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, "requires": { - "duplexer2": "0.1.4", - "readable-stream": "2.3.6" + "duplexer2": "~0.1.0", + "readable-stream": "^2.0.2" } }, "stream-consume": { @@ -5424,11 +5413,11 @@ "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, "requires": { - "builtin-status-codes": "3.0.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "to-arraybuffer": "1.0.1", - "xtend": "4.0.1" + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.3.6", + "to-arraybuffer": "^1.0.0", + "xtend": "^4.0.0" } }, "stream-shift": { @@ -5443,8 +5432,8 @@ "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.6" + "inherits": "^2.0.1", + "readable-stream": "^2.0.2" } }, "streamqueue": { @@ -5453,7 +5442,7 @@ "integrity": "sha1-ZvX17JTpuK8knkrsLdH3Qb/pTeM=", "dev": true, "requires": { - "readable-stream": "1.1.14" + "readable-stream": "^1.0.26-2" }, "dependencies": { "isarray": { @@ -5468,10 +5457,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "string_decoder": { @@ -5482,23 +5471,14 @@ } } }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" }, "dependencies": { "ansi-regex": { @@ -5513,18 +5493,27 @@ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "ansi-regex": "^3.0.0" } } } }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-bom": { @@ -5533,8 +5522,8 @@ "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", "dev": true, "requires": { - "first-chunk-stream": "1.0.0", - "is-utf8": "0.2.1" + "first-chunk-stream": "^1.0.0", + "is-utf8": "^0.2.0" } }, "strip-bom-string": { @@ -5555,7 +5544,7 @@ "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, "requires": { - "minimist": "1.2.0" + "minimist": "^1.1.0" } }, "supports-color": { @@ -5564,7 +5553,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "3.0.0" + "has-flag": "^3.0.0" } }, "syntax-error": { @@ -5573,7 +5562,7 @@ "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, "requires": { - "acorn-node": "1.3.0" + "acorn-node": "^1.2.0" } }, "ternary-stream": { @@ -5582,10 +5571,10 @@ "integrity": "sha1-Bk5Im0tb9gumpre8fy9cJ07Pgmk=", "dev": true, "requires": { - "duplexify": "3.6.0", - "fork-stream": "0.0.4", - "merge-stream": "1.0.1", - "through2": "2.0.3" + "duplexify": "^3.5.0", + "fork-stream": "^0.0.4", + "merge-stream": "^1.0.0", + "through2": "^2.0.1" } }, "through": { @@ -5600,8 +5589,8 @@ "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "readable-stream": "2.3.6", - "xtend": "4.0.1" + "readable-stream": "^2.1.5", + "xtend": "~4.0.1" } }, "through2-filter": { @@ -5610,8 +5599,8 @@ "integrity": "sha1-YLxVoNrLdghdsfna6Zq0P4PWIuw=", "dev": true, "requires": { - "through2": "2.0.3", - "xtend": "4.0.1" + "through2": "~2.0.0", + "xtend": "~4.0.0" } }, "tildify": { @@ -5620,7 +5609,7 @@ "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", "dev": true, "requires": { - "os-homedir": "1.0.2" + "os-homedir": "^1.0.0" } }, "time-stamp": { @@ -5635,7 +5624,7 @@ "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, "requires": { - "process": "0.11.10" + "process": "~0.11.0" } }, "timers-ext": { @@ -5644,8 +5633,8 @@ "integrity": "sha512-tsEStd7kmACHENhsUPaxb8Jf8/+GZZxyNFQbZD07HQOyooOa6At1rQqjffgvg7n+dxscQa9cjjMdWhJtsP2sxg==", "dev": true, "requires": { - "es5-ext": "0.10.45", - "next-tick": "1.0.0" + "es5-ext": "~0.10.14", + "next-tick": "1" } }, "to-absolute-glob": { @@ -5654,8 +5643,8 @@ "integrity": "sha1-GGX0PZ50sIItufFFt4z/fQ98hJs=", "dev": true, "requires": { - "is-absolute": "1.0.0", - "is-negated-glob": "1.0.0" + "is-absolute": "^1.0.0", + "is-negated-glob": "^1.0.0" } }, "to-arraybuffer": { @@ -5670,7 +5659,7 @@ "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" }, "dependencies": { "kind-of": { @@ -5679,7 +5668,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } } } @@ -5690,10 +5679,10 @@ "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, "requires": { - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "regex-not": "1.0.2", - "safe-regex": "1.1.0" + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" } }, "to-regex-range": { @@ -5702,8 +5691,8 @@ "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, "requires": { - "is-number": "3.0.0", - "repeat-string": "1.6.1" + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" } }, "to-through": { @@ -5712,7 +5701,7 @@ "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", "dev": true, "requires": { - "through2": "2.0.3" + "through2": "^2.0.3" } }, "travis-fold": { @@ -5722,9 +5711,9 @@ "dev": true }, "tslib": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.2.tgz", - "integrity": "sha512-AVP5Xol3WivEr7hnssHDsaM+lVrVXWUvd1cfXTRkTj80b//6g2wIFEH6hZG0muGZRnHGrfttpdzRk3YlBkWjKw==", + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "dev": true }, "tslint": { @@ -5733,27 +5722,27 @@ "integrity": "sha1-EeJrzLiK+gLdDZlWyuPUVAtfVMM=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "builtin-modules": "1.1.1", - "chalk": "2.4.1", - "commander": "2.15.1", - "diff": "3.5.0", - "glob": "7.1.2", - "js-yaml": "3.11.0", - "minimatch": "3.0.4", - "resolve": "1.7.1", - "semver": "5.5.0", - "tslib": "1.9.2", - "tsutils": "2.27.1" + "babel-code-frame": "^6.22.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.7.0", + "minimatch": "^3.0.4", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.12.1" }, "dependencies": { "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } }, "semver": { @@ -5765,12 +5754,12 @@ } }, "tsutils": { - "version": "2.27.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.27.1.tgz", - "integrity": "sha512-AE/7uzp32MmaHvNNFES85hhUDHFdFZp6OAiZcd6y4ZKKIg6orJTm8keYWBhIhrJQH3a4LzNKat7ZPXZt5aTf6w==", + "version": "2.27.2", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.27.2.tgz", + "integrity": "sha512-qf6rmT84TFMuxAKez2pIfR8UCai49iQsfB7YWVjV1bKpy/d0PWT5rEOSM6La9PiHZ0k1RRZQiwVdVJfQ3BPHgg==", "dev": true, "requires": { - "tslib": "1.9.2" + "tslib": "^1.8.1" } }, "tty-browserify": { @@ -5785,7 +5774,7 @@ "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, "requires": { - "prelude-ls": "1.1.2" + "prelude-ls": "~1.1.2" } }, "type-detect": { @@ -5801,9 +5790,9 @@ "dev": true }, "typescript": { - "version": "3.0.0-dev.20180626", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.0-dev.20180626.tgz", - "integrity": "sha512-OQH9osIC4CdsVzVvsb2RenRTVPRKwSIMIpRy2J42XNOEUP+vhX56BX1Z47K3l//LEGY0xG7zF7qVKCDlUhhrlg==", + "version": "3.0.0-dev.20180706", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.0-dev.20180706.tgz", + "integrity": "sha512-FDGcMfvqDr4xoYhyspX/0SshPQCHFYbegQtggwxJLAWHtMjmutN+DrdNqEGwpX5nGKP96Ek34SN7HDRJegqZzw==", "dev": true }, "uglify-js": { @@ -5813,9 +5802,9 @@ "dev": true, "optional": true, "requires": { - "source-map": "0.5.7", - "uglify-to-browserify": "1.0.2", - "yargs": "3.10.0" + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" } }, "uglify-to-browserify": { @@ -5837,16 +5826,28 @@ "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", "dev": true }, + "undeclared-identifiers": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz", + "integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==", + "dev": true, + "requires": { + "acorn-node": "^1.3.0", + "get-assigned-identifiers": "^1.2.0", + "simple-concat": "^1.0.0", + "xtend": "^4.0.1" + } + }, "union-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", "dev": true, "requires": { - "arr-union": "3.1.0", - "get-value": "2.0.6", - "is-extendable": "0.1.1", - "set-value": "0.4.3" + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^0.4.3" }, "dependencies": { "extend-shallow": { @@ -5855,7 +5856,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "0.1.1" + "is-extendable": "^0.1.0" } }, "set-value": { @@ -5864,10 +5865,10 @@ "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", "dev": true, "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "to-object-path": "0.3.0" + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.1", + "to-object-path": "^0.3.0" } } } @@ -5890,8 +5891,8 @@ "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, "requires": { - "has-value": "0.3.1", - "isobject": "3.0.1" + "has-value": "^0.3.1", + "isobject": "^3.0.0" }, "dependencies": { "has-value": { @@ -5900,9 +5901,9 @@ "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, "requires": { - "get-value": "2.0.6", - "has-values": "0.1.4", - "isobject": "2.1.0" + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" }, "dependencies": { "isobject": { @@ -5960,7 +5961,7 @@ "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", "dev": true, "requires": { - "kind-of": "6.0.2" + "kind-of": "^6.0.2" } }, "user-home": { @@ -5996,7 +5997,7 @@ "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", "dev": true, "requires": { - "user-home": "1.1.1" + "user-home": "^1.1.1" } }, "value-or-function": { @@ -6006,17 +6007,17 @@ "dev": true }, "vinyl": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.1.0.tgz", - "integrity": "sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz", + "integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==", "dev": true, "requires": { - "clone": "2.1.1", - "clone-buffer": "1.0.0", - "clone-stats": "1.0.0", - "cloneable-readable": "1.1.2", - "remove-trailing-separator": "1.1.0", - "replace-ext": "1.0.0" + "clone": "^2.1.1", + "clone-buffer": "^1.0.0", + "clone-stats": "^1.0.0", + "cloneable-readable": "^1.0.0", + "remove-trailing-separator": "^1.0.1", + "replace-ext": "^1.0.0" }, "dependencies": { "clone": { @@ -6045,14 +6046,14 @@ "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", "dev": true, "requires": { - "defaults": "1.0.3", - "glob-stream": "3.1.18", - "glob-watcher": "0.0.6", - "graceful-fs": "3.0.11", - "mkdirp": "0.5.1", - "strip-bom": "1.0.0", - "through2": "0.6.5", - "vinyl": "0.4.6" + "defaults": "^1.0.0", + "glob-stream": "^3.1.5", + "glob-watcher": "^0.0.6", + "graceful-fs": "^3.0.0", + "mkdirp": "^0.5.0", + "strip-bom": "^1.0.0", + "through2": "^0.6.1", + "vinyl": "^0.4.0" }, "dependencies": { "clone": { @@ -6073,10 +6074,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", "isarray": "0.0.1", - "string_decoder": "0.10.31" + "string_decoder": "~0.10.x" } }, "string_decoder": { @@ -6091,8 +6092,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" + "readable-stream": ">=1.0.33-1 <1.1.0-0", + "xtend": ">=4.0.0 <4.1.0-0" } }, "vinyl": { @@ -6101,8 +6102,8 @@ "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", "dev": true, "requires": { - "clone": "0.2.0", - "clone-stats": "0.0.1" + "clone": "^0.2.0", + "clone-stats": "^0.0.1" } } } @@ -6113,13 +6114,13 @@ "integrity": "sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY=", "dev": true, "requires": { - "append-buffer": "1.0.2", - "convert-source-map": "1.5.1", - "graceful-fs": "4.1.11", - "normalize-path": "2.1.1", - "now-and-later": "2.0.0", - "remove-bom-buffer": "3.0.0", - "vinyl": "2.1.0" + "append-buffer": "^1.0.2", + "convert-source-map": "^1.5.0", + "graceful-fs": "^4.1.6", + "normalize-path": "^2.1.1", + "now-and-later": "^2.0.0", + "remove-bom-buffer": "^3.0.0", + "vinyl": "^2.0.0" }, "dependencies": { "graceful-fs": { @@ -6136,13 +6137,13 @@ "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", "dev": true, "requires": { - "source-map": "0.5.7" + "source-map": "^0.5.1" } }, "vm-browserify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.0.1.tgz", - "integrity": "sha512-EqzLchIMYLBjRPoqVsEkZOa/4Vr2RfOWbd58F+I/Gj79AYTrsseMunxbbSkbYfrqZaXSuPBBXNSOhtJgg0PpmA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz", + "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==", "dev": true }, "which": { @@ -6151,7 +6152,7 @@ "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { - "isexe": "2.0.0" + "isexe": "^2.0.0" } }, "which-module": { @@ -6179,8 +6180,8 @@ "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { - "string-width": "1.0.2", - "strip-ansi": "3.0.1" + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" }, "dependencies": { "is-fullwidth-code-point": { @@ -6189,7 +6190,7 @@ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "string-width": { @@ -6198,9 +6199,9 @@ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } } } @@ -6217,8 +6218,8 @@ "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", "dev": true, "requires": { - "sax": "1.2.4", - "xmlbuilder": "9.0.7" + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" } }, "xmlbuilder": { @@ -6252,9 +6253,9 @@ "dev": true, "optional": true, "requires": { - "camelcase": "1.2.1", - "cliui": "2.1.0", - "decamelize": "1.2.0", + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", "window-size": "0.1.0" } }, @@ -6264,7 +6265,7 @@ "integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=", "dev": true, "requires": { - "camelcase": "4.1.0" + "camelcase": "^4.1.0" }, "dependencies": { "camelcase": { diff --git a/package.json b/package.json index af7f0369a6721..510d3aab53b1b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "3.0.0", + "version": "3.1.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/scripts/build/browserify.js b/scripts/build/browserify.js index 3d9fffa9fa652..1fa5bbdeaf368 100644 --- a/scripts/build/browserify.js +++ b/scripts/build/browserify.js @@ -1,120 +1,34 @@ // @ts-check -const Browserify = require("browserify"); -const Vinyl = require("vinyl"); -const fs = require("fs"); -const path = require("path"); -const convertMap = require("convert-source-map"); -const applySourceMap = require("vinyl-sourcemaps-apply"); -const { Transform, Readable } = require("stream"); +const browserify = require("browserify"); +const Vinyl = require("./vinyl"); +const { Transform } = require("stream"); +const { streamFromFile } = require("./utils"); +const { replaceContents } = require("./sourcemaps"); -module.exports = browserify; +module.exports = browserifyFile; /** * @param {import("browserify").Options} [opts] */ -function browserify(opts) { +function browserifyFile(opts) { return new Transform({ objectMode: true, /** - * @param {string | Buffer | File} input + * @param {string | Buffer | Vinyl} input */ transform(input, _, cb) { if (typeof input === "string" || Buffer.isBuffer(input)) return cb(new Error("Only Vinyl files are supported.")); try { - const sourceMap = input.sourceMap; - const cwd = input.cwd || process.cwd(); - const base = input.base || cwd; - const output = /**@type {File}*/(new Vinyl({ path: input.path, base: input.base })); - const stream = streamFromFile(input); - const b = new Browserify(Object.assign({}, opts, { debug: !!sourceMap, basedir: input.base })); - b.add(stream, { file: input.path, basedir: input.base }); - b.bundle((err, contents) => { - if (err) return cb(err); - output.contents = contents; - if (sourceMap) { - output.sourceMap = typeof sourceMap === "string" ? JSON.parse(sourceMap) : sourceMap; - const sourceRoot = output.sourceMap.sourceRoot; - makeAbsoluteSourceMap(cwd, base, output.sourceMap); - const stringContents = contents.toString("utf8"); - const newSourceMapConverter = convertMap.fromSource(stringContents); - if (newSourceMapConverter) { - const newSourceMap = newSourceMapConverter.toObject(); - makeAbsoluteSourceMap(cwd, base, newSourceMap); - applySourceMap(output, newSourceMap); - makeRelativeSourceMap(cwd, base, sourceRoot, output.sourceMap); - output.contents = new Buffer(convertMap.removeComments(stringContents), "utf8"); - } - } - cb(null, output); - }); + browserify(Object.assign({}, opts, { debug: !!input.sourceMap, basedir: input.base })) + .add(streamFromFile(input), { file: input.path, basedir: input.base }) + .bundle((err, contents) => { + if (err) return cb(err); + cb(null, replaceContents(input, contents)); + }); } catch (e) { cb(e); } } }); -} - -/** - * @param {string | undefined} cwd - * @param {string | undefined} base - * @param {RawSourceMap} sourceMap - * - * @typedef RawSourceMap - * @property {string} version - * @property {string} file - * @property {string} [sourceRoot] - * @property {string[]} sources - * @property {string[]} [sourcesContents] - * @property {string} mappings - * @property {string[]} [names] - */ -function makeAbsoluteSourceMap(cwd = process.cwd(), base = "", sourceMap) { - const sourceRoot = sourceMap.sourceRoot || ""; - const resolvedBase = path.resolve(cwd, base); - const resolvedSourceRoot = path.resolve(resolvedBase, sourceRoot); - sourceMap.file = path.resolve(resolvedBase, sourceMap.file).replace(/\\/g, "/"); - sourceMap.sources = sourceMap.sources.map(source => path.resolve(resolvedSourceRoot, source).replace(/\\/g, "/")); - sourceMap.sourceRoot = ""; -} - -/** - * @param {string | undefined} cwd - * @param {string | undefined} base - * @param {string} sourceRoot - * @param {RawSourceMap} sourceMap - */ -function makeRelativeSourceMap(cwd = process.cwd(), base = "", sourceRoot, sourceMap) { - makeAbsoluteSourceMap(cwd, base, sourceMap); - const resolvedBase = path.resolve(cwd, base); - const resolvedSourceRoot = path.resolve(resolvedBase, sourceRoot); - sourceMap.file = path.relative(resolvedBase, sourceMap.file).replace(/\\/g, "/"); - sourceMap.sources = sourceMap.sources.map(source => path.relative(resolvedSourceRoot, source).replace(/\\/g, "/")); - sourceMap.sourceRoot = sourceRoot; -} - -/** - * @param {File} file - */ -function streamFromFile(file) { - return file.isBuffer() ? streamFromBuffer(file.contents) : - file.isStream() ? file.contents : - fs.createReadStream(file.path, { autoClose: true }); -} - -/** - * @param {Buffer} buffer - */ -function streamFromBuffer(buffer) { - return new Readable({ - read() { - this.push(buffer); - this.push(null); - } - }); -} - -/** - * @typedef {import("vinyl") & { sourceMap?: any }} File - */ -void 0; \ No newline at end of file +} \ No newline at end of file diff --git a/scripts/build/cancellation.js b/scripts/build/cancellation.js new file mode 100644 index 0000000000000..793aaf19d868c --- /dev/null +++ b/scripts/build/cancellation.js @@ -0,0 +1,71 @@ +// @ts-check +const symSource = Symbol("CancelToken.source"); +const symToken = Symbol("CancelSource.token"); +const symCancellationRequested = Symbol("CancelSource.cancellationRequested"); +const symCancellationCallbacks = Symbol("CancelSource.cancellationCallbacks"); + +class CancelSource { + constructor() { + this[symCancellationRequested] = false; + this[symCancellationCallbacks] = []; + } + + /** @type {CancelToken} */ + get token() { + return this[symToken] || (this[symToken] = new CancelToken(this)); + } + + cancel() { + if (!this[symCancellationRequested]) { + this[symCancellationRequested] = true; + for (const callback of this[symCancellationCallbacks]) { + callback(); + } + } + } +} +exports.CancelSource = CancelSource; + +class CancelToken { + /** + * @param {CancelSource} source + */ + constructor(source) { + if (source[symToken]) return source[symToken]; + this[symSource] = source; + } + + /** @type {boolean} */ + get cancellationRequested() { + return this[symSource][symCancellationRequested]; + } + + /** + * @param {() => void} callback + */ + subscribe(callback) { + const source = this[symSource]; + if (source[symCancellationRequested]) { + callback(); + return; + } + + source[symCancellationCallbacks].push(callback); + + return { + unsubscribe() { + const index = source[symCancellationCallbacks].indexOf(callback); + if (index !== -1) source[symCancellationCallbacks].splice(index, 1); + } + }; + } +} +exports.CancelToken = CancelToken; + +class CancelError extends Error { + constructor(message = "Operation was canceled") { + super(message); + this.name = "CancelError"; + } +} +exports.CancelError = CancelError; \ No newline at end of file diff --git a/scripts/build/debounce.js b/scripts/build/debounce.js new file mode 100644 index 0000000000000..7020cb61bbd16 --- /dev/null +++ b/scripts/build/debounce.js @@ -0,0 +1,31 @@ +// @ts-check +module.exports = debounce; + +/** + * @param {() => void} cb + * @param {number} timeout + * @param {DebounceOptions} [opts] + * + * @typedef DebounceOptions + * @property {number} [max] + */ +function debounce(cb, timeout, opts = {}) { + if (timeout < 10) timeout = 10; + let max = opts.max || 10; + if (max < timeout) max = timeout; + let minTimer; + let maxTimer; + return trigger; + + function trigger() { + if (max > timeout && !maxTimer) maxTimer = setTimeout(done, max); + if (minTimer) clearTimeout(minTimer); + minTimer = setTimeout(done, timeout); + } + + function done() { + if (maxTimer) maxTimer = void clearTimeout(maxTimer); + if (minTimer) minTimer = void clearTimeout(minTimer); + cb(); + } +} \ No newline at end of file diff --git a/scripts/build/exec.js b/scripts/build/exec.js index ca7c6e3f6c961..04336321dd468 100644 --- a/scripts/build/exec.js +++ b/scripts/build/exec.js @@ -3,6 +3,7 @@ const cp = require("child_process"); const log = require("fancy-log"); // was `require("gulp-util").log (see https://github.com/gulpjs/gulp-util) const isWin = /^win/.test(process.platform); const chalk = require("./chalk"); +const { CancelToken, CancelError } = require("./cancellation"); module.exports = exec; @@ -10,8 +11,11 @@ module.exports = exec; * Executes the provided command once with the supplied arguments. * @param {string} cmd * @param {string[]} args - * @param {object} [options] - * @param {boolean} [options.ignoreExitCode] + * @param {ExecOptions} [options] + * + * @typedef ExecOptions + * @property {boolean} [ignoreExitCode] + * @property {CancelToken} [cancelToken] */ function exec(cmd, args, options = {}) { return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => { @@ -20,7 +24,13 @@ function exec(cmd, args, options = {}) { const subshellFlag = isWin ? "/c" : "-c"; const command = isWin ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`]; const ex = cp.spawn(isWin ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: "inherit", windowsVerbatimArguments: true }); + const subscription = options.cancelToken && options.cancelToken.subscribe(() => { + ex.kill("SIGINT"); + ex.kill("SIGTERM"); + reject(new CancelError()); + }); ex.on("exit", exitCode => { + subscription && subscription.unsubscribe(); if (exitCode === 0 || options.ignoreExitCode) { resolve({ exitCode }); } @@ -28,7 +38,10 @@ function exec(cmd, args, options = {}) { reject(new Error(`Process exited with code: ${exitCode}`)); } }); - ex.on("error", reject); + ex.on("error", error => { + subscription && subscription.unsubscribe(); + reject(error); + }); })); } diff --git a/scripts/build/options.js b/scripts/build/options.js index b69358f0f9874..e9e3bfb7b1bc6 100644 --- a/scripts/build/options.js +++ b/scripts/build/options.js @@ -4,7 +4,7 @@ const os = require("os"); /** @type {CommandLineOptions} */ module.exports = minimist(process.argv.slice(2), { - boolean: ["debug", "inspect", "light", "colors", "lint", "soft", "fix", "failed", "keepFailed"], + boolean: ["debug", "dirty", "inspect", "light", "colors", "lint", "lkg", "soft", "fix", "failed", "keepFailed"], string: ["browser", "tests", "host", "reporter", "stackTraceLimit", "timeout"], alias: { "b": "browser", @@ -33,17 +33,21 @@ module.exports = minimist(process.argv.slice(2), { fix: process.env.fix || process.env.f, workers: process.env.workerCount || os.cpus().length, failed: false, - keepFailed: false + keepFailed: false, + lkg: false, + dirty: false } }); /** * @typedef TypedOptions * @property {boolean} debug + * @property {boolean} dirty * @property {boolean} inspect * @property {boolean} light * @property {boolean} colors * @property {boolean} lint + * @property {boolean} lkg * @property {boolean} soft * @property {boolean} fix * @property {string} browser @@ -56,7 +60,7 @@ module.exports = minimist(process.argv.slice(2), { * @property {string|number} timeout * @property {boolean} failed * @property {boolean} keepFailed - * + * * @typedef {import("minimist").ParsedArgs & TypedOptions} CommandLineOptions */ void 0; \ No newline at end of file diff --git a/scripts/build/prepend.js b/scripts/build/prepend.js new file mode 100644 index 0000000000000..6e7b794e79bea --- /dev/null +++ b/scripts/build/prepend.js @@ -0,0 +1,66 @@ +// @ts-check +const stream = require("stream"); +const Vinyl = require("./vinyl"); +const ts = require("../../lib/typescript"); +const fs = require("fs"); +const { base64VLQFormatEncode } = require("./sourcemaps"); + +module.exports = exports = prepend; + +/** + * @param {string | ((file: Vinyl) => string)} data + */ +function prepend(data) { + return new stream.Transform({ + objectMode: true, + /** + * @param {string | Buffer | Vinyl} input + * @param {(error: Error, data?: any) => void} cb + */ + transform(input, _, cb) { + if (typeof input === "string" || Buffer.isBuffer(input)) return cb(new Error("Only Vinyl files are supported.")); + if (!input.isBuffer()) return cb(new Error("Streams not supported.")); + try { + const output = input.clone(); + const prependContent = typeof data === "function" ? data(input) : data; + output.contents = Buffer.concat([Buffer.from(prependContent, "utf8"), input.contents]); + if (input.sourceMap) { + if (typeof input.sourceMap === "string") input.sourceMap = /**@type {import("./sourcemaps").RawSourceMap}*/(JSON.parse(input.sourceMap)); + const lineStarts = /**@type {*}*/(ts).computeLineStarts(prependContent); + let prependMappings = ""; + for (let i = 1; i < lineStarts.length; i++) { + prependMappings += ";"; + } + const offset = prependContent.length - lineStarts[lineStarts.length - 1]; + if (offset > 0) { + prependMappings += base64VLQFormatEncode(offset) + ","; + } + output.sourceMap = { + version: input.sourceMap.version, + file: input.sourceMap.file, + sources: input.sourceMap.sources, + sourceRoot: input.sourceMap.sourceRoot, + mappings: prependMappings + input.sourceMap.mappings, + names: input.names, + sourcesContent: input.sourcesContent + }; + } + return cb(null, output); + } + catch (e) { + return cb(e); + } + } + }) +} +exports.prepend = prepend; + +/** + * @param {string | ((file: Vinyl) => string)} file + */ +function prependFile(file) { + const data = typeof file === "string" ? fs.readFileSync(file, "utf8") : + vinyl => fs.readFileSync(file(vinyl), "utf8"); + return prepend(data) +} +exports.file = prependFile; \ No newline at end of file diff --git a/scripts/build/project.js b/scripts/build/project.js index 35b500d749a9c..933f7c44c65fc 100644 --- a/scripts/build/project.js +++ b/scripts/build/project.js @@ -209,6 +209,27 @@ function flatten(projectSpec, flattenedProjectSpec, options = {}) { } exports.flatten = flatten; +/** + * Returns a Promise that resolves when all pending build tasks have completed + */ +function wait() { + return new Promise(resolve => { + if (compilationGulp.allDone()) { + resolve(); + } + else { + const onDone = () => { + compilationGulp.removeListener("onDone", onDone); + compilationGulp.removeListener("err", onDone); + resolve(); + }; + compilationGulp.on("stop", onDone); + compilationGulp.on("err", onDone); + } + }); +} +exports.wait = wait; + /** * Resolve a TypeScript specifier into a fully-qualified module specifier and any requisite dependencies. * @param {string} typescript An unresolved module specifier to a TypeScript version. diff --git a/scripts/build/sourcemaps.js b/scripts/build/sourcemaps.js new file mode 100644 index 0000000000000..66e488287b2b7 --- /dev/null +++ b/scripts/build/sourcemaps.js @@ -0,0 +1,143 @@ +// @ts-check +const path = require("path"); +const Vinyl = require("./vinyl"); +const convertMap = require("convert-source-map"); +const applySourceMap = require("vinyl-sourcemaps-apply"); +const through2 = require("through2"); + +/** + * @param {Vinyl} input + * @param {string | Buffer} contents + * @param {string | RawSourceMap} [sourceMap] + */ +function replaceContents(input, contents, sourceMap) { + const output = input.clone(); + output.contents = typeof contents === "string" ? Buffer.from(contents, "utf8") : contents; + if (input.sourceMap) { + output.sourceMap = typeof input.sourceMap === "string" ? /**@type {RawSourceMap}*/(JSON.parse(input.sourceMap)) : input.sourceMap; + if (typeof sourceMap === "string") { + sourceMap = /**@type {RawSourceMap}*/(JSON.parse(sourceMap)); + } + else if (sourceMap === undefined) { + const stringContents = typeof contents === "string" ? contents : contents.toString("utf8"); + const newSourceMapConverter = convertMap.fromSource(stringContents); + if (newSourceMapConverter) { + sourceMap = /**@type {RawSourceMap}*/(newSourceMapConverter.toObject()); + output.contents = new Buffer(convertMap.removeMapFileComments(stringContents), "utf8"); + } + } + if (sourceMap) { + const cwd = input.cwd || process.cwd(); + const base = input.base || cwd; + const sourceRoot = output.sourceMap.sourceRoot; + makeAbsoluteSourceMap(cwd, base, output.sourceMap); + makeAbsoluteSourceMap(cwd, base, sourceMap); + applySourceMap(output, sourceMap); + makeRelativeSourceMap(cwd, base, sourceRoot, output.sourceMap); + } + else { + output.sourceMap = undefined; + } + } + return output; +} +exports.replaceContents = replaceContents; + +function removeSourceMaps() { + return through2.obj((/**@type {Vinyl}*/file, _, cb) => { + if (file.sourceMap && file.isBuffer()) { + file.contents = Buffer.from(convertMap.removeMapFileComments(file.contents.toString("utf8")), "utf8"); + file.sourceMap = undefined; + } + cb(null, file); + }); +} +exports.removeSourceMaps = removeSourceMaps; + +/** + * @param {string | undefined} cwd + * @param {string | undefined} base + * @param {RawSourceMap} sourceMap + * + * @typedef RawSourceMap + * @property {string} version + * @property {string} file + * @property {string} [sourceRoot] + * @property {string[]} sources + * @property {string[]} [sourcesContent] + * @property {string} mappings + * @property {string[]} [names] + */ +function makeAbsoluteSourceMap(cwd = process.cwd(), base = "", sourceMap) { + const sourceRoot = sourceMap.sourceRoot || ""; + const resolvedBase = path.resolve(cwd, base); + const resolvedSourceRoot = path.resolve(resolvedBase, sourceRoot); + sourceMap.file = path.resolve(resolvedBase, sourceMap.file).replace(/\\/g, "/"); + sourceMap.sources = sourceMap.sources.map(source => path.resolve(resolvedSourceRoot, source).replace(/\\/g, "/")); + sourceMap.sourceRoot = ""; +} +exports.makeAbsoluteSourceMap = makeAbsoluteSourceMap; + +/** + * @param {string | undefined} cwd + * @param {string | undefined} base + * @param {string} sourceRoot + * @param {RawSourceMap} sourceMap + */ +function makeRelativeSourceMap(cwd = process.cwd(), base = "", sourceRoot, sourceMap) { + makeAbsoluteSourceMap(cwd, base, sourceMap); + const resolvedBase = path.resolve(cwd, base); + const resolvedSourceRoot = path.resolve(resolvedBase, sourceRoot); + sourceMap.file = path.relative(resolvedBase, sourceMap.file).replace(/\\/g, "/"); + sourceMap.sources = sourceMap.sources.map(source => path.relative(resolvedSourceRoot, source).replace(/\\/g, "/")); + sourceMap.sourceRoot = sourceRoot; +} +exports.makeRelativeSourceMap = makeRelativeSourceMap; + +/** + * @param {string} message + * @returns {never} + */ +function fail(message) { + throw new Error(message); +} + +/** + * @param {number} value + */ +function base64FormatEncode(value) { + return value < 0 ? fail("Invalid value") : + value < 26 ? 0x41 /*A*/ + value : + value < 52 ? 0x61 /*a*/ + value - 26 : + value < 62 ? 0x30 /*0*/ + value - 52 : + value === 62 ? 0x2B /*+*/ : + value === 63 ? 0x2F /*/*/ : + fail("Invalid value"); +} + +/** + * @param {number} value + */ +function base64VLQFormatEncode(value) { + if (value < 0) { + value = ((-value) << 1) + 1; + } + else { + value = value << 1; + } + + // Encode 5 bits at a time starting from least significant bits + let result = ""; + do { + let currentDigit = value & 31; // 11111 + value = value >> 5; + if (value > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + result += String.fromCharCode(base64FormatEncode(currentDigit)); + } while (value > 0); + + return result; +} +exports.base64VLQFormatEncode = base64VLQFormatEncode; \ No newline at end of file diff --git a/scripts/build/tests.js b/scripts/build/tests.js index 36615149d701c..d631f1e35acc5 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -1,4 +1,5 @@ // @ts-check +const gulp = require("./gulp"); const del = require("del"); const fs = require("fs"); const os = require("os"); @@ -6,13 +7,8 @@ const path = require("path"); const mkdirP = require("./mkdirp"); const cmdLineOptions = require("./options"); const exec = require("./exec"); -const runSequence = require("run-sequence"); -const finished = require("./finished"); const log = require("fancy-log"); // was `require("gulp-util").log (see https://github.com/gulpjs/gulp-util) - -const nodeModulesPathPrefix = path.resolve("./node_modules/.bin/"); -const isWin = /^win/.test(process.platform); -const mocha = path.join(nodeModulesPathPrefix, "mocha") + (isWin ? ".cmd" : ""); +const mochaJs = require.resolve("mocha/bin/_mocha"); exports.localBaseline = "tests/baselines/local/"; exports.refBaseline = "tests/baselines/reference/"; @@ -24,8 +20,10 @@ exports.localTest262Baseline = "internal/baselines/test262/local"; * @param {string} runJs * @param {string} defaultReporter * @param {boolean} runInParallel + * @param {boolean} watchMode + * @param {InstanceType} [cancelToken] */ -function runConsoleTests(runJs, defaultReporter, runInParallel) { +async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, cancelToken) { let testTimeout = cmdLineOptions.timeout; let tests = cmdLineOptions.tests; const lintFlag = cmdLineOptions.lint; @@ -36,112 +34,116 @@ function runConsoleTests(runJs, defaultReporter, runInParallel) { const stackTraceLimit = cmdLineOptions.stackTraceLimit; const testConfigFile = "test.config"; const failed = cmdLineOptions.failed; - const keepFailed = cmdLineOptions.keepFailed || failed; - return cleanTestDirs() - .then(() => { - if (fs.existsSync(testConfigFile)) { - fs.unlinkSync(testConfigFile); - } - - let workerCount, taskConfigsFolder; - if (runInParallel) { - // generate name to store task configuration files - const prefix = os.tmpdir() + "/ts-tests"; - let i = 1; - do { - taskConfigsFolder = prefix + i; - i++; - } while (fs.existsSync(taskConfigsFolder)); - fs.mkdirSync(taskConfigsFolder); - - workerCount = cmdLineOptions.workers; - } - - if (tests && tests.toLocaleLowerCase() === "rwc") { - testTimeout = 400000; - } - - if (tests || runners || light || testTimeout || taskConfigsFolder || keepFailed) { - writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, testTimeout, keepFailed); - } - - const colors = cmdLineOptions.colors; - const reporter = cmdLineOptions.reporter || defaultReporter; - - /** @type {string} */ - let host = "node"; - - /** @type {string[]} */ - let args = []; - - // 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) { - args.push("-R", "scripts/failed-tests"); - args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"'); - if (tests) { - args.push("-g", `"${tests}"`); - } - if (colors) { - args.push("--colors"); - } - else { - args.push("--no-colors"); - } - if (inspect) { - args.unshift("--inspect-brk"); - } - else if (debug) { - args.unshift("--debug-brk"); - } - else { - args.push("-t", "" + testTimeout); - } - args.push(runJs); - host = mocha; - } - else { - // run task to load all tests and partition them between workers - host = "node"; - args.push(runJs); - } - setNodeEnvToDevelopment(); - if (failed) { - return exec(host, ["scripts/run-failed-tests.js"].concat(args)); - } - else { - return exec(host, args); - } - }) - .then(({ exitCode }) => { - if (exitCode !== 0) return finish(undefined, exitCode); - if (lintFlag) return finished(runSequence("lint")).then(() => finish(), finish); - return finish(); - }, finish); - - /** - * @param {any=} error - * @param {number=} errorStatus - */ - function finish(error, errorStatus) { + const keepFailed = cmdLineOptions.keepFailed; + if (!cmdLineOptions.dirty) { + await cleanTestDirs(); + } + + if (fs.existsSync(testConfigFile)) { + fs.unlinkSync(testConfigFile); + } + + let workerCount, taskConfigsFolder; + if (runInParallel) { + // generate name to store task configuration files + const prefix = os.tmpdir() + "/ts-tests"; + let i = 1; + do { + taskConfigsFolder = prefix + i; + i++; + } while (fs.existsSync(taskConfigsFolder)); + fs.mkdirSync(taskConfigsFolder); + + workerCount = cmdLineOptions.workers; + } + + if (tests && tests.toLocaleLowerCase() === "rwc") { + testTimeout = 400000; + } + + if (tests || runners || light || testTimeout || taskConfigsFolder || keepFailed) { + writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, testTimeout, keepFailed); + } + + const colors = cmdLineOptions.colors; + const reporter = cmdLineOptions.reporter || defaultReporter; + + /** @type {string[]} */ + let args = []; + + // 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) { + args.push(failed ? "scripts/run-failed-tests.js" : mochaJs); + args.push("-R", "scripts/failed-tests"); + args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"'); + if (tests) { + args.push("-g", `"${tests}"`); + } + if (colors) { + args.push("--colors"); + } + else { + args.push("--no-colors"); + } + if (inspect) { + args.unshift("--inspect-brk"); + } + else if (debug) { + args.unshift("--debug-brk"); + } + else { + args.push("-t", "" + testTimeout); + } + args.push(runJs); + } + else { + // run task to load all tests and partition them between workers + args.push(runJs); + } + + /** @type {number | undefined} */ + let errorStatus; + + /** @type {Error | undefined} */ + let error; + + try { + setNodeEnvToDevelopment(); + const { exitCode } = await exec("node", args, { cancelToken }); + if (exitCode !== 0) { + errorStatus = exitCode; + error = new Error(`Process exited with status code ${errorStatus}.`); + } + else if (lintFlag) { + await new Promise((resolve, reject) => gulp.start(["lint"], error => error ? reject(error) : resolve())); + } + } + catch (e) { + errorStatus = undefined; + error = e; + } + finally { restoreSavedNodeEnv(); - return deleteTestConfig() - .then(deleteTemporaryProjectOutput) - .then(() => { - if (error !== undefined || errorStatus !== undefined) { - process.exit(typeof errorStatus === "number" ? errorStatus : 2); - } - }); } - function deleteTestConfig() { - return del("test.config"); + await del("test.config"); + await deleteTemporaryProjectOutput(); + + if (error !== undefined) { + if (watchMode) { + throw error; + } + else { + log.error(error); + process.exit(typeof errorStatus === "number" ? errorStatus : 2); + } } } exports.runConsoleTests = runConsoleTests; function cleanTestDirs() { - return del([exports.localBaseline, exports.localRwcBaseline,]) + return del([exports.localBaseline, exports.localRwcBaseline]) .then(() => mkdirP(exports.localRwcBaseline)) .then(() => mkdirP(exports.localBaseline)); } diff --git a/scripts/build/utils.js b/scripts/build/utils.js new file mode 100644 index 0000000000000..06f55d7288ac3 --- /dev/null +++ b/scripts/build/utils.js @@ -0,0 +1,27 @@ +// @ts-check +const fs = require("fs"); +const File = require("./vinyl"); +const { Readable } = require("stream"); + +/** + * @param {File} file + */ +function streamFromFile(file) { + return file.isBuffer() ? streamFromBuffer(file.contents) : + file.isStream() ? file.contents : + fs.createReadStream(file.path, { autoClose: true }); +} +exports.streamFromFile = streamFromFile; + +/** + * @param {Buffer} buffer + */ +function streamFromBuffer(buffer) { + return new Readable({ + read() { + this.push(buffer); + this.push(null); + } + }); +} +exports.streamFromBuffer = streamFromBuffer; \ No newline at end of file diff --git a/scripts/build/vinyl.d.ts b/scripts/build/vinyl.d.ts new file mode 100644 index 0000000000000..1dfb631499194 --- /dev/null +++ b/scripts/build/vinyl.d.ts @@ -0,0 +1,60 @@ +// NOTE: This makes it possible to correctly type vinyl Files under @ts-check. +export = File; + +declare class File { + constructor(options?: File.VinylOptions); + + cwd: string; + base: string; + path: string; + readonly history: ReadonlyArray; + contents: T; + relative: string; + dirname: string; + basename: string; + stem: string; + extname: string; + symlink: string | null; + stat: import("fs").Stats | null; + sourceMap?: import("./sourcemaps").RawSourceMap | string; + + [custom: string]: any; + + isBuffer(): this is T extends Buffer ? File : never; + isStream(): this is T extends NodeJS.ReadableStream ? File : never; + isNull(): this is T extends null ? File : never; + isDirectory(): this is T extends null ? File.Directory : never; + isSymbolic(): this is T extends null ? File.Symbolic : never; + clone(opts?: { contents?: boolean, deep?: boolean }): this; +} + +namespace File { + export interface VinylOptions { + cwd?: string; + base?: string; + path?: string; + history?: ReadonlyArray; + stat?: import("fs").Stats; + contents?: T; + sourceMap?: import("./sourcemaps").RawSourceMap | string; + [custom: string]: any; + } + + export type Contents = Buffer | NodeJS.ReadableStream | null; + export type File = import("./vinyl"); + export type NullFile = File; + export type BufferFile = File; + export type StreamFile = File; + + export interface Directory extends NullFile { + isNull(): true; + isDirectory(): true; + isSymbolic(): this is never; + } + + export interface Symbolic extends NullFile { + isNull(): true; + isDirectory(): this is never; + isSymbolic(): true; + } +} \ No newline at end of file diff --git a/scripts/build/vinyl.js b/scripts/build/vinyl.js new file mode 100644 index 0000000000000..6cf68f3cd26ce --- /dev/null +++ b/scripts/build/vinyl.js @@ -0,0 +1 @@ +module.exports = require("vinyl"); \ No newline at end of file diff --git a/scripts/createBenchmark.ts b/scripts/createBenchmark.ts index 659df53c9156a..6148d80bf2c23 100644 --- a/scripts/createBenchmark.ts +++ b/scripts/createBenchmark.ts @@ -32,7 +32,7 @@ sourceFiles.forEach(f=> { }); var compilerSoruces = `var compilerSources = ${JSON.stringify(rawCompilerSources) };`; -// .js code for the compiler, what we are actuallty testing +// .js code for the compiler, what we are actually testing var rawCompilerJavaScript = fs.readFileSync(path.join(tsBuildDir, "tsc.js")).toString(); rawCompilerJavaScript = rawCompilerJavaScript.replace("ts.executeCommandLine(ts.sys.args);", ""); diff --git a/scripts/failed-tests.js b/scripts/failed-tests.js index 9d54bb8bd02dc..46baa3201ec78 100644 --- a/scripts/failed-tests.js +++ b/scripts/failed-tests.js @@ -4,9 +4,11 @@ const path = require("path"); const fs = require("fs"); const os = require("os"); +const failingHookRegExp = /^(.*) "(before|after) (all|each)" hook$/; + /** * .failed-tests reporter - * + * * @typedef {Object} ReporterOptions * @property {string} [file] * @property {boolean} [keepFailed] @@ -15,7 +17,7 @@ const os = require("os"); */ class FailedTestsReporter extends Mocha.reporters.Base { /** - * @param {Mocha.Runner} runner + * @param {Mocha.Runner} runner * @param {{ reporterOptions?: ReporterOptions }} [options] */ constructor(runner, options) { @@ -49,35 +51,58 @@ class FailedTestsReporter extends Mocha.reporters.Base { /** @type {Mocha.Test[]} */ this.passes = []; - - /** @type {Mocha.Test[]} */ + + /** @type {(Mocha.Test)[]} */ this.failures = []; - + runner.on("pass", test => this.passes.push(test)); runner.on("fail", test => this.failures.push(test)); } /** - * @param {string} file - * @param {ReadonlyArray} passes - * @param {ReadonlyArray} failures - * @param {boolean} keepFailed - * @param {(err?: NodeJS.ErrnoException) => void} done + * @param {string} file + * @param {ReadonlyArray} passes + * @param {ReadonlyArray} failures + * @param {boolean} keepFailed + * @param {(err?: NodeJS.ErrnoException) => void} done */ static writeFailures(file, passes, failures, keepFailed, done) { const failingTests = new Set(fs.existsSync(file) ? readTests() : undefined); - if (failingTests.size > 0) { + const possiblyPassingSuites = /**@type {Set}*/(new Set()); + + // Remove tests that are now passing and track suites that are now + // possibly passing. + if (failingTests.size > 0 && !keepFailed) { for (const test of passes) { - const title = test.fullTitle().trim(); - if (title) failingTests.delete(title); + failingTests.delete(test.fullTitle().trim()); + possiblyPassingSuites.add(test.parent.fullTitle().trim()); } } + + // Add tests that are now failing. If a hook failed, track its + // containing suite as failing. If the suite for a test or hook was + // possibly passing then it is now definitely failing. for (const test of failures) { - const title = test.fullTitle().trim(); - if (title) failingTests.add(title); + const suiteTitle = test.parent.fullTitle().trim(); + if (test.type === "test") { + failingTests.add(test.fullTitle().trim()); + } + else { + failingTests.add(suiteTitle); + } + possiblyPassingSuites.delete(suiteTitle); } + + // Remove all definitely passing suites. + for (const suite of possiblyPassingSuites) { + failingTests.delete(suite); + } + if (failingTests.size > 0) { - const failed = Array.from(failingTests).join(os.EOL); + const failed = Array + .from(failingTests) + .sort() + .join(os.EOL); fs.writeFile(file, failed, "utf8", done); } else if (!keepFailed && fs.existsSync(file)) { @@ -96,7 +121,7 @@ class FailedTestsReporter extends Mocha.reporters.Base { } /** - * @param {number} failures + * @param {number} failures * @param {(failures: number) => void} [fn] */ done(failures, fn) { diff --git a/scripts/produceLKG.ts b/scripts/produceLKG.ts index a49b4fcbe4923..31a81f97a2c69 100644 --- a/scripts/produceLKG.ts +++ b/scripts/produceLKG.ts @@ -54,16 +54,17 @@ async function copyScriptOutputs() { await copyWithCopyright("cancellationToken.js"); await copyWithCopyright("tsc.release.js", "tsc.js"); await copyWithCopyright("tsserver.js"); - await copyWithCopyright("typescript.js"); - await copyWithCopyright("typescriptServices.js"); + await copyFromBuiltLocal("tsserverlibrary.js"); // copyright added by build + await copyFromBuiltLocal("typescript.js"); // copyright added by build + await copyFromBuiltLocal("typescriptServices.js"); // copyright added by build await copyWithCopyright("typingsInstaller.js"); await copyWithCopyright("watchGuard.js"); } async function copyDeclarationOutputs() { - await copyWithCopyright("tsserverlibrary.d.ts"); - await copyWithCopyright("typescript.d.ts"); - await copyWithCopyright("typescriptServices.d.ts"); + await copyFromBuiltLocal("tsserverlibrary.d.ts"); // copyright added by build + await copyFromBuiltLocal("typescript.d.ts"); // copyright added by build + await copyFromBuiltLocal("typescriptServices.d.ts"); // copyright added by build } async function writeGitAttributes() { diff --git a/scripts/run-failed-tests.js b/scripts/run-failed-tests.js index 876c4a34eec8d..bde06df11cb0e 100644 --- a/scripts/run-failed-tests.js +++ b/scripts/run-failed-tests.js @@ -69,7 +69,12 @@ const proc = spawn(process.execPath, args, { proc.on('exit', (code, signal) => { process.on('exit', () => { if (grepFile) { - fs.unlinkSync(grepFile); + try { + fs.unlinkSync(grepFile); + } + catch (e) { + if (e.code !== "ENOENT") throw e; + } } if (signal) { diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f835afff31fb5..4ab044d52bac3 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -26,7 +26,7 @@ namespace ts { return ModuleInstanceState.NonInstantiated; // 2. const enum declarations case SyntaxKind.EnumDeclaration: - if (isConst(node)) { + if (isEnumConst(node as EnumDeclaration)) { return ModuleInstanceState.ConstEnumOnly; } break; @@ -225,11 +225,11 @@ namespace ts { node.symbol = symbol; symbol.declarations = append(symbol.declarations, node); - if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) { + if (symbolFlags & (SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.Module | SymbolFlags.Variable) && !symbol.exports) { symbol.exports = createSymbolTable(); } - if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) { + if (symbolFlags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && !symbol.members) { symbol.members = createSymbolTable(); } @@ -306,7 +306,7 @@ namespace ts { } function getDisplayName(node: Declaration): string { - return isNamedDeclaration(node) ? declarationNameToString(node.name) : unescapeLeadingUnderscores(getDeclarationName(node)!); // TODO: GH#18217 + return isNamedDeclaration(node) ? declarationNameToString(node.name) : unescapeLeadingUnderscores(Debug.assertDefined(getDeclarationName(node))); } /** @@ -383,9 +383,11 @@ namespace ts { let message = symbol.flags & SymbolFlags.BlockScopedVariable ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; + let messageNeedsName = true; if (symbol.flags & SymbolFlags.Enum || includes & SymbolFlags.Enum) { message = Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; + messageNeedsName = false; } if (symbol.declarations && symbol.declarations.length) { @@ -394,6 +396,7 @@ namespace ts { // We'll know whether we have other default exports depending on if `symbol` already has a declaration list set. if (isDefaultExport) { message = Diagnostics.A_module_cannot_have_multiple_default_exports; + messageNeedsName = false; } else { // This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration. @@ -403,14 +406,16 @@ namespace ts { if (symbol.declarations && symbol.declarations.length && (node.kind === SyntaxKind.ExportAssignment && !(node).isExportEquals)) { message = Diagnostics.A_module_cannot_have_multiple_default_exports; + messageNeedsName = false; } } } - forEach(symbol.declarations, declaration => { - file.bindDiagnostics.push(createDiagnosticForNode(getNameOfDeclaration(declaration) || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(createDiagnosticForNode(getNameOfDeclaration(node) || node, message, getDisplayName(node))); + const addError = (decl: Declaration): void => { + file.bindDiagnostics.push(createDiagnosticForNode(getNameOfDeclaration(decl) || decl, message, messageNeedsName ? getDisplayName(decl) : undefined)); + }; + forEach(symbol.declarations, addError); + addError(node); symbol = createSymbol(SymbolFlags.None, name); } @@ -1211,7 +1216,7 @@ namespace ts { bind(node.statement); popActiveLabel(); if (!activeLabel.referenced && !options.allowUnusedLabels) { - errorOrSuggestionOnFirstToken(unusedLabelIsError(options), node, Diagnostics.Unused_label); + errorOrSuggestionOnNode(unusedLabelIsError(options), node.label, Diagnostics.Unused_label); } if (!node.statement || node.statement.kind !== SyntaxKind.DoStatement) { // do statement sets current flow inside bindDoStatement @@ -1913,14 +1918,30 @@ namespace ts { } } + function checkStrictModeLabeledStatement(node: LabeledStatement) { + // Grammar checking for labeledStatement + if (inStrictMode && options.target! >= ScriptTarget.ES2015) { + if (isDeclarationStatement(node.statement) || isVariableStatement(node.statement)) { + errorOnFirstToken(node.label, Diagnostics.A_label_is_not_allowed_here); + } + } + } + function errorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) { const span = getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } - function errorOrSuggestionOnFirstToken(isError: boolean, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) { - const span = getSpanOfTokenAtPosition(file, node.pos); - const diag = createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2); + function errorOrSuggestionOnNode(isError: boolean, node: Node, message: DiagnosticMessage): void { + errorOrSuggestionOnRange(isError, node, node, message); + } + + function errorOrSuggestionOnRange(isError: boolean, startNode: Node, endNode: Node, message: DiagnosticMessage): void { + addErrorOrSuggestionDiagnostic(isError, { pos: getTokenPosOfNode(startNode, file), end: endNode.end }, message); + } + + function addErrorOrSuggestionDiagnostic(isError: boolean, range: TextRange, message: DiagnosticMessage): void { + const diag = createFileDiagnostic(file, range.pos, range.end - range.pos, message); if (isError) { file.bindDiagnostics.push(diag); } @@ -2051,6 +2072,10 @@ namespace ts { if (isSpecialPropertyDeclaration(node as PropertyAccessExpression)) { bindSpecialPropertyDeclaration(node as PropertyAccessExpression); } + if (isInJavaScriptFile(node) && isModuleExportsPropertyAccessExpression(node as PropertyAccessExpression)) { + declareSymbol(container.locals!, /*parent*/ undefined, (node as PropertyAccessExpression).expression as Identifier, + SymbolFlags.FunctionScopedVariable | SymbolFlags.ModuleExports, SymbolFlags.FunctionScopedVariableExcludes); + } break; case SyntaxKind.BinaryExpression: const specialKind = getSpecialPropertyAssignmentKind(node as BinaryExpression); @@ -2092,6 +2117,8 @@ namespace ts { return checkStrictModePrefixUnaryExpression(node); case SyntaxKind.WithStatement: return checkStrictModeWithStatement(node); + case SyntaxKind.LabeledStatement: + return checkStrictModeLabeledStatement(node); case SyntaxKind.ThisType: seenThisKeyword = true; return; @@ -2611,7 +2638,7 @@ namespace ts { } function bindEnumDeclaration(node: EnumDeclaration) { - return isConst(node) + return isEnumConst(node) ? bindBlockScopedDeclaration(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes) : bindBlockScopedDeclaration(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); } @@ -2768,7 +2795,7 @@ namespace ts { // report error on instantiated modules or const-enums only modules if preserveConstEnums is set (node.kind === SyntaxKind.ModuleDeclaration && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === SyntaxKind.EnumDeclaration && (!isConstEnumDeclaration(node) || options.preserveConstEnums)); + (isEnumDeclaration(node) && (!isEnumConst(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; @@ -2792,7 +2819,7 @@ namespace ts { node.declarationList.declarations.some(d => !!d.initializer) ); - errorOrSuggestionOnFirstToken(isError, node, Diagnostics.Unreachable_code_detected); + eachUnreachableRange(node, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected)); } } } @@ -2800,6 +2827,38 @@ namespace ts { } } + function eachUnreachableRange(node: Node, cb: (start: Node, last: Node) => void): void { + if (isStatement(node) && isExecutableStatement(node) && isBlock(node.parent)) { + const { statements } = node.parent; + const slice = sliceAfter(statements, node); + getRangesWhere(slice, isExecutableStatement, (start, afterEnd) => cb(slice[start], slice[afterEnd - 1])); + } + else { + cb(node, node); + } + } + // As opposed to a pure declaration like an `interface` + function isExecutableStatement(s: Statement): boolean { + // Don't remove statements that can validly be used before they appear. + return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && + // `var x;` may declare a variable used above + !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & (NodeFlags.Let | NodeFlags.Const)) && s.declarationList.declarations.some(d => !d.initializer)); + } + + function isPurelyTypeDeclaration(s: Statement): boolean { + switch (s.kind) { + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.TypeAliasDeclaration: + return true; + case SyntaxKind.ModuleDeclaration: + return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated; + case SyntaxKind.EnumDeclaration: + return hasModifier(s, ModifierFlags.Const); + default: + return false; + } + } + /* @internal */ export function isExportsOrModuleExportsOrAlias(sourceFile: SourceFile, node: Expression): boolean { return isExportsIdentifier(node) || diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index eb23835ffc4a9..b476b80e4a566 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -76,7 +76,6 @@ namespace ts { undefinedSymbol.declarations = []; const argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments" as __String); const requireSymbol = createSymbol(SymbolFlags.Property, "require" as __String); - const moduleSymbol = createSymbol(SymbolFlags.Property, "module" as __String); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ let apparentArgumentCount: number | undefined; @@ -109,6 +108,7 @@ namespace ts { getDeclaredTypeOfSymbol, getPropertiesOfType, getPropertyOfType: (type, name) => getPropertyOfType(type, escapeLeadingUnderscores(name)), + getTypeOfPropertyOfType: (type, name) => getTypeOfPropertyOfType(type, escapeLeadingUnderscores(name)), getIndexInfoOfType, getSignaturesOfType, getIndexTypeOfType, @@ -182,7 +182,6 @@ namespace ts { writeTypePredicate: (predicate, enclosingDeclaration, flags, writer) => { return typePredicateToString(predicate, getParseTreeNode(enclosingDeclaration), flags, writer); }, - getSymbolDisplayBuilder, // TODO (weswigham): Remove once deprecation process is complete getAugmentedPropertiesOfType, getRootSymbols, getContextualType: nodeIn => { @@ -291,10 +290,11 @@ namespace ts { getNeverType: () => neverType, isSymbolAccessible, isArrayLikeType, + isTypeInvalidDueToUnionDiscriminant, getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: (node, type) => getSuggestionForNonexistentProperty(node, type), getSuggestionForNonexistentSymbol: (location, name, meaning) => getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning), - getSuggestionForNonexistentModule: (node, target) => getSuggestionForNonexistentModule(node, target), + getSuggestionForNonexistentExport: (node, target) => getSuggestionForNonexistentExport(node, target), getBaseConstraintOfType, getDefaultFromTypeParameter: type => type && type.flags & TypeFlags.TypeParameter ? getDefaultFromTypeParameter(type as TypeParameter) : undefined, resolveName(name, location, meaning, excludeGlobals) { @@ -335,8 +335,8 @@ namespace ts { } function addUnusedDiagnostics() { - checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), (kind, diag) => { - if (!unusedIsError(kind)) { + checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), (containingNode, kind, diag) => { + if (!containsParseError(containingNode) && !unusedIsError(kind)) { (diagnostics || (diagnostics = [])).push({ ...diag, category: DiagnosticCategory.Suggestion }); } }); @@ -423,6 +423,7 @@ namespace ts { const jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); const globals = createSymbolTable(); + let amalgamatedDuplicates: Map<{ firstFile: SourceFile, secondFile: SourceFile, firstFileInstances: Map<{ instances: Node[], blockScoped: boolean }>, secondFileInstances: Map<{ instances: Node[], blockScoped: boolean }> }> | undefined; const reverseMappedCache = createMap(); let ambientModulesCache: Symbol[] | undefined; /** @@ -596,7 +597,7 @@ namespace ts { const definitelyAssignableRelation = createMap(); const comparableRelation = createMap(); const identityRelation = createMap(); - const enumRelation = createMap(); + const enumRelation = createMap(); type TypeSystemEntity = Symbol | Type | Signature; @@ -605,7 +606,7 @@ namespace ts { ResolvedBaseConstructorType, DeclaredType, ResolvedReturnType, - ResolvedBaseConstraint, + ImmediateBaseConstraint, } const enum CheckMode { @@ -644,7 +645,8 @@ namespace ts { Local, Parameter, } - type AddUnusedDiagnostic = (type: UnusedKind, diagnostic: DiagnosticWithLocation) => void; + /** @param containingNode Node to check for parse error */ + type AddUnusedDiagnostic = (containingNode: Node, type: UnusedKind, diagnostic: DiagnosticWithLocation) => void; const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); @@ -655,145 +657,6 @@ namespace ts { return checker; - /** - * @deprecated - */ - function getSymbolDisplayBuilder(): SymbolDisplayBuilder { - return { - buildTypeDisplay(type, writer, enclosingDeclaration?, flags?) { - typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); - }, - buildSymbolDisplay(symbol, writer, enclosingDeclaration?, meaning?, flags = SymbolFormatFlags.None) { - symbolToString(symbol, enclosingDeclaration, meaning, flags | SymbolFormatFlags.AllowAnyNodeKind, emitTextWriterWrapper(writer)); - }, - buildSignatureDisplay(signature, writer, enclosing?, flags?, kind?) { - signatureToString(signature, enclosing, flags, kind, emitTextWriterWrapper(writer)); - }, - buildIndexSignatureDisplay(info, writer, kind, enclosing?, flags?) { - const sig = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, kind, enclosing, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors, writer); - const printer = createPrinter({ removeComments: true }); - printer.writeNode(EmitHint.Unspecified, sig, getSourceFileOfNode(getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildParameterDisplay(symbol, writer, enclosing?, flags?) { - const node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors, writer); - const printer = createPrinter({ removeComments: true }); - printer.writeNode(EmitHint.Unspecified, node!, getSourceFileOfNode(getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypeParameterDisplay(tp, writer, enclosing?, flags?) { - const node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.OmitParameterModifiers, writer); - const printer = createPrinter({ removeComments: true }); - printer.writeNode(EmitHint.Unspecified, node!, getSourceFileOfNode(getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - }, - buildTypePredicateDisplay(predicate, writer, enclosing?, flags?) { - typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - }, - buildTypeParameterDisplayFromSymbol(symbol, writer, enclosing?, flags?) { - const nodes = nodeBuilder.symbolToTypeParameterDeclarations(symbol, enclosing, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors, writer); - const printer = createPrinter({ removeComments: true }); - printer.writeList(ListFormat.TypeParameters, nodes, getSourceFileOfNode(getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosing?, originalFlags?) { - const printer = createPrinter({ removeComments: true }); - const flags = NodeBuilderFlags.OmitParameterModifiers | NodeBuilderFlags.IgnoreErrors | toNodeBuilderFlags(originalFlags); - const thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)!] : []; // TODO: GH#18217 - const params = createNodeArray([...thisParameterArray, ...map(parameters, param => nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags)!)]); // TODO: GH#18217 - printer.writeList(ListFormat.CallExpressionArguments, params, getSourceFileOfNode(getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosing?, flags?) { - const printer = createPrinter({ removeComments: true }); - const args = createNodeArray(map(typeParameters, p => nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags))!)); // TODO: GH#18217 - printer.writeList(ListFormat.TypeParameters, args, getSourceFileOfNode(getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); - }, - buildReturnTypeDisplay(signature, writer, enclosing?, flags?) { - writer.writePunctuation(":"); - writer.writeSpace(" "); - const predicate = getTypePredicateOfSignature(signature); - if (predicate) { - return typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); - } - const node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors, writer); - const printer = createPrinter({ removeComments: true }); - printer.writeNode(EmitHint.Unspecified, node!, getSourceFileOfNode(getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 - } - }; - - function emitTextWriterWrapper(underlying: SymbolWriter): EmitTextWriter { - return { - write: noop, - writeTextOfNode: noop, - writeLine: noop, - increaseIndent() { - return underlying.increaseIndent(); - }, - decreaseIndent() { - return underlying.decreaseIndent(); - }, - getText() { - return ""; - }, - rawWrite: noop, - writeLiteral(s) { - return underlying.writeStringLiteral(s); - }, - getTextPos() { - return 0; - }, - getLine() { - return 0; - }, - getColumn() { - return 0; - }, - getIndent() { - return 0; - }, - isAtStartOfLine() { - return false; - }, - clear() { - return underlying.clear(); - }, - - writeKeyword(text) { - return underlying.writeKeyword(text); - }, - writeOperator(text) { - return underlying.writeOperator(text); - }, - writePunctuation(text) { - return underlying.writePunctuation(text); - }, - writeSpace(text) { - return underlying.writeSpace(text); - }, - writeStringLiteral(text) { - return underlying.writeStringLiteral(text); - }, - writeParameter(text) { - return underlying.writeParameter(text); - }, - writeProperty(text) { - return underlying.writeProperty(text); - }, - writeSymbol(text, symbol) { - return underlying.writeSymbol(text, symbol); - }, - trackSymbol(symbol, enclosing?, meaning?) { - return underlying.trackSymbol && underlying.trackSymbol(symbol, enclosing, meaning); - }, - reportInaccessibleThisError() { - return underlying.reportInaccessibleThisError && underlying.reportInaccessibleThisError(); - }, - reportPrivateInBaseOfClassExpression(name) { - return underlying.reportPrivateInBaseOfClassExpression && underlying.reportPrivateInBaseOfClassExpression(name); - }, - reportInaccessibleUniqueSymbolError() { - return underlying.reportInaccessibleUniqueSymbolError && underlying.reportInaccessibleUniqueSymbolError(); - } - }; - } - } - function getJsxNamespace(location: Node | undefined): __String { if (location) { const file = getSourceFileOfNode(location); @@ -833,6 +696,28 @@ namespace ts { return emitResolver; } + function lookupOrIssueError(location: Node | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic { + const diagnostic = location + ? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) + : createCompilerDiagnostic(message, arg0, arg1, arg2, arg3); + const existing = diagnostics.lookup(diagnostic); + if (existing) { + return existing; + } + else { + diagnostics.add(diagnostic); + return diagnostic; + } + } + + function addRelatedInfo(diagnostic: Diagnostic, ...relatedInformation: [DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]]) { + if (!diagnostic.relatedInformation) { + diagnostic.relatedInformation = []; + } + diagnostic.relatedInformation.push(...relatedInformation); + return diagnostic; + } + function error(location: Node | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic { const diagnostic = location ? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) @@ -943,23 +828,63 @@ namespace ts { error(getNameOfDeclaration(source.declarations[0]), Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { - const message = target.flags & SymbolFlags.Enum || source.flags & SymbolFlags.Enum + const isEitherEnum = !!(target.flags & SymbolFlags.Enum || source.flags & SymbolFlags.Enum); + const isEitherBlockScoped = !!(target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable); + const message = isEitherEnum ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations - : target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable + : isEitherBlockScoped ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; - forEach(source.declarations, node => { - const errorNode = (getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? getOuterNameOfJsInitializer(node) : getNameOfDeclaration(node)) || node; - error(errorNode, message, symbolToString(source)); - }); - forEach(target.declarations, node => { - const errorNode = (getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? getOuterNameOfJsInitializer(node) : getNameOfDeclaration(node)) || node; - error(errorNode, message, symbolToString(source)); - }); + const sourceSymbolFile = source.declarations && getSourceFileOfNode(source.declarations[0]); + const targetSymbolFile = target.declarations && getSourceFileOfNode(target.declarations[0]); + + // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch + if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { + const firstFile = comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === Comparison.LessThan ? sourceSymbolFile : targetSymbolFile; + const secondFile = firstFile === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; + const cacheKey = `${firstFile.path}|${secondFile.path}`; + const existing = amalgamatedDuplicates.get(cacheKey) || { firstFile, secondFile, firstFileInstances: createMap(), secondFileInstances: createMap() }; + const symbolName = symbolToString(source); + const firstInstanceList = existing.firstFileInstances.get(symbolName) || { instances: [], blockScoped: isEitherBlockScoped }; + const secondInstanceList = existing.secondFileInstances.get(symbolName) || { instances: [], blockScoped: isEitherBlockScoped }; + + forEach(source.declarations, node => { + const errorNode = (getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? getOuterNameOfJsInitializer(node) : getNameOfDeclaration(node)) || node; + const targetList = sourceSymbolFile === firstFile ? firstInstanceList : secondInstanceList; + targetList.instances.push(errorNode); + }); + forEach(target.declarations, node => { + const errorNode = (getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? getOuterNameOfJsInitializer(node) : getNameOfDeclaration(node)) || node; + const targetList = targetSymbolFile === firstFile ? firstInstanceList : secondInstanceList; + targetList.instances.push(errorNode); + }); + + existing.firstFileInstances.set(symbolName, firstInstanceList); + existing.secondFileInstances.set(symbolName, secondInstanceList); + amalgamatedDuplicates.set(cacheKey, existing); + return target; + } + const symbolName = symbolToString(source); + addDuplicateDeclarationErrorsForSymbols(source, message, symbolName, target); + addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source); } return target; } + function addDuplicateDeclarationErrorsForSymbols(target: Symbol, message: DiagnosticMessage, symbolName: string, source: Symbol) { + forEach(target.declarations, node => { + const errorNode = (getJavascriptInitializer(node, /*isPrototypeAssignment*/ false) ? getOuterNameOfJsInitializer(node) : getNameOfDeclaration(node)) || node; + addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations && source.declarations[0]); + }); + } + + function addDuplicateDeclarationError(errorNode: Node, message: DiagnosticMessage, symbolName: string, relatedNode: Node | undefined) { + const err = lookupOrIssueError(errorNode, message, symbolName); + if (relatedNode && length(err.relatedInformation) < 5) { + addRelatedInfo(err, !length(err.relatedInformation) ? createDiagnosticForNode(relatedNode, Diagnostics._0_was_also_declared_here, symbolName) : createDiagnosticForNode(relatedNode, Diagnostics.and_here)); + } + } + function combineSymbolTables(first: SymbolTable | undefined, second: SymbolTable | undefined): SymbolTable | undefined { if (!hasEntries(first)) return second; if (!hasEntries(second)) return first; @@ -1134,6 +1059,7 @@ namespace ts { // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) + // 2. inside a jsdoc comment if (usage.parent.kind === SyntaxKind.ExportSpecifier || (usage.parent.kind === SyntaxKind.ExportAssignment && (usage.parent as ExportAssignment).isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; @@ -1144,7 +1070,7 @@ namespace ts { } const container = getEnclosingBlockScopeContainer(declaration); - return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & NodeFlags.JSDoc) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration: VariableDeclaration, usage: Node): boolean { const container = getEnclosingBlockScopeContainer(declaration); @@ -1495,10 +1421,6 @@ namespace ts { if (isRequireCall(originalLocation.parent, /*checkArgumentIsStringLiteralLike*/ false)) { return requireSymbol; } - if (isIdentifier(originalLocation) && isPropertyAccessExpression(originalLocation.parent) && - originalLocation.escapedText === "module" && originalLocation.parent.name.escapedText === "exports") { - return moduleSymbol; - } } } if (!result) { @@ -1509,11 +1431,18 @@ namespace ts { !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) { - let suggestion: string | undefined; + let suggestion: Symbol | undefined; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { - suggestion = getSuggestionForNonexistentSymbol(originalLocation, name, meaning); + suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); if (suggestion) { - error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg!), suggestion); + const suggestionName = symbolToString(suggestion); + const diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg!), suggestionName); + if (suggestion.valueDeclaration) { + addRelatedInfo( + diagnostic, + createDiagnosticForNode(suggestion.valueDeclaration, Diagnostics._0_is_declared_here, suggestionName) + ); + } } } if (!suggestion) { @@ -1732,14 +1661,25 @@ namespace ts { if (declaration === undefined) return Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & NodeFlags.Ambient) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + let diagnosticMessage; + const declarationName = declarationNameToString(getNameOfDeclaration(declaration)); if (result.flags & SymbolFlags.BlockScopedVariable) { - error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } else if (result.flags & SymbolFlags.Class) { - error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName); } else if (result.flags & SymbolFlags.RegularEnum) { - error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationNameToString(getNameOfDeclaration(declaration))); + diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName); + } + else { + Debug.assert(!!(result.flags & SymbolFlags.ConstEnum)); + } + + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, + createDiagnosticForNode(declaration, Diagnostics._0_is_declared_here, declarationName) + ); } } } @@ -1930,9 +1870,15 @@ namespace ts { if (!symbol) { const moduleName = getFullyQualifiedName(moduleSymbol); const declarationName = declarationNameToString(name); - const suggestion = getSuggestionForNonexistentModule(name, targetSymbol); + const suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol); if (suggestion !== undefined) { - error(name, Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2, moduleName, declarationName, suggestion); + const suggestionName = symbolToString(suggestion); + const diagnostic = error(name, Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2, moduleName, declarationName, suggestionName); + if (suggestion.valueDeclaration) { + addRelatedInfo(diagnostic, + createDiagnosticForNode(suggestion.valueDeclaration, Diagnostics._0_is_declared_here, suggestionName) + ); + } } else { error(name, Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -2332,7 +2278,7 @@ namespace ts { function resolveESModuleSymbol(moduleSymbol: Symbol | undefined, referencingLocation: Node, dontResolveAlias: boolean): Symbol | undefined { const symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) { + if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable)) && !getDeclarationOfKind(symbol, SyntaxKind.SourceFile)) { error(referencingLocation, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol!)); return symbol; } @@ -2459,7 +2405,7 @@ namespace ts { function getExportsOfModuleWorker(moduleSymbol: Symbol): SymbolTable { const visitedSymbols: Symbol[] = []; - // A module defined by an 'export=' consists on one export that needs to be resolved + // A module defined by an 'export=' consists of one export that needs to be resolved moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || emptySymbols; @@ -2467,12 +2413,12 @@ namespace ts { // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error. function visit(symbol: Symbol | undefined): SymbolTable | undefined { - if (!(symbol && symbol.flags & SymbolFlags.HasExports && pushIfUnique(visitedSymbols, symbol))) { + if (!(symbol && symbol.exports && pushIfUnique(visitedSymbols, symbol))) { return; } - const symbols = cloneMap(symbol.exports!); + const symbols = cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - const exportStars = symbol.exports!.get(InternalSymbolName.ExportStar); + const exportStars = symbol.exports.get(InternalSymbolName.ExportStar); if (exportStars) { const nestedSymbols = createSymbolTable(); const lookupTable = createMap() as ExportCollisionTrackerTable; @@ -2527,17 +2473,26 @@ namespace ts { * Attempts to find the symbol corresponding to the container a symbol is in - usually this * is just its' `.parent`, but for locals, this value is `undefined` */ - function getContainerOfSymbol(symbol: Symbol): Symbol | undefined { + function getContainersOfSymbol(symbol: Symbol, enclosingDeclaration: Node | undefined): Symbol[] | undefined { const container = getParentOfSymbol(symbol); if (container) { - return container; + const additionalContainers = mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); + if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, SymbolFlags.Namespace, /*externalOnly*/ false)) { + return concatenate([container], additionalContainers); // This order expresses a preference for the real container if it is in scope + } + return append(additionalContainers, container); } - const candidate = forEach(symbol.declarations, d => !isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined); - if (!candidate) { + const candidates = mapDefined(symbol.declarations, d => !isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined); + if (!length(candidates)) { return undefined; } - const alias = getAliasForSymbolInContainer(candidate, symbol); - return alias ? candidate : undefined; + return mapDefined(candidates, candidate => getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined); + + function fileSymbolIfFileSymbolExportEqualsContainer(d: Declaration) { + const fileSymbol = getExternalModuleContainer(d); + const exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get(InternalSymbolName.ExportEquals); + return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + } } function getAliasForSymbolInContainer(container: Symbol, symbol: Symbol) { @@ -2566,9 +2521,7 @@ namespace ts { function getExportSymbolOfValueSymbolIfExported(symbol: Symbol): Symbol; function getExportSymbolOfValueSymbolIfExported(symbol: Symbol | undefined): Symbol | undefined; function getExportSymbolOfValueSymbolIfExported(symbol: Symbol | undefined): Symbol | undefined { - return symbol && (symbol.flags & SymbolFlags.ExportValue) !== 0 - ? getMergedSymbol(symbol.exportSymbol) - : symbol; + return getMergedSymbol(symbol && (symbol.flags & SymbolFlags.ExportValue) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol: Symbol): boolean { @@ -2608,6 +2561,12 @@ namespace ts { const type = createType(TypeFlags.Object); type.objectFlags = objectFlags; type.symbol = symbol!; + type.members = undefined; + type.properties = undefined; + type.callSignatures = undefined; + type.constructSignatures = undefined; + type.stringIndexInfo = undefined; + type.numberIndexInfo = undefined; return type; } @@ -2629,11 +2588,8 @@ namespace ts { function getNamedMembers(members: SymbolTable): Symbol[] { let result: Symbol[] | undefined; members.forEach((symbol, id) => { - if (!isReservedMemberName(id)) { - if (!result) result = []; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + (result || (result = [])).push(symbol); } }); return result || emptyArray; @@ -2641,11 +2597,11 @@ namespace ts { function setStructuredTypeMembers(type: StructuredType, members: SymbolTable, callSignatures: ReadonlyArray, constructSignatures: ReadonlyArray, stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): ResolvedType { (type).members = members; - (type).properties = getNamedMembers(members); + (type).properties = members === emptySymbols ? emptyArray : getNamedMembers(members); (type).callSignatures = callSignatures; (type).constructSignatures = constructSignatures; - if (stringIndexInfo) (type).stringIndexInfo = stringIndexInfo; - if (numberIndexInfo) (type).numberIndexInfo = numberIndexInfo; + (type).stringIndexInfo = stringIndexInfo; + (type).numberIndexInfo = numberIndexInfo; return type; } @@ -2820,6 +2776,56 @@ namespace ts { return access.accessibility === SymbolAccessibility.Accessible; } + function isAnySymbolAccessible(symbols: Symbol[] | undefined, enclosingDeclaration: Node, initialSymbol: Symbol, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult | undefined { + if (!length(symbols)) return; + + let hadAccessibleChain: Symbol | undefined; + for (const symbol of symbols!) { + // Symbol is accessible if it by itself is accessible + const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false); + if (accessibleSymbolChain) { + hadAccessibleChain = symbol; + const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible); + if (hasAccessibleDeclarations) { + return hasAccessibleDeclarations; + } + } + else { + if (some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + // Any meaning of a module symbol is always accessible via an `import` type + return { + accessibility: SymbolAccessibility.Accessible + }; + } + } + + // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible. + // It could be a qualified symbol and hence verify the path + // e.g.: + // module m { + // export class c { + // } + // } + // const x: typeof m.c + // In the above example when we start with checking if typeof m.c symbol is accessible, + // we are going to see if c can be accessed in scope directly. + // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible + // It is accessible if the parent m is accessible because then m.c can be accessed through qualification + const parentResult = isAnySymbolAccessible(getContainersOfSymbol(symbol, enclosingDeclaration), enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible); + if (parentResult) { + return parentResult; + } + } + + if (hadAccessibleChain) { + return { + accessibility: SymbolAccessibility.NotAccessible, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, SymbolFlags.Namespace) : undefined, + }; + } + } + /** * Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested * @@ -2830,57 +2836,21 @@ namespace ts { */ function isSymbolAccessible(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult { if (symbol && enclosingDeclaration) { - const initialSymbol = symbol; - let meaningToLook = meaning; - while (symbol) { - // Symbol is accessible if it by itself is accessible - const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); - if (accessibleSymbolChain) { - const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible); - if (!hasAccessibleDeclarations) { - return { - accessibility: SymbolAccessibility.NotAccessible, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, SymbolFlags.Namespace) : undefined, - }; - } - return hasAccessibleDeclarations; - } - else { - if (some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - // Any meaning of a module symbol is always accessible via an `import` type - return { - accessibility: SymbolAccessibility.Accessible - }; - } - } - - // If we haven't got the accessible symbol, it doesn't mean the symbol is actually inaccessible. - // It could be a qualified symbol and hence verify the path - // e.g.: - // module m { - // export class c { - // } - // } - // const x: typeof m.c - // In the above example when we start with checking if typeof m.c symbol is accessible, - // we are going to see if c can be accessed in scope directly. - // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible - // It is accessible if the parent m is accessible because then m.c can be accessed through qualification - meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getContainerOfSymbol(symbol); + const result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible); + if (result) { + return result; } // This could be a symbol that is not exported in the external module // or it could be a symbol from different external module that is not aliased and hence cannot be named - const symbolExternalModule = forEach(initialSymbol.declarations, getExternalModuleContainer); + const symbolExternalModule = forEach(symbol.declarations, getExternalModuleContainer); if (symbolExternalModule) { const enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { accessibility: SymbolAccessibility.CannotBeNamed, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule) }; } @@ -2889,16 +2859,16 @@ namespace ts { // Just a local name that is not accessible return { accessibility: SymbolAccessibility.NotAccessible, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } return { accessibility: SymbolAccessibility.Accessible }; + } - function getExternalModuleContainer(declaration: Node) { - const node = findAncestor(declaration, hasExternalModuleSymbol); - return node && getSymbolOfNode(node); - } + function getExternalModuleContainer(declaration: Node) { + const node = findAncestor(declaration, hasExternalModuleSymbol); + return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration: Node) { @@ -3031,7 +3001,8 @@ namespace ts { } function typeToString(type: Type, enclosingDeclaration?: Node, flags: TypeFormatFlags = TypeFormatFlags.AllowUniqueESSymbolType | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope, writer: EmitTextWriter = createTextWriter("")): string { - const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors, writer); + const noTruncation = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation; + const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | (noTruncation ? NodeBuilderFlags.NoTruncation : 0), writer); if (typeNode === undefined) return Debug.fail("should always get typenode"); const options = { removeComments: true }; const printer = createPrinter(options); @@ -3039,7 +3010,7 @@ namespace ts { printer.writeNode(EmitHint.Unspecified, typeNode, /*sourceFile*/ sourceFile, writer); const result = writer.getText(); - const maxLength = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation ? undefined : 100; + const maxLength = noTruncation ? undefined : defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { return result.substr(0, maxLength - "...".length) + "..."; } @@ -3078,12 +3049,18 @@ namespace ts { tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: noop }, encounteredError: false, visitedSymbols: undefined, - inferTypeParameters: undefined + inferTypeParameters: undefined, + approximateLength: 0 }; const resultingNode = cb(context); return context.encounteredError ? undefined : resultingNode; } + function checkTruncationLength(context: NodeBuilderContext): boolean { + if (context.truncating) return context.truncating; + return context.truncating = !(context.flags & NodeBuilderFlags.NoTruncation) && context.approximateLength > defaultMaximumTruncationLength; + } + function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); @@ -3097,66 +3074,83 @@ namespace ts { } if (type.flags & TypeFlags.Any) { + context.approximateLength += 3; return createKeywordTypeNode(SyntaxKind.AnyKeyword); } if (type.flags & TypeFlags.Unknown) { return createKeywordTypeNode(SyntaxKind.UnknownKeyword); } if (type.flags & TypeFlags.String) { + context.approximateLength += 6; return createKeywordTypeNode(SyntaxKind.StringKeyword); } if (type.flags & TypeFlags.Number) { + context.approximateLength += 6; return createKeywordTypeNode(SyntaxKind.NumberKeyword); } if (type.flags & TypeFlags.Boolean) { + context.approximateLength += 7; return createKeywordTypeNode(SyntaxKind.BooleanKeyword); } if (type.flags & TypeFlags.EnumLiteral && !(type.flags & TypeFlags.Union)) { const parentSymbol = getParentOfSymbol(type.symbol)!; const parentName = symbolToName(parentSymbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false); const enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : createQualifiedName(parentName, symbolName(type.symbol)); + context.approximateLength += symbolName(type.symbol).length; return createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); } if (type.flags & TypeFlags.EnumLike) { const name = symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false); + context.approximateLength += symbolName(type.symbol).length; return createTypeReferenceNode(name, /*typeArguments*/ undefined); } - if (type.flags & (TypeFlags.StringLiteral)) { + if (type.flags & TypeFlags.StringLiteral) { + context.approximateLength += ((type).value.length + 2); return createLiteralTypeNode(setEmitFlags(createLiteral((type).value), EmitFlags.NoAsciiEscaping)); } - if (type.flags & (TypeFlags.NumberLiteral)) { + if (type.flags & TypeFlags.NumberLiteral) { + context.approximateLength += (("" + (type).value).length); return createLiteralTypeNode((createLiteral((type).value))); } if (type.flags & TypeFlags.BooleanLiteral) { + context.approximateLength += (type).intrinsicName.length; return (type).intrinsicName === "true" ? createTrue() : createFalse(); } if (type.flags & TypeFlags.UniqueESSymbol) { if (!(context.flags & NodeBuilderFlags.AllowUniqueESSymbolType)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration!)) { + context.approximateLength += 6; return symbolToTypeNode(type.symbol, context, SymbolFlags.Value); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } + context.approximateLength += 13; return createTypeOperatorNode(SyntaxKind.UniqueKeyword, createKeywordTypeNode(SyntaxKind.SymbolKeyword)); } if (type.flags & TypeFlags.Void) { + context.approximateLength += 4; return createKeywordTypeNode(SyntaxKind.VoidKeyword); } if (type.flags & TypeFlags.Undefined) { + context.approximateLength += 9; return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); } if (type.flags & TypeFlags.Null) { + context.approximateLength += 4; return createKeywordTypeNode(SyntaxKind.NullKeyword); } if (type.flags & TypeFlags.Never) { + context.approximateLength += 5; return createKeywordTypeNode(SyntaxKind.NeverKeyword); } if (type.flags & TypeFlags.ESSymbol) { + context.approximateLength += 6; return createKeywordTypeNode(SyntaxKind.SymbolKeyword); } if (type.flags & TypeFlags.NonPrimitive) { + context.approximateLength += 6; return createKeywordTypeNode(SyntaxKind.ObjectKeyword); } if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { @@ -3168,6 +3162,7 @@ namespace ts { context.tracker.reportInaccessibleThisError(); } } + context.approximateLength += 4; return createThis(); } @@ -3179,6 +3174,7 @@ namespace ts { } if (type.flags & TypeFlags.TypeParameter || objectFlags & ObjectFlags.ClassOrInterface) { if (type.flags & TypeFlags.TypeParameter && contains(context.inferTypeParameters, type)) { + context.approximateLength += (symbolName(type.symbol).length + 6); return createInferTypeNode(typeParameterToDeclarationWithConstraint(type as TypeParameter, context, /*constraintNode*/ undefined)); } if (context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams && @@ -3187,7 +3183,9 @@ namespace ts { isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { - return createTypeReferenceNode(getGeneratedNameForNode((type.symbol.declarations[0] as TypeParameterDeclaration).name, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.ReservedInNestedScopes), /*typeArguments*/ undefined); + const name = (type.symbol.declarations[0] as TypeParameterDeclaration).name; + context.approximateLength += idText(name).length; + return createTypeReferenceNode(getGeneratedNameForNode(name, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.ReservedInNestedScopes), /*typeArguments*/ undefined); } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol @@ -3201,7 +3199,7 @@ namespace ts { } if (type.flags & (TypeFlags.Union | TypeFlags.Intersection)) { const types = type.flags & TypeFlags.Union ? formatUnionTypes((type).types) : (type).types; - const typeNodes = mapToTypeNodes(types, context); + const typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { const unionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode(type.flags & TypeFlags.Union ? SyntaxKind.UnionType : SyntaxKind.IntersectionType, typeNodes); return unionOrIntersectionTypeNode; @@ -3220,12 +3218,14 @@ namespace ts { } if (type.flags & TypeFlags.Index) { const indexedType = (type).type; + context.approximateLength += 6; const indexTypeNode = typeToTypeNodeHelper(indexedType, context); return createTypeOperatorNode(indexTypeNode); } if (type.flags & TypeFlags.IndexedAccess) { const objectTypeNode = typeToTypeNodeHelper((type).objectType, context); const indexTypeNode = typeToTypeNodeHelper((type).indexType, context); + context.approximateLength += 2; return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } if (type.flags & TypeFlags.Conditional) { @@ -3236,6 +3236,7 @@ namespace ts { context.inferTypeParameters = saveInferTypeParameters; const trueTypeNode = typeToTypeNodeHelper(getTrueTypeFromConditionalType(type), context); const falseTypeNode = typeToTypeNodeHelper(getFalseTypeFromConditionalType(type), context); + context.approximateLength += 15; return createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } if (type.flags & TypeFlags.Substitution) { @@ -3260,6 +3261,7 @@ namespace ts { const typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); const templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context); const mappedTypeNode = createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + context.approximateLength += 10; return setEmitFlags(mappedTypeNode, EmitFlags.SingleLine); } @@ -3288,6 +3290,7 @@ namespace ts { return symbolToTypeNode(typeAlias, context, SymbolFlags.Type); } else { + context.approximateLength += 3; return createKeywordTypeNode(SyntaxKind.AnyKeyword); } } @@ -3332,6 +3335,7 @@ namespace ts { const resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + context.approximateLength += 2; return setEmitFlags(createTypeLiteralNode(/*members*/ undefined), EmitFlags.SingleLine); } @@ -3354,6 +3358,7 @@ namespace ts { const members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; const typeLiteralNode = createTypeLiteralNode(members); + context.approximateLength += 2; return setEmitFlags(typeLiteralNode, (context.flags & NodeBuilderFlags.MultilineObjectLiterals) ? 0 : EmitFlags.SingleLine); } @@ -3475,6 +3480,9 @@ namespace ts { } function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] | undefined { + if (checkTruncationLength(context)) { + return [createPropertySignature(/*modifiers*/ undefined, "...", /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)]; + } const typeElements: TypeElement[] = []; for (const signature of resolvedType.callSignatures) { typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.CallSignature, context)); @@ -3497,7 +3505,9 @@ namespace ts { return typeElements; } + let i = 0; for (const propertySymbol of properties) { + i++; if (context.flags & NodeBuilderFlags.WriteClassExpressionAsTypeLiteral) { if (propertySymbol.flags & SymbolFlags.Prototype) { continue; @@ -3506,65 +3516,102 @@ namespace ts { context.tracker.reportPrivateInBaseOfClassExpression(unescapeLeadingUnderscores(propertySymbol.escapedName)); } } - const propertyType = getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped && context.flags & NodeBuilderFlags.InReverseMappedType ? - anyType : getTypeOfSymbol(propertySymbol); - const saveEnclosingDeclaration = context.enclosingDeclaration; - context.enclosingDeclaration = undefined; - if (getCheckFlags(propertySymbol) & CheckFlags.Late) { - const decl = first(propertySymbol.declarations); - if (context.tracker.trackSymbol && hasLateBindableName(decl)) { - // get symbol of the first identifier of the entityName - const firstIdentifier = getFirstIdentifier(decl.name.expression); - const name = resolveName(firstIdentifier, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (name) { - context.tracker.trackSymbol(name, saveEnclosingDeclaration, SymbolFlags.Value); - } - } + if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { + typeElements.push(createPropertySignature(/*modifiers*/ undefined, `... ${properties.length - i} more ...`, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); + addPropertyToElementList(properties[properties.length - 1], context, typeElements); + break; } - const propertyName = symbolToName(propertySymbol, context, SymbolFlags.Value, /*expectsIdentifier*/ true); - context.enclosingDeclaration = saveEnclosingDeclaration; - const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined; - if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { - const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); - for (const signature of signatures) { - const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature, context); - methodDeclaration.name = propertyName; - methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); - } + addPropertyToElementList(propertySymbol, context, typeElements); + + } + return typeElements.length ? typeElements : undefined; + } + } + + function addPropertyToElementList(propertySymbol: Symbol, context: NodeBuilderContext, typeElements: TypeElement[]) { + const propertyType = getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped && context.flags & NodeBuilderFlags.InReverseMappedType ? + anyType : getTypeOfSymbol(propertySymbol); + const saveEnclosingDeclaration = context.enclosingDeclaration; + context.enclosingDeclaration = undefined; + if (getCheckFlags(propertySymbol) & CheckFlags.Late) { + const decl = first(propertySymbol.declarations); + if (context.tracker.trackSymbol && hasLateBindableName(decl)) { + // get symbol of the first identifier of the entityName + const firstIdentifier = getFirstIdentifier(decl.name.expression); + const name = resolveName(firstIdentifier, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + if (name) { + context.tracker.trackSymbol(name, saveEnclosingDeclaration, SymbolFlags.Value); } - else { - const savedFlags = context.flags; - context.flags |= !!(getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped) ? NodeBuilderFlags.InReverseMappedType : 0; - const propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : createKeywordTypeNode(SyntaxKind.AnyKeyword); - context.flags = savedFlags; - - const modifiers = isReadonlySymbol(propertySymbol) ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined; - const propertySignature = createPropertySignature( - modifiers, - propertyName, - optionalToken, - propertyTypeNode, - /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - setCommentRange(propertySignature, propertySymbol.valueDeclaration); - } - typeElements.push(propertySignature); + } + } + const propertyName = symbolToName(propertySymbol, context, SymbolFlags.Value, /*expectsIdentifier*/ true); + context.approximateLength += (symbolName(propertySymbol).length + 1); + context.enclosingDeclaration = saveEnclosingDeclaration; + const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined; + if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { + const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); + for (const signature of signatures) { + const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature, context); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + if (propertySymbol.valueDeclaration) { + // Copy comments to node for declaration emit + setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); } + typeElements.push(methodDeclaration); } - return typeElements.length ? typeElements : undefined; + } + else { + const savedFlags = context.flags; + context.flags |= !!(getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped) ? NodeBuilderFlags.InReverseMappedType : 0; + const propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : createKeywordTypeNode(SyntaxKind.AnyKeyword); + context.flags = savedFlags; + + const modifiers = isReadonlySymbol(propertySymbol) ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined; + if (modifiers) { + context.approximateLength += 9; + } + const propertySignature = createPropertySignature( + modifiers, + propertyName, + optionalToken, + propertyTypeNode, + /*initializer*/ undefined); + if (propertySymbol.valueDeclaration) { + // Copy comments to node for declaration emit + setCommentRange(propertySignature, propertySymbol.valueDeclaration); + } + typeElements.push(propertySignature); } } - function mapToTypeNodes(types: ReadonlyArray | undefined, context: NodeBuilderContext): TypeNode[] | undefined { + function mapToTypeNodes(types: ReadonlyArray | undefined, context: NodeBuilderContext, isBareList?: boolean): TypeNode[] | undefined { if (some(types)) { + if (checkTruncationLength(context)) { + if (!isBareList) { + return [createTypeReferenceNode("...", /*typeArguments*/ undefined)]; + } + else if (types.length > 2) { + return [ + typeToTypeNodeHelper(types[0], context), + createTypeReferenceNode(`... ${types.length - 2} more ...`, /*typeArguments*/ undefined), + typeToTypeNodeHelper(types[types.length - 1], context) + ]; + } + } const result = []; + let i = 0; for (const type of types) { + i++; + if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { + result.push(createTypeReferenceNode(`... ${types.length - i} more ...`, /*typeArguments*/ undefined)); + const typeNode = typeToTypeNodeHelper(types[types.length - 1], context); + if (typeNode) { + result.push(typeNode); + } + break; + } + context.approximateLength += 2; // Account for whitespace + separator const typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { result.push(typeNode); @@ -3591,6 +3638,7 @@ namespace ts { if (!indexInfo.type && !(context.flags & NodeBuilderFlags.AllowEmptyIndexInfoType)) { context.encounteredError = true; } + context.approximateLength += (name.length + 4); return createIndexSignature( /*decorators*/ undefined, indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined, @@ -3635,6 +3683,7 @@ namespace ts { else if (!returnTypeNode) { returnTypeNode = createKeywordTypeNode(SyntaxKind.AnyKeyword); } + context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); } @@ -3696,6 +3745,7 @@ namespace ts { questionToken, parameterTypeNode, /*initializer*/ undefined); + context.approximateLength += symbolName(parameterSymbol).length + 3; return parameterNode; function cloneBindingName(node: BindingName): BindingName { @@ -3728,18 +3778,19 @@ namespace ts { /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { let accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & NodeBuilderFlags.UseOnlyExternalAliasing)); - let parentSymbol: Symbol | undefined; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - const parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent) { - const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); - if (parentChain) { - parentSymbol = parent; - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); + const parents = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration); + if (length(parents)) { + for (const parent of parents!) { + const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + if (parentChain) { + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); + break; + } } } } @@ -3750,11 +3801,12 @@ namespace ts { if ( // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || - // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) - (yieldModuleSymbol || !(!parentSymbol && forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) && // If a parent symbol is an anonymous type, don't write it. !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { - + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + if (!endOfChain && !yieldModuleSymbol && !!forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return; + } return [symbol]; } } @@ -3799,19 +3851,58 @@ namespace ts { return top; } + function getSpecifierForModuleSymbol(symbol: Symbol, context: NodeBuilderContext) { + const file = getDeclarationOfKind(symbol, SyntaxKind.SourceFile); + if (file && file.moduleName !== undefined) { + // Use the amd name if it is available + return file.moduleName; + } + if (!file) { + if (context.tracker.trackReferencedAmbientModule) { + const ambientDecls = filter(symbol.declarations, isAmbientModule); + if (length(ambientDecls)) { + for (const decl of ambientDecls) { + context.tracker.trackReferencedAmbientModule(decl, symbol); + } + } + } + return (symbol.escapedName as string).substring(1, (symbol.escapedName as string).length - 1); + } + else { + if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) { + // If there's no context declaration, we can't lookup a non-ambient specifier, so we just use the symbol name + return (symbol.escapedName as string).substring(1, (symbol.escapedName as string).length - 1); + } + const contextFile = getSourceFileOfNode(getOriginalNode(context.enclosingDeclaration)); + const links = getSymbolLinks(symbol); + let specifier = links.specifierCache && links.specifierCache.get(contextFile.path); + if (!specifier) { + specifier = flatten(moduleSpecifiers.getModuleSpecifiers( + symbol, + compilerOptions, + contextFile, + context.tracker.moduleResolverHost, + context.tracker.moduleResolverHost.getSourceFiles!(), // TODO: GH#18217 + { importModuleSpecifierPreference: "non-relative" } + ))[0]; + links.specifierCache = links.specifierCache || createMap(); + links.specifierCache.set(contextFile.path, specifier); + } + return specifier; + } + } + function symbolToTypeNode(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, overrideTypeArguments?: ReadonlyArray): TypeNode { const chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope)); // If we're using aliases outside the current scope, dont bother with the module - context.flags |= NodeBuilderFlags.InInitialEntityName; - const rootName = getNameOfSymbolAsWritten(chain[0], context); - context.flags ^= NodeBuilderFlags.InInitialEntityName; - const isTypeOf = meaning === SymbolFlags.Value; - if (ambientModuleSymbolRegex.test(rootName)) { + if (some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` const nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; const typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); - const lit = createLiteralTypeNode(createLiteral(rootName.substring(1, rootName.length - 1))); + const specifier = getSpecifierForModuleSymbol(chain[0], context); + const lit = createLiteralTypeNode(createLiteral(specifier)); + context.approximateLength += specifier.length + 10; // specifier + import("") if (!nonRootParts || isEntityName(nonRootParts)) { if (nonRootParts) { const lastId = isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right; @@ -3848,6 +3939,7 @@ namespace ts { context.flags |= NodeBuilderFlags.InInitialEntityName; } const symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += symbolName.length + 1; if (index === 0) { context.flags ^= NodeBuilderFlags.InInitialEntityName; } @@ -4032,6 +4124,8 @@ namespace ts { encounteredError: boolean; visitedSymbols: Map | undefined; inferTypeParameters: TypeParameter[] | undefined; + approximateLength: number; + truncating?: boolean; } function isDefaultBindingContext(location: Node) { @@ -4056,41 +4150,6 @@ namespace ts { return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (some(symbol.declarations, hasExternalModuleSymbol) && context!.enclosingDeclaration) { // TODO: GH#18217 - const file = getDeclarationOfKind(symbol, SyntaxKind.SourceFile); - if (!file || !context!.tracker.moduleResolverHost) { - if (context!.tracker.trackReferencedAmbientModule) { - const ambientDecls = filter(symbol.declarations, isAmbientModule); - if (length(ambientDecls)) { - for (const decl of ambientDecls) { - context!.tracker.trackReferencedAmbientModule!(decl); // TODO: GH#18217 - } - } - } - // ambient module, just use declaration/symbol name (fallthrough) - } - else { - if (file.moduleName) { - return `"${file.moduleName}"`; - } - const contextFile = getSourceFileOfNode(getOriginalNode(context!.enclosingDeclaration))!; - const links = getSymbolLinks(symbol); - let specifier = links.specifierCache && links.specifierCache.get(contextFile.path); - if (!specifier) { - specifier = flatten(moduleSpecifiers.getModuleSpecifiers( - symbol, - compilerOptions, - contextFile, - context!.tracker.moduleResolverHost!, - context!.tracker.moduleResolverHost!.getSourceFiles!(), - { importModuleSpecifierPreference: "non-relative" } - ))[0]; - links.specifierCache = links.specifierCache || createMap(); - links.specifierCache.set(contextFile.path, specifier); - } - return `"${specifier}"`; - } - } const declaration = symbol.declarations[0]; const name = getNameOfDeclaration(declaration); if (name) { @@ -4161,7 +4220,7 @@ namespace ts { } const parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(getCombinedModifierFlags(node) & ModifierFlags.Export) && + if (!(getCombinedModifierFlags(node as Declaration) & ModifierFlags.Export) && !(node.kind !== SyntaxKind.ImportEqualsDeclaration && parent.kind !== SyntaxKind.SourceFile && parent.flags & NodeFlags.Ambient)) { return isGlobalSourceFile(parent); } @@ -4314,8 +4373,8 @@ namespace ts { if (propertyName === TypeSystemPropertyName.ResolvedReturnType) { return !!(target).resolvedReturnType; } - if (propertyName === TypeSystemPropertyName.ResolvedBaseConstraint) { - const bc = (target).resolvedBaseConstraint; + if (propertyName === TypeSystemPropertyName.ImmediateBaseConstraint) { + const bc = (target).immediateBaseConstraint; return !!bc && bc !== circularConstraintType; } @@ -4525,7 +4584,7 @@ namespace ts { if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & TypeFlags.Undefined)) { type = getTypeWithFacts(type, TypeFacts.NEUndefined); } - return declaration.initializer ? + return declaration.initializer && !getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration)) ? getUnionType([type, checkExpressionCached(declaration.initializer)], UnionReduction.Subtype) : type; } @@ -4617,13 +4676,7 @@ namespace ts { } } // Use contextual parameter type if one is available - let type: Type | undefined; - if (declaration.symbol.escapedName === "this") { - type = getContextualThisParameterType(func); - } - else { - type = getContextuallyTypedParameterType(declaration); - } + const type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, isOptional); } @@ -4650,100 +4703,45 @@ namespace ts { return undefined; } - function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol: Symbol) { + function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol: Symbol, resolvedSymbol?: Symbol) { // function/class/{} assignments are fresh declarations, not property assignments, so only add prototype assignments const specialDeclaration = getAssignedJavascriptInitializer(symbol.valueDeclaration); if (specialDeclaration) { + const tag = getJSDocTypeTag(specialDeclaration); + if (tag && tag.typeExpression) { + return getTypeFromTypeNode(tag.typeExpression); + } return getWidenedLiteralType(checkExpressionCached(specialDeclaration)); } - const types: Type[] = []; - let constructorTypes: Type[] | undefined; let definedInConstructor = false; let definedInMethod = false; - let jsDocType: Type | undefined; + let jsdocType: Type | undefined; + let types: Type[] | undefined; for (const declaration of symbol.declarations) { - let declarationInConstructor = false; const expression = isBinaryExpression(declaration) ? declaration : isPropertyAccessExpression(declaration) ? isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; - if (!expression) { return errorType; } const special = isPropertyAccessExpression(expression) ? getSpecialPropertyAccessKind(expression) : getSpecialPropertyAssignmentKind(expression); if (special === SpecialPropertyAssignmentKind.ThisProperty) { - const thisContainer = getThisContainer(expression, /*includeArrowFunctions*/ false); - // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. - // Function expressions that are assigned to the prototype count as methods. - declarationInConstructor = thisContainer.kind === SyntaxKind.Constructor || - thisContainer.kind === SyntaxKind.FunctionDeclaration || - (thisContainer.kind === SyntaxKind.FunctionExpression && !isPrototypePropertyAssignment(thisContainer.parent)); - if (declarationInConstructor) { + if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } else { definedInMethod = true; } } - - // If there is a JSDoc type, use it - const type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type) { - const declarationType = getWidenedType(type); - if (!jsDocType) { - jsDocType = declarationType; - } - else if (jsDocType !== errorType && declarationType !== errorType && - !isTypeIdenticalTo(jsDocType, declarationType) && - !(symbol.flags & SymbolFlags.JSContainer)) { - errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); - } - } - else if (!jsDocType && isBinaryExpression(expression)) { - // If we don't have an explicit JSDoc type, get the type from the expression. - let type = getWidenedLiteralType(checkExpressionCached(expression.right)); - - if (getObjectFlags(type) & ObjectFlags.Anonymous && - special === SpecialPropertyAssignmentKind.ModuleExports && - symbol.escapedName === InternalSymbolName.ExportEquals) { - const exportedType = resolveStructuredTypeMembers(type as AnonymousType); - const members = createSymbolTable(); - copyEntries(exportedType.members, members); - symbol.exports!.forEach((s, name) => { - if (members.has(name)) { - const exportedMember = exportedType.members.get(name)!; - const union = createSymbol(s.flags | exportedMember.flags, name); - union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]); - members.set(name, union); - } - else { - members.set(name, s); - } - }); - type = createAnonymousType( - exportedType.symbol, - members, - exportedType.callSignatures, - exportedType.constructSignatures, - exportedType.stringIndexInfo, - exportedType.numberIndexInfo); - } - let anyedType = type; - if (isEmptyArrayLiteralType(type)) { - anyedType = anyArrayType; - if (noImplicitAny) { - reportImplicitAnyError(expression, anyArrayType); - } - } - types.push(anyedType); - if (declarationInConstructor) { - (constructorTypes || (constructorTypes = [])).push(anyedType); - } + jsdocType = getJSDocTypeFromSpecialDeclarations(jsdocType, expression, symbol, declaration); + if (!jsdocType) { + (types || (types = [])).push(isBinaryExpression(expression) ? getInitializerTypeFromSpecialDeclarations(symbol, resolvedSymbol, expression, special) : neverType); } } - let type = jsDocType; + let type = jsdocType; if (!type) { + let constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types!, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { const propType = getTypeOfSpecialPropertyOfBaseType(symbol); @@ -4752,8 +4750,8 @@ namespace ts { definedInConstructor = true; } } - const sourceTypes = some(constructorTypes, t => !!(t.flags & ~(TypeFlags.Nullable | TypeFlags.ContainsWideningType))) ? constructorTypes! : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, UnionReduction.Subtype); + const sourceTypes = some(constructorTypes, t => !!(t.flags & ~(TypeFlags.Nullable | TypeFlags.ContainsWideningType))) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes!, UnionReduction.Subtype); } const widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); if (filterType(widened, t => !!(t.flags & ~TypeFlags.Nullable)) === neverType) { @@ -4765,6 +4763,82 @@ namespace ts { return widened; } + function getJSDocTypeFromSpecialDeclarations(declaredType: Type | undefined, expression: Expression, _symbol: Symbol, declaration: Declaration) { + const typeNode = getJSDocType(expression.parent); + if (typeNode) { + const type = getWidenedType(getTypeFromTypeNode(typeNode)); + if (!declaredType) { + return type; + } + else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) { + errorNextVariableOrPropertyDeclarationMustHaveSameType(declaredType, declaration, type); + } + } + return declaredType; + } + + /** If we don't have an explicit JSDoc type, get the type from the initializer. */ + function getInitializerTypeFromSpecialDeclarations(symbol: Symbol, resolvedSymbol: Symbol | undefined, expression: Expression, special: SpecialPropertyAssignmentKind) { + if (isBinaryExpression(expression)) { + const type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right)); + if (type.flags & TypeFlags.Object && + special === SpecialPropertyAssignmentKind.ModuleExports && + symbol.escapedName === InternalSymbolName.ExportEquals) { + const exportedType = resolveStructuredTypeMembers(type as ObjectType); + const members = createSymbolTable(); + copyEntries(exportedType.members, members); + if (resolvedSymbol && !resolvedSymbol.exports) { + resolvedSymbol.exports = createSymbolTable(); + } + (resolvedSymbol || symbol).exports!.forEach((s, name) => { + if (members.has(name)) { + const exportedMember = exportedType.members.get(name)!; + const union = createSymbol(s.flags | exportedMember.flags, name); + union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]); + members.set(name, union); + } + else { + members.set(name, s); + } + }); + return createAnonymousType( + exportedType.symbol, + members, + exportedType.callSignatures, + exportedType.constructSignatures, + exportedType.stringIndexInfo, + exportedType.numberIndexInfo); + } + if (isEmptyArrayLiteralType(type)) { + if (noImplicitAny) { + reportImplicitAnyError(expression, anyArrayType); + } + return anyArrayType; + } + return type; + } + return neverType; + } + + function isDeclarationInConstructor(expression: Expression) { + const thisContainer = getThisContainer(expression, /*includeArrowFunctions*/ false); + // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. + // Function expressions that are assigned to the prototype count as methods. + return thisContainer.kind === SyntaxKind.Constructor || + thisContainer.kind === SyntaxKind.FunctionDeclaration || + (thisContainer.kind === SyntaxKind.FunctionExpression && !isPrototypePropertyAssignment(thisContainer.parent)); + } + + function getConstructorDefinedThisAssignmentTypes(types: Type[], declarations: Declaration[]): Type[] | undefined { + Debug.assert(types.length === declarations.length); + return types.filter((_, i) => { + const declaration = declarations[i]; + const expression = isBinaryExpression(declaration) ? declaration : + isBinaryExpression(declaration.parent) ? declaration.parent : undefined; + return expression && isDeclarationInConstructor(expression); + }); + } + /** check for definition in base class if any declaration is in a class */ function getTypeOfSpecialPropertyOfBaseType(specialProperty: Symbol) { const parentDeclaration = forEach(specialProperty.declarations, d => { @@ -4920,9 +4994,15 @@ namespace ts { return links.type = getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. - if (symbol === requireSymbol || symbol === moduleSymbol) { + if (symbol === requireSymbol) { return links.type = anyType; } + if (symbol.flags & SymbolFlags.ModuleExports) { + const fileSymbol = getSymbolOfNode(getSourceFileOfNode(symbol.valueDeclaration)); + const members = createSymbolTable(); + members.set("exports" as __String, fileSymbol); + return links.type = createAnonymousType(symbol, members, emptyArray, emptyArray, undefined, undefined); + } // Handle catch clause variables const declaration = symbol.valueDeclaration; if (isCatchClauseVariableDeclarationOrBindingElement(declaration)) { @@ -5021,7 +5101,7 @@ namespace ts { } function getJSInitializerType(decl: Node, symbol: Symbol, init: Expression | undefined): Type | undefined { - if (init && isInJavaScriptFile(init) && isObjectLiteralExpression(init)) { + if (init && isInJavaScriptFile(init) && isObjectLiteralExpression(init) && init.properties.length === 0) { const exports = createSymbolTable(); while (isBinaryExpression(decl) || isPropertyAccessExpression(decl)) { const s = getSymbolOfNode(decl); @@ -5156,13 +5236,28 @@ namespace ts { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { - const type = createObjectType(ObjectFlags.Anonymous, symbol); - if (symbol.flags & SymbolFlags.Class) { - const baseTypeVariable = getBaseTypeVariableOfClass(symbol); - links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + if (symbol.flags & SymbolFlags.ValueModule && symbol.valueDeclaration && isSourceFile(symbol.valueDeclaration) && symbol.valueDeclaration.commonJsModuleIndicator) { + if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) { + return errorType; + } + const resolvedModule = resolveExternalModuleSymbol(symbol); + if (resolvedModule !== symbol) { + const exportEquals = getMergedSymbol(symbol.exports!.get(InternalSymbolName.ExportEquals)!); + links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); + } + if (!popTypeResolution()) { + links.type = reportCircularityError(symbol); + } } - else { - links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? getOptionalType(type) : type; + if (!links.type) { + const type = createObjectType(ObjectFlags.Anonymous, symbol); + if (symbol.flags & SymbolFlags.Class) { + const baseTypeVariable = getBaseTypeVariableOfClass(symbol); + links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; + } + else { + links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? getOptionalType(type) : type; + } } } } @@ -5514,7 +5609,7 @@ namespace ts { // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a // partial instantiation of the members without the base types fully resolved - (type as Type as ResolvedType).members = undefined!; // TODO: GH#18217 + type.members = undefined; } return type.resolvedBaseTypes = [baseType]; } @@ -5938,6 +6033,12 @@ namespace ts { && isTypeUsableAsLateBoundName(checkComputedPropertyName(node)); } + function isLateBoundName(name: __String): boolean { + return (name as string).charCodeAt(0) === CharacterCodes._ && + (name as string).charCodeAt(1) === CharacterCodes._ && + (name as string).charCodeAt(2) === CharacterCodes.at; + } + /** * Indicates whether a declaration has a late-bindable dynamic name. */ @@ -6444,6 +6545,7 @@ namespace ts { function resolveAnonymousTypeMembers(type: AnonymousType) { const symbol = type.symbol; if (type.target) { + setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined); const members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper!, /*mappingThisOnly*/ false); const callSignatures = instantiateSignatures(getSignaturesOfType(type.target, SignatureKind.Call), type.mapper!); const constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper!); @@ -6452,6 +6554,7 @@ namespace ts { setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & SymbolFlags.TypeLiteral) { + setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined); const members = getMembersOfSymbol(symbol); const callSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.Call)); const constructSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.New)); @@ -6485,7 +6588,7 @@ namespace ts { // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) { - (type).callSignatures = getSignaturesOfSymbol(symbol); + type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes if (symbol.flags & SymbolFlags.Class) { @@ -6494,7 +6597,7 @@ namespace ts { if (!constructSignatures.length) { constructSignatures = getDefaultConstructSignatures(classType); } - (type).constructSignatures = constructSignatures; + type.constructSignatures = constructSignatures; } } } @@ -6746,6 +6849,18 @@ namespace ts { getPropertiesOfObjectType(type); } + function isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression): boolean { + return obj.properties.some(property => { + const name = property.name && getTextOfPropertyName(property.name); + const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); + if (expected && typeIsLiteralType(expected)) { + const actual = getTypeOfNode(property); + return !!actual && !isTypeIdenticalTo(actual, expected); + } + return false; + }); + } + function getAllPossiblePropertiesOfTypes(types: ReadonlyArray): Symbol[] { const unionType = getUnionType(types); if (!(unionType.flags & TypeFlags.Union)) { @@ -6899,15 +7014,21 @@ namespace ts { return type.resolvedBaseConstraint; function getBaseConstraint(t: Type): Type | undefined { - if (!pushTypeResolution(t, TypeSystemPropertyName.ResolvedBaseConstraint)) { + if (t.immediateBaseConstraint) { + return t.immediateBaseConstraint === noConstraintType ? undefined : t.immediateBaseConstraint; + } + if (!pushTypeResolution(t, TypeSystemPropertyName.ImmediateBaseConstraint)) { circular = true; + t.immediateBaseConstraint = circularConstraintType; return undefined; } const result = computeBaseConstraint(getSimplifiedType(t)); if (!popTypeResolution()) { circular = true; + t.immediateBaseConstraint = circularConstraintType; return undefined; } + t.immediateBaseConstraint = !result ? noConstraintType : result; return result; } @@ -7024,6 +7145,7 @@ namespace ts { function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined { let props: Symbol[] | undefined; + let indexTypes: Type[] | undefined; 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 @@ -7048,14 +7170,21 @@ namespace ts { } } else if (isUnion) { - checkFlags |= CheckFlags.Partial; + const index = !isLateBoundName(name) && ((isNumericLiteralName(name) && getIndexInfoOfType(type, IndexKind.Number)) || getIndexInfoOfType(type, IndexKind.String)); + if (index) { + checkFlags |= index.isReadonly ? CheckFlags.Readonly : 0; + indexTypes = append(indexTypes, index.type); + } + else { + checkFlags |= CheckFlags.Partial; + } } } } if (!props) { return undefined; } - if (props.length === 1 && !(checkFlags & CheckFlags.Partial)) { + if (props.length === 1 && !(checkFlags & CheckFlags.Partial) && !indexTypes) { return props[0]; } let declarations: Declaration[] | undefined; @@ -7086,6 +7215,7 @@ namespace ts { } propTypes.push(type); } + addRange(propTypes, indexTypes); const result = createSymbol(SymbolFlags.Property | commonFlags, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && commonValueDeclaration) { @@ -7466,12 +7596,21 @@ namespace ts { const setter = getDeclarationOfKind(getSymbolOfNode(declaration), SyntaxKind.SetAccessor); return getAnnotatedAccessorType(setter); } - + const typeFromTag = getReturnTypeOfTypeTag(declaration); + if (typeFromTag) { + return typeFromTag; + } if (nodeIsMissing((declaration).body)) { return anyType; } } + function getReturnTypeOfTypeTag(node: SignatureDeclaration | JSDocSignature) { + const typeTag = isInJavaScriptFile(node) ? getJSDocTypeTag(node) : undefined; + const signatures = typeTag && typeTag.typeExpression && getSignaturesOfType(getTypeFromTypeNode(typeTag.typeExpression), SignatureKind.Call); + return signatures && signatures.length === 1 ? getReturnTypeOfSignature(signatures[0]) : undefined; + } + function containsArgumentsReference(declaration: SignatureDeclaration): boolean { const links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { @@ -7602,9 +7741,13 @@ namespace ts { return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, TypeSystemPropertyName.ResolvedReturnType) >= 0; } - function getRestTypeOfSignature(signature: Signature) { + function getRestTypeOfSignature(signature: Signature): Type { + return tryGetRestTypeOfSignature(signature) || anyType; + } + + function tryGetRestTypeOfSignature(signature: Signature): Type | undefined { const type = getTypeOfRestParameter(signature); - return type && getIndexTypeOfType(type, IndexKind.Number) || anyType; + return type && getIndexTypeOfType(type, IndexKind.Number); } function getSignatureInstantiation(signature: Signature, typeArguments: Type[] | undefined, isJavascript: boolean): Signature { @@ -7674,7 +7817,7 @@ namespace ts { // will result in a different declaration kind. if (!signature.isolatedSignatureType) { const isConstructor = signature.declaration!.kind === SyntaxKind.Constructor || signature.declaration!.kind === SyntaxKind.ConstructSignature; // TODO: GH#18217 - const type = createObjectType(ObjectFlags.Anonymous); + const type = createObjectType(ObjectFlags.Anonymous); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -8151,7 +8294,7 @@ namespace ts { // The expression is processed as an identifier expression (section 4.3) // or property access expression(section 4.10), // the widened type(section 3.9) of which becomes the result. - links.resolvedType = getWidenedType(checkExpression(node.exprName)); + links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(checkExpression(node.exprName))); } return links.resolvedType; } @@ -8807,7 +8950,7 @@ namespace ts { if (!(getDeclarationModifierFlagsFromSymbol(prop) & ModifierFlags.NonPublicAccessibilityModifier)) { let type = getLateBoundSymbol(prop).nameType; if (!type && !isKnownSymbol(prop)) { - const name = getNameOfDeclaration(prop.valueDeclaration); + const name = prop.valueDeclaration && getNameOfDeclaration(prop.valueDeclaration); type = name && isNumericLiteral(name) ? getLiteralType(+name.text) : name && name.kind === SyntaxKind.ComputedPropertyName && isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(symbolName(prop)); @@ -9277,11 +9420,9 @@ namespace ts { links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - const argumentType = getTypeFromTypeNode(node.argument); const targetMeaning = node.isTypeOf ? SymbolFlags.Value : SymbolFlags.Type; // TODO: Future work: support unions/generics/whatever via a deferred import-type - const moduleName = (argumentType as StringLiteralType).value; - const innerModuleSymbol = resolveExternalModule(node, moduleName, Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); + const innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; @@ -9309,7 +9450,12 @@ namespace ts { resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - error(node, targetMeaning === SymbolFlags.Value ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); + const errorMessage = targetMeaning === SymbolFlags.Value + ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here + : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; + + error(node, errorMessage, node.argument.literal.text); + links.resolvedSymbol = unknownSymbol; links.resolvedType = errorType; } @@ -10110,7 +10256,7 @@ namespace ts { if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - const result = createObjectType(ObjectFlags.Anonymous, type.symbol); + const result = createObjectType(ObjectFlags.Anonymous, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -10146,42 +10292,197 @@ namespace ts { return isTypeRelatedTo(source, target, assignableRelation); } - // An object type S is considered to be derived from an object type T if - // S is a union type and every constituent of S is derived from T, - // T is a union type and S is derived from at least one constituent of T, or - // S is a type variable with a base constraint that is derived from T, - // T is one of the global types Object and Function and S is a subtype of T, or - // T occurs directly or indirectly in an 'extends' clause of S. - // Note that this check ignores type parameters and only considers the - // inheritance hierarchy. - function isTypeDerivedFrom(source: Type, target: Type): boolean { - return source.flags & TypeFlags.Union ? every((source).types, t => isTypeDerivedFrom(t, target)) : - target.flags & TypeFlags.Union ? some((target).types, t => isTypeDerivedFrom(source, t)) : - source.flags & TypeFlags.InstantiableNonPrimitive ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : - target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) : - hasBaseType(source, getTargetType(target)); + // An object type S is considered to be derived from an object type T if + // S is a union type and every constituent of S is derived from T, + // T is a union type and S is derived from at least one constituent of T, or + // S is a type variable with a base constraint that is derived from T, + // T is one of the global types Object and Function and S is a subtype of T, or + // T occurs directly or indirectly in an 'extends' clause of S. + // Note that this check ignores type parameters and only considers the + // inheritance hierarchy. + function isTypeDerivedFrom(source: Type, target: Type): boolean { + return source.flags & TypeFlags.Union ? every((source).types, t => isTypeDerivedFrom(t, target)) : + target.flags & TypeFlags.Union ? some((target).types, t => isTypeDerivedFrom(source, t)) : + source.flags & TypeFlags.InstantiableNonPrimitive ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : + target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) : + hasBaseType(source, getTargetType(target)); + } + + /** + * This is *not* a bi-directional relationship. + * If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'. + * + * A type S is comparable to a type T if some (but not necessarily all) of the possible values of S are also possible values of T. + * It is used to check following cases: + * - the types of the left and right sides of equality/inequality operators (`===`, `!==`, `==`, `!=`). + * - the types of `case` clause expressions and their respective `switch` expressions. + * - the type of an expression in a type assertion with the type being asserted. + */ + function isTypeComparableTo(source: Type, target: Type): boolean { + return isTypeRelatedTo(source, target, comparableRelation); + } + + function areTypesComparable(type1: Type, type2: Type): boolean { + return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); + } + + function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined, errorOutputObject?: { error?: Diagnostic }): boolean { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject); + } + + /** + * Like `checkTypeAssignableTo`, but if it would issue an error, instead performs structural comparisons of the types using the given expression node to + * attempt to issue more specific errors on, for example, specific object literal properties or tuple members. + */ + function checkTypeAssignableToAndOptionallyElaborate(source: Type, target: Type, errorNode: Node | undefined, expr: Expression | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { + if (isTypeAssignableTo(source, target)) return true; + if (!elaborateError(expr, source, target)) { + return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + } + return false; + } + + function elaborateError(node: Expression | undefined, source: Type, target: Type): boolean { + if (!node) return false; + switch (node.kind) { + case SyntaxKind.JsxExpression: + case SyntaxKind.ParenthesizedExpression: + return elaborateError((node as ParenthesizedExpression | JsxExpression).expression, source, target); + case SyntaxKind.BinaryExpression: + switch ((node as BinaryExpression).operatorToken.kind) { + case SyntaxKind.EqualsToken: + case SyntaxKind.CommaToken: + return elaborateError((node as BinaryExpression).right, source, target); + } + break; + case SyntaxKind.ObjectLiteralExpression: + return elaborateObjectLiteral(node as ObjectLiteralExpression, source, target); + case SyntaxKind.ArrayLiteralExpression: + return elaborateArrayLiteral(node as ArrayLiteralExpression, source, target); + case SyntaxKind.JsxAttributes: + return elaborateJsxAttributes(node as JsxAttributes, source, target); + } + return false; + } + + type ElaborationIterator = IterableIterator<{ errorNode: Node, innerExpression: Expression | undefined, nameType: Type, errorMessage?: DiagnosticMessage | undefined }>; + /** + * For every element returned from the iterator, checks that element to issue an error on a property of that element's type + * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` + * Otherwise, we issue an error on _every_ element which fail the assignability check + */ + function elaborateElementwise(iterator: ElaborationIterator, source: Type, target: Type) { + // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span + let reportedError = false; + for (let status = iterator.next(); !status.done; status = iterator.next()) { + const { errorNode: prop, innerExpression: next, nameType, errorMessage } = status.value; + const sourcePropType = getIndexedAccessType(source, nameType); + const targetPropType = getIndexedAccessType(target, nameType); + if (!isTypeAssignableTo(sourcePropType, targetPropType)) { + const elaborated = next && elaborateError(next, sourcePropType, targetPropType); + if (elaborated) { + reportedError = true; + } + else { + // Issue error on the prop itself, since the prop couldn't elaborate the error + const resultObj: { error?: Diagnostic } = {}; + // Use the expression type, if available + const specificSource = next ? checkExpressionForMutableLocation(next, CheckMode.Normal, sourcePropType) : sourcePropType; + const result = checkTypeAssignableTo(specificSource, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeAssignableTo(sourcePropType, targetPropType, prop, errorMessage, /*containingChain*/ undefined, resultObj); + } + if (resultObj.error) { + const reportedDiag = resultObj.error; + const propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined; + const targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined; + + let issuedElaboration = false; + if (!targetProp) { + const indexInfo = isTypeAssignableToKind(nameType, TypeFlags.NumberLike) && getIndexInfoOfType(target, IndexKind.Number) || + getIndexInfoOfType(target, IndexKind.String) || + undefined; + if (indexInfo && indexInfo.declaration) { + issuedElaboration = true; + addRelatedInfo(reportedDiag, createDiagnosticForNode(indexInfo.declaration, Diagnostics.The_expected_type_comes_from_this_index_signature)); + } + } + + if (!issuedElaboration && (targetProp && length(targetProp.declarations) || target.symbol && length(target.symbol.declarations))) { + addRelatedInfo(reportedDiag, createDiagnosticForNode( + targetProp && length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0], + Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, + propertyName && !(nameType.flags & TypeFlags.UniqueESSymbol) ? unescapeLeadingUnderscores(propertyName) : typeToString(nameType), + typeToString(target) + )); + } + } + reportedError = true; + } + } + } + return reportedError; + } + + function *generateJsxAttributes(node: JsxAttributes): ElaborationIterator { + if (!length(node.properties)) return; + for (const prop of node.properties) { + if (isJsxSpreadAttribute(prop)) continue; + yield { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(idText(prop.name)) }; + } + } + + function elaborateJsxAttributes(node: JsxAttributes, source: Type, target: Type) { + return elaborateElementwise(generateJsxAttributes(node), source, target); + } + + function *generateLimitedTupleElements(node: ArrayLiteralExpression, target: Type): ElaborationIterator { + const len = length(node.elements); + if (!len) return; + for (let i = 0; i < len; i++) { + // Skip elements which do not exist in the target - a length error on the tuple overall is likely better than an error on a mismatched index signature + if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i) as __String)) continue; + const elem = node.elements[i]; + if (isOmittedExpression(elem)) continue; + const nameType = getLiteralType(i); + yield { errorNode: elem, innerExpression: elem, nameType }; + } + } + + function elaborateArrayLiteral(node: ArrayLiteralExpression, source: Type, target: Type) { + if (isTupleLikeType(source)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), source, target); } - - /** - * This is *not* a bi-directional relationship. - * If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'. - * - * A type S is comparable to a type T if some (but not necessarily all) of the possible values of S are also possible values of T. - * It is used to check following cases: - * - the types of the left and right sides of equality/inequality operators (`===`, `!==`, `==`, `!=`). - * - the types of `case` clause expressions and their respective `switch` expressions. - * - the type of an expression in a type assertion with the type being asserted. - */ - function isTypeComparableTo(source: Type, target: Type): boolean { - return isTypeRelatedTo(source, target, comparableRelation); + return false; } - function areTypesComparable(type1: Type, type2: Type): boolean { - return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1); + function *generateObjectLiteralElements(node: ObjectLiteralExpression): ElaborationIterator { + if (!length(node.properties)) return; + for (const prop of node.properties) { + if (isSpreadAssignment(prop)) continue; + const type = getLiteralTypeFromPropertyName(getSymbolOfNode(prop), TypeFlags.StringOrNumberLiteralOrUnique); + if (!type || (type.flags & TypeFlags.Never)) { + continue; + } + switch (prop.kind) { + case SyntaxKind.SetAccessor: + case SyntaxKind.GetAccessor: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.ShorthandPropertyAssignment: + yield { errorNode: prop.name, innerExpression: undefined, nameType: type }; + break; + case SyntaxKind.PropertyAssignment: + yield { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }; + break; + default: + Debug.assertNever(prop); + } + } } - function checkTypeAssignableTo(source: Type, target: Type, errorNode: Node | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain); + function elaborateObjectLiteral(node: ObjectLiteralExpression, source: Type, target: Type) { + return elaborateElementwise(generateObjectLiteralElements(node), source, target); } /** @@ -10227,9 +10528,9 @@ namespace ts { } const sourceCount = getParameterCount(source); - const sourceRestTypeParameter = getRestTypeParameter(source); - const targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter(target) : undefined; - if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) { + const sourceGenericRestType = getGenericRestType(source); + const targetGenericRestType = sourceGenericRestType ? getGenericRestType(target) : undefined; + if (sourceGenericRestType && !(targetGenericRestType && sourceCount === targetCount)) { return Ternary.False; } @@ -10258,8 +10559,8 @@ namespace ts { const paramCount = Math.max(sourceCount, targetCount); const lastIndex = paramCount - 1; for (let i = 0; i < paramCount; i++) { - const sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i); - const targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i); + const sourceType = i === lastIndex && sourceGenericRestType || getTypeAtPosition(source, i); + const targetType = i === lastIndex && targetGenericRestType || getTypeAtPosition(target, i); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -10396,11 +10697,11 @@ namespace ts { } const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); const relation = enumRelation.get(id); - if (relation !== undefined) { - return relation; + if (relation !== undefined && !(relation === RelationComparisonResult.Failed && errorReporter)) { + return relation === RelationComparisonResult.Succeeded; } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & SymbolFlags.RegularEnum) || !(targetSymbol.flags & SymbolFlags.RegularEnum)) { - enumRelation.set(id, false); + enumRelation.set(id, RelationComparisonResult.FailedAndReported); return false; } const targetEnumType = getTypeOfSymbol(targetSymbol); @@ -10411,13 +10712,16 @@ namespace ts { if (errorReporter) { errorReporter(Diagnostics.Property_0_is_missing_in_type_1, symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType)); + enumRelation.set(id, RelationComparisonResult.FailedAndReported); + } + else { + enumRelation.set(id, RelationComparisonResult.Failed); } - enumRelation.set(id, false); return false; } } } - enumRelation.set(id, true); + enumRelation.set(id, RelationComparisonResult.Succeeded); return true; } @@ -10502,7 +10806,9 @@ namespace ts { relation: Map, errorNode: Node | undefined, headMessage?: DiagnosticMessage, - containingMessageChain?: () => DiagnosticMessageChain | undefined): boolean { + containingMessageChain?: () => DiagnosticMessageChain | undefined, + errorOutputContainer?: { error?: Diagnostic } + ): boolean { let errorInfo: DiagnosticMessageChain | undefined; let maybeKeys: string[]; @@ -10542,7 +10848,11 @@ namespace ts { } } - diagnostics.add(createDiagnosticForNodeFromMessageChain(errorNode!, errorInfo, relatedInformation)); // TODO: GH#18217 + const diag = createDiagnosticForNodeFromMessageChain(errorNode!, errorInfo, relatedInformation); + if (errorOutputContainer) { + errorOutputContainer.error = diag; + } + diagnostics.add(diag); // TODO: GH#18217 } return result !== Ternary.False; @@ -10631,6 +10941,23 @@ namespace ts { target = getSimplifiedType(target); } + // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. + // If so, reporting the `null` and `undefined` in the type is hardly useful. + // First, see if we're even relating an object type to a union. + // Then see if the target is stripped down to a single non-union type. + // Note + // * We actually want to remove null and undefined naively here (rather than using getNonNullableType), + // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable`" + // when dealing with generics. + // * We also don't deal with primitive source types, since we already halt elaboration below. + if (target.flags & TypeFlags.Union && source.flags & TypeFlags.Object && + (target as UnionType).types.length <= 3 && maybeTypeOfKind(target, TypeFlags.Nullable)) { + const nullStrippedTarget = extractTypesOfKind(target, ~TypeFlags.Nullable); + if (!(nullStrippedTarget.flags & (TypeFlags.Union | TypeFlags.Never))) { + target = nullStrippedTarget; + } + } + // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; @@ -10890,7 +11217,8 @@ namespace ts { if (reportErrors) { const bestMatchingType = findMatchingDiscriminantType(source, target) || - findMatchingTypeReferenceOrTypeAliasReference(source, target); + findMatchingTypeReferenceOrTypeAliasReference(source, target) || + findBestTypeForObjectLiteral(source, target); isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); } @@ -10915,6 +11243,11 @@ namespace ts { } } + function findBestTypeForObjectLiteral(source: Type, unionTarget: UnionOrIntersectionType) { + if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && forEachType(unionTarget, isArrayLikeType)) { + return find(unionTarget.types, t => !isArrayLikeType(t)); + } + } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source: Type, target: UnionOrIntersectionType) { @@ -11047,9 +11380,8 @@ namespace ts { 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.set(id, RelationComparisonResult.FailedAndReported); + // We are elaborating errors and the cached result is an unreported failure. The result will be reported + // as a failure, and should be updated as a reported failure by the bottom of this function. } else { return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False; @@ -12223,7 +12555,7 @@ namespace ts { if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); } - return getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull); // Type alias unavailable, fall back to non-higherorder behavior + return getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull); // Type alias unavailable, fall back to non-higher-order behavior } function getNonNullableType(type: Type): Type { @@ -12503,28 +12835,13 @@ namespace ts { sourceHasRest ? targetCount : targetHasRest ? sourceCount : Math.min(sourceCount, targetCount); - const targetRestTypeVariable = getRestTypeParameter(target); - const paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount; + const targetGenericRestType = getGenericRestType(target); + const paramCount = targetGenericRestType ? Math.min(targetCount - 1, maxCount) : maxCount; for (let i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } - if (targetRestTypeVariable) { - const sourceRestTypeVariable = getRestTypeParameter(source); - if (sourceRestTypeVariable && paramCount === sourceCount - 1) { - callback(sourceRestTypeVariable, targetRestTypeVariable); - } - else { - const types = []; - const names = []; - for (let i = paramCount; i < maxCount; i++) { - types.push(getTypeAtPosition(source, i)); - names.push(getParameterNameAtPosition(source, i)); - } - const minArgumentCount = getMinArgumentCount(source); - const minLength = minArgumentCount < paramCount ? 0 : minArgumentCount - paramCount; - const rest = createTupleType(types, minLength, sourceHasRest, names); - callback(rest, targetRestTypeVariable); - } + if (targetGenericRestType) { + callback(getRestTypeAtPosition(source, paramCount), targetGenericRestType); } } @@ -14729,7 +15046,8 @@ namespace ts { const declarationContainer = getControlFlowContainer(declaration); let flowContainer = getControlFlowContainer(node); const isOuterVariable = flowContainer !== declarationContainer; - const isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + const isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); + const isModuleExports = symbol.flags & SymbolFlags.ModuleExports; // 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. @@ -14741,7 +15059,7 @@ namespace ts { // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). - const assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || + const assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.AnyOrUnknown) !== 0 || isInTypeQuery(node) || node.parent.kind === SyntaxKind.ExportSpecifier) || node.parent.kind === SyntaxKind.NonNullExpression || @@ -15326,43 +15644,35 @@ namespace ts { } const iife = getImmediatelyInvokedFunctionExpression(func); if (iife && iife.arguments) { + const args = getEffectiveCallArguments(iife)!; const indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - const restTypes: Type[] = []; - for (let i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getWidenedLiteralType(checkExpression(iife.arguments[i]))); - } - return restTypes.length ? createArrayType(getUnionType(restTypes)) : undefined; + return getSpreadArgumentType(iife, args, indexOfParameter, args.length, anyType, /*context*/ undefined); } const links = getNodeLinks(iife); const cached = links.resolvedSignature; links.resolvedSignature = anySignature; - const type = indexOfParameter < iife.arguments.length ? - getWidenedLiteralType(checkExpression(iife.arguments[indexOfParameter])) : + const type = indexOfParameter < args.length ? + getWidenedLiteralType(checkExpression(args[indexOfParameter])) : parameter.initializer ? undefined : undefinedWideningType; links.resolvedSignature = cached; return type; } const contextualSignature = getContextualSignature(func); if (contextualSignature) { - const funcHasRestParameters = hasRestParameter(func); - const len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + const funcHasRestParameter = hasRestParameter(func); + const len = func.parameters.length - (funcHasRestParameter ? 1 : 0); let indexOfParameter = func.parameters.indexOf(parameter); if (getThisParameter(func) !== undefined && !contextualSignature.thisParameter) { Debug.assert(indexOfParameter !== 0); // Otherwise we should not have called `getContextuallyTypedParameterType`. indexOfParameter -= 1; } - if (indexOfParameter < len) { return getTypeAtPosition(contextualSignature, indexOfParameter); } - // If last parameter is contextually rest parameter get its type - if (funcHasRestParameters && - indexOfParameter === func.parameters.length - 1 && - hasEffectiveRestParameter(contextualSignature) && - func.parameters.length >= contextualSignature.parameters.length) { - return getTypeOfRestParameter(contextualSignature); + if (funcHasRestParameter && indexOfParameter === len) { + return getRestTypeAtPosition(contextualSignature, indexOfParameter); } } } @@ -15518,22 +15828,22 @@ namespace ts { } // In an assignment expression, the right operand is contextually typed by the type of the left operand. - // Don't do this for special property assignments to avoid circularity. + // Don't do this for special property assignments unless there is a type tag on the assignment, to avoid circularity from checking the right operand. function isContextSensitiveAssignment(binaryExpression: BinaryExpression): boolean { const kind = getSpecialPropertyAssignmentKind(binaryExpression); switch (kind) { case SpecialPropertyAssignmentKind.None: return true; case SpecialPropertyAssignmentKind.Property: - // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. - // See `bindStaticPropertyAssignment` in `binder.ts`. - return !binaryExpression.left.symbol; case SpecialPropertyAssignmentKind.ExportsProperty: - case SpecialPropertyAssignmentKind.ModuleExports: + case SpecialPropertyAssignmentKind.Prototype: case SpecialPropertyAssignmentKind.PrototypeProperty: + // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. + // See `bindStaticPropertyAssignment` in `binder.ts`. + return !binaryExpression.left.symbol || binaryExpression.left.symbol.valueDeclaration && !!getJSDocTypeTag(binaryExpression.left.symbol.valueDeclaration); case SpecialPropertyAssignmentKind.ThisProperty: - case SpecialPropertyAssignmentKind.Prototype: - return false; + case SpecialPropertyAssignmentKind.ModuleExports: + return !binaryExpression.symbol || binaryExpression.symbol.valueDeclaration && !!getJSDocTypeTag(binaryExpression.symbol.valueDeclaration); default: return Debug.assertNever(kind); } @@ -15687,7 +15997,7 @@ namespace ts { const discriminatingType = checkExpression(prop.initializer); for (const type of (contextualType as UnionType).types) { const targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); - if (targetType && checkTypeAssignableTo(discriminatingType, targetType, /*errorNode*/ undefined)) { + if (targetType && isTypeAssignableTo(discriminatingType, targetType)) { if (match) { if (type === match) continue; // Finding multiple fields which discriminate to the same type is fine match = undefined; @@ -15853,8 +16163,9 @@ namespace ts { return getUnionType(map(signatures, ctor ? t => getJsxPropsTypeFromClassType(t, isJs, context, /*reportErrors*/ false) : t => getJsxPropsTypeFromCallSignature(t, context)), UnionReduction.None); } - function getJsxPropsTypeFromCallSignature(sig: Signature, context: Node) { + function getJsxPropsTypeFromCallSignature(sig: Signature, context: JsxOpeningLikeElement) { let propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); + propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); const intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); @@ -15867,9 +16178,26 @@ namespace ts { return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); } + function getJsxManagedAttributesFromLocatedAttributes(context: JsxOpeningLikeElement, ns: Symbol, attributesType: Type) { + const managedSym = getJsxLibraryManagedAttributes(ns); + if (managedSym) { + const declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + if (length((declaredManagedType as GenericType).typeParameters) >= 2) { + const args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], (declaredManagedType as GenericType).typeParameters, 2, isInJavaScriptFile(context)); + return createTypeReference((declaredManagedType as GenericType), args); + } + else if (length(declaredManagedType.aliasTypeArguments) >= 2) { + const args = fillMissingTypeArguments([checkExpressionCached(context.tagName), attributesType], declaredManagedType.aliasTypeArguments!, 2, isInJavaScriptFile(context)); + return getTypeAliasInstantiation(declaredManagedType.aliasSymbol!, args); + } + } + return attributesType; + } + function getJsxPropsTypeFromClassType(sig: Signature, isJs: boolean, context: JsxOpeningLikeElement, reportErrors: boolean) { - const forcedLookupLocation = getJsxElementPropertiesName(getJsxNamespaceAt(context)); - const attributesType = forcedLookupLocation === undefined + const ns = getJsxNamespaceAt(context); + const forcedLookupLocation = getJsxElementPropertiesName(ns); + let attributesType = forcedLookupLocation === undefined // If there is no type ElementAttributesProperty, return the type of the first parameter of the signature, which should be the props type ? getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType) : forcedLookupLocation === "" @@ -15885,7 +16213,10 @@ namespace ts { } return emptyObjectType; } - else if (isTypeAny(attributesType)) { + + attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType); + + if (isTypeAny(attributesType)) { // Props is of type 'any' or unknown return attributesType; } @@ -15915,7 +16246,7 @@ namespace ts { // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. - function getContextualCallSignature(type: Type, node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature | undefined { + function getContextualCallSignature(type: Type, node: SignatureDeclaration): Signature | undefined { const signatures = getSignaturesOfType(type, SignatureKind.Call); if (signatures.length === 1) { const signature = signatures[0]; @@ -15926,7 +16257,7 @@ namespace ts { } /** If the contextual signature has fewer parameters than the function expression, do not use it */ - function isAritySmaller(signature: Signature, target: FunctionExpression | ArrowFunction | MethodDeclaration) { + function isAritySmaller(signature: Signature, target: SignatureDeclaration) { let targetParameterCount = 0; for (; targetParameterCount < target.parameters.length; targetParameterCount++) { const param = target.parameters[targetParameterCount]; @@ -16365,14 +16696,18 @@ namespace ts { type.flags & TypeFlags.UnionOrIntersection && every((type).types, isValidSpreadType)); } - function checkJsxSelfClosingElement(node: JsxSelfClosingElement, checkMode: CheckMode | undefined): Type { - checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); + function checkJsxSelfClosingElementDeferred(node: JsxSelfClosingElement) { + checkJsxOpeningLikeElementOrOpeningFragment(node, CheckMode.Normal); + } + + function checkJsxSelfClosingElement(node: JsxSelfClosingElement, _checkMode: CheckMode | undefined): Type { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } - function checkJsxElement(node: JsxElement, checkMode: CheckMode | undefined): Type { + function checkJsxElementDeferred(node: JsxElement) { // Check attributes - checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, checkMode); + checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement, CheckMode.Normal); // Perform resolution on the closing tag so that rename/go to definition/etc work if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) { @@ -16381,6 +16716,10 @@ namespace ts { else { checkExpression(node.closingElement.tagName); } + } + + function checkJsxElement(node: JsxElement, _checkMode: CheckMode | undefined): Type { + checkNodeDeferred(node); return getJsxElementTypeAt(node) || anyType; } @@ -16409,16 +16748,7 @@ namespace ts { * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName: JsxTagNameExpression): boolean { - // TODO (yuisu): comment - switch (tagName.kind) { - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.ThisKeyword: - return false; - case SyntaxKind.Identifier: - return isIntrinsicJsxName((tagName).escapedText); - default: - return Debug.fail(); - } + return tagName.kind === SyntaxKind.Identifier && isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node: JsxAttribute, checkMode?: CheckMode) { @@ -16661,12 +16991,24 @@ namespace ts { } function getJsxNamespaceAt(location: Node | undefined): Symbol { - const namespaceName = getJsxNamespace(location); - const resolvedNamespace = resolveName(location, namespaceName, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); - if (resolvedNamespace) { - const candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, SymbolFlags.Namespace); - if (candidate) { - return candidate; + const links = location && getNodeLinks(location); + if (links && links.jsxNamespace) { + return links.jsxNamespace; + } + if (!links || links.jsxNamespace !== false) { + const namespaceName = getJsxNamespace(location); + const resolvedNamespace = resolveName(location, namespaceName, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + if (resolvedNamespace) { + const candidate = getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, SymbolFlags.Namespace); + if (candidate) { + if (links) { + links.jsxNamespace = candidate; + } + return candidate; + } + if (links) { + links.jsxNamespace = false; + } } } // JSX global fallback @@ -16705,6 +17047,11 @@ namespace ts { return undefined; } + function getJsxLibraryManagedAttributes(jsxNamespace: Symbol) { + // JSX.LibraryManagedAttributes [symbol] + return jsxNamespace && getSymbol(jsxNamespace.exports!, JsxNames.LibraryManagedAttributes, SymbolFlags.Type); + } + /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all /// non-intrinsic elements' attributes type is 'any'), @@ -17105,7 +17452,7 @@ namespace ts { */ function isKnownProperty(targetType: Type, name: __String, isComparingJsxAttributes: boolean): boolean { if (targetType.flags & TypeFlags.Object) { - const resolved = resolveStructuredTypeMembers(targetType); + const resolved = resolveStructuredTypeMembers(targetType as ObjectType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || getPropertyOfObjectType(targetType, name) || @@ -17115,12 +17462,16 @@ namespace ts { } } else if (targetType.flags & TypeFlags.UnionOrIntersection) { - for (const t of (targetType).types) { + for (const t of (targetType as UnionOrIntersectionType).types) { if (isKnownProperty(t, name, isComparingJsxAttributes)) { return true; } } } + else if (targetType.flags & TypeFlags.Conditional) { + return isKnownProperty((targetType as ConditionalType).root.trueType, name, isComparingJsxAttributes) || + isKnownProperty((targetType as ConditionalType).root.falseType, name, isComparingJsxAttributes); + } return false; } @@ -17146,7 +17497,7 @@ namespace ts { // 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, checkMode); + const sourceAttributesType = checkExpressionCached(openingLikeElement.attributes, checkMode); // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties const isSourceAttributeTypeAssignableToTarget = isTypeAssignableTo(sourceAttributesType, targetAttributesType); @@ -17167,30 +17518,7 @@ namespace ts { } } else if (!isSourceAttributeTypeAssignableToTarget) { - // Assignability failure - check each prop individually, and if that fails, fall back on the bad error span - if (length(openingLikeElement.attributes.properties)) { - let reportedError = false; - for (const prop of openingLikeElement.attributes.properties) { - if (isJsxSpreadAttribute(prop)) continue; - const name = idText(prop.name); - const sourcePropType = getIndexedAccessType(sourceAttributesType, getLiteralType(name)); - const targetPropType = getIndexedAccessType(targetAttributesType, getLiteralType(name)); - const rootChain = () => chainDiagnosticMessages( - /*details*/ undefined, - Diagnostics.Types_of_property_0_are_incompatible, - name, - ); - if (!checkTypeAssignableTo(sourcePropType, targetPropType, prop, /*headMessage*/ undefined, rootChain)) { - reportedError = true; - } - } - - if (reportedError) { - return; - } - } - // Report fallback error on just the component name - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.tagName); + checkTypeAssignableToAndOptionallyElaborate(sourceAttributesType, targetAttributesType, openingLikeElement.tagName, openingLikeElement.attributes); } } @@ -17483,16 +17811,24 @@ namespace ts { return; } + let diagnosticMessage; + const declarationName = idText(right); if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { - error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, idText(right)); + diagnosticMessage = error(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } else if (valueDeclaration.kind === SyntaxKind.ClassDeclaration && node.parent.kind !== SyntaxKind.TypeReference && !(valueDeclaration.flags & NodeFlags.Ambient) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { - error(right, Diagnostics.Class_0_used_before_its_declaration, idText(right)); + diagnosticMessage = error(right, Diagnostics.Class_0_used_before_its_declaration, declarationName); + } + + if (diagnosticMessage) { + addRelatedInfo(diagnosticMessage, + createDiagnosticForNode(valueDeclaration, Diagnostics._0_is_declared_here, declarationName) + ); } } @@ -17541,6 +17877,7 @@ namespace ts { function reportNonexistentProperty(propNode: Identifier, containingType: Type) { let errorInfo: DiagnosticMessageChain | undefined; + let relatedInfo: Diagnostic | undefined; if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Primitive)) { for (const subtype of (containingType as UnionType).types) { if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -17554,30 +17891,34 @@ namespace ts { errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await, declarationNameToString(propNode), typeToString(containingType)); } else { - const suggestion = getSuggestionForNonexistentProperty(propNode, containingType); + const suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType); if (suggestion !== undefined) { - errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestion); + const suggestedName = symbolName(suggestion); + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestedName); + relatedInfo = suggestion.valueDeclaration && createDiagnosticForNode(suggestion.valueDeclaration, Diagnostics._0_is_declared_here, suggestedName); } else { - const suggestion = getSuggestionForNonexistentProperty(propNode, containingType); - if (suggestion !== undefined) { - errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestion); - } - else { - errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType)); - } + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType)); } } - diagnostics.add(createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); + const resultDiagnostic = createDiagnosticForNodeFromMessageChain(propNode, errorInfo); + if (relatedInfo) { + addRelatedInfo(resultDiagnostic, relatedInfo); + } + diagnostics.add(resultDiagnostic); + } + + function getSuggestedSymbolForNonexistentProperty(name: Identifier | string, containingType: Type): Symbol | undefined { + return getSpellingSuggestionForName(isString(name) ? name : idText(name), getPropertiesOfType(containingType), SymbolFlags.Value); } function getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined { - const suggestion = getSpellingSuggestionForName(isString(name) ? name : idText(name), getPropertiesOfType(containingType), SymbolFlags.Value); + const suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); return suggestion && symbolName(suggestion); } - function getSuggestionForNonexistentSymbol(location: Node | undefined, outerName: __String, meaning: SymbolFlags): string | undefined { + function getSuggestedSymbolForNonexistentSymbol(location: Node | undefined, outerName: __String, meaning: SymbolFlags): Symbol | undefined { Debug.assert(outerName !== undefined, "outername should always be defined"); const result = resolveNameHelper(location, outerName, meaning, /*nameNotFoundMessage*/ undefined, outerName, /*isUse*/ false, /*excludeGlobals*/ false, (symbols, name, meaning) => { Debug.assertEqual(outerName, name, "name should equal outerName"); @@ -17587,11 +17928,20 @@ namespace ts { // However, resolveNameHelper will continue and call this callback again, so we'll eventually get a correct suggestion. return symbol || getSpellingSuggestionForName(unescapeLeadingUnderscores(name), arrayFrom(symbols.values()), meaning); }); - return result && symbolName(result); + return result; + } + + function getSuggestionForNonexistentSymbol(location: Node | undefined, outerName: __String, meaning: SymbolFlags): string | undefined { + const symbolResult = getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning); + return symbolResult && symbolName(symbolResult); + } + + function getSuggestedSymbolForNonexistentModule(name: Identifier, targetModule: Symbol): Symbol | undefined { + return targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule), SymbolFlags.ModuleMember); } - function getSuggestionForNonexistentModule(name: Identifier, targetModule: Symbol): string | undefined { - const suggestion = targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule), SymbolFlags.ModuleMember); + function getSuggestionForNonexistentExport(name: Identifier, targetModule: Symbol): string | undefined { + const suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); return suggestion && symbolName(suggestion); } @@ -17892,7 +18242,7 @@ namespace ts { } } - function isSpreadArgument(arg: Expression | undefined) { + function isSpreadArgument(arg: Expression | undefined): arg is Expression { return !!arg && (arg.kind === SyntaxKind.SpreadElement || arg.kind === SyntaxKind.SyntheticExpression && (arg).isSpread); } @@ -17902,7 +18252,6 @@ namespace ts { function hasCorrectArity(node: CallLikeExpression, args: ReadonlyArray, signature: Signature, signatureHelpTrailingComma = false) { let argCount: number; // Apparent number of arguments we will have in this call - let typeArguments: NodeArray | undefined; // Type arguments (undefined if none) let callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments let spreadArgIndex = -1; @@ -17915,7 +18264,6 @@ namespace ts { // 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 = node.typeArguments; if (node.template.kind === SyntaxKind.TemplateExpression) { // If a tagged template expression lacks a tail literal, the call is incomplete. @@ -17933,7 +18281,6 @@ namespace ts { } } else if (node.kind === SyntaxKind.Decorator) { - typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined!, signature); } else { @@ -17948,14 +18295,9 @@ namespace ts { // If we are missing the close parenthesis, the call is incomplete. callIsIncomplete = node.arguments.end === node.end; - typeArguments = node.typeArguments; spreadArgIndex = getSpreadArgumentIndex(args); } - if (!hasCorrectTypeArgumentArity(signature, typeArguments)) { - return false; - } - // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature)); @@ -18070,8 +18412,8 @@ namespace ts { // We perform two passes over the arguments. In the first pass we infer from all arguments, but use // wildcards for all context sensitive function expressions. const effectiveArgCount = getEffectiveArgumentCount(node, args, signature); - const restTypeParameter = getRestTypeParameter(signature); - const argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; + const genericRestType = getGenericRestType(signature); + const argCount = genericRestType ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount; for (let i = 0; i < argCount; i++) { const arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. @@ -18090,9 +18432,9 @@ namespace ts { } } - if (restTypeParameter) { - const spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter, context); - inferTypes(context.inferences, spreadType, restTypeParameter); + if (genericRestType) { + const spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, genericRestType, context); + inferTypes(context.inferences, spreadType, genericRestType); } // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this @@ -18114,12 +18456,14 @@ namespace ts { } function getSpreadArgumentType(node: CallLikeExpression, args: ReadonlyArray, index: number, argCount: number, restType: TypeParameter, context: InferenceContext | undefined) { - if (index === argCount - 1) { - const arg = getEffectiveArgument(node, args, index); + if (index >= argCount - 1) { + const arg = getEffectiveArgument(node, args, argCount - 1); if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return checkExpressionWithContextualType((arg).expression, restType, context); + return arg.kind === SyntaxKind.SyntheticExpression ? + createArrayType((arg).type) : + checkExpressionWithContextualType((arg).expression, restType, context); } } const contextualType = getIndexTypeOfType(restType, IndexKind.Number) || anyType; @@ -18528,7 +18872,7 @@ namespace ts { node.kind === SyntaxKind.SetAccessor) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. - const propertyType = getTypeOfNode(node)!; // TODO: GH#18217 + const propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -18603,6 +18947,43 @@ namespace ts { } } + function getArgumentArityError(node: Node, signatures: ReadonlyArray, args: ReadonlyArray) { + let min = Number.POSITIVE_INFINITY; + let max = Number.NEGATIVE_INFINITY; + let belowArgCount = Number.NEGATIVE_INFINITY; + let aboveArgCount = Number.POSITIVE_INFINITY; + + let argCount = args.length; + for (const sig of signatures) { + const minCount = getMinArgumentCount(sig); + const maxCount = getParameterCount(sig); + if (minCount < argCount && minCount > belowArgCount) belowArgCount = minCount; + if (argCount < maxCount && maxCount < aboveArgCount) aboveArgCount = maxCount; + min = Math.min(min, minCount); + max = Math.max(max, maxCount); + } + + const hasRestParameter = some(signatures, hasEffectiveRestParameter); + const paramRange = hasRestParameter ? min : + min < max ? min + "-" + max : + min; + const hasSpreadArgument = getSpreadArgumentIndex(args) > -1; + if (argCount <= max && hasSpreadArgument) { + argCount--; + } + + if (hasRestParameter || hasSpreadArgument) { + const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : + hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 : + Diagnostics.Expected_0_arguments_but_got_1_or_more; + return createDiagnosticForNode(node, error, paramRange, argCount); + } + if (min < argCount && argCount < max) { + return createDiagnosticForNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); + } + return createDiagnosticForNode(node, Diagnostics.Expected_0_arguments_but_got_1, paramRange, argCount); + } + function getTypeArgumentArityError(node: Node, signatures: ReadonlyArray, typeArguments: NodeArray) { let min = Infinity; let max = -Infinity; @@ -18693,6 +19074,7 @@ namespace ts { // foo(0); // let candidateForArgumentError: Signature | undefined; + let candidateForArgumentArityError: Signature | undefined; let candidateForTypeArgumentError: Signature | undefined; let result: Signature | undefined; @@ -18737,78 +19119,32 @@ namespace ts { // an error, we don't need to exclude any arguments, although it would cause no harm to do so. checkApplicableSignature(node, args!, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } + else if (candidateForArgumentArityError) { + diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args!)); + } else if (candidateForTypeArgumentError) { checkTypeArguments(candidateForTypeArgumentError, (node as CallExpression | TaggedTemplateExpression).typeArguments!, /*reportErrors*/ true, fallbackError); } - else if (typeArguments && every(signatures, sig => length(sig.typeParameters) !== typeArguments!.length)) { + else if (typeArguments && every(signatures, sig => typeArguments!.length < getMinTypeArgumentCount(sig.typeParameters) || typeArguments!.length > length(sig.typeParameters))) { diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments)); } else if (args) { - let min = Number.POSITIVE_INFINITY; - let max = Number.NEGATIVE_INFINITY; - for (const sig of signatures) { - min = Math.min(min, getMinArgumentCount(sig)); - max = Math.max(max, getParameterCount(sig)); - } - const hasRestParameter = some(signatures, hasEffectiveRestParameter); - const hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - const paramCount = hasRestParameter ? min : - min < max ? min + "-" + max : - min; - let argCount = args.length; - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 : - hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_got_1_or_more : - Diagnostics.Expected_0_arguments_but_got_1; - diagnostics.add(createDiagnosticForNode(node, error, paramCount, argCount)); + diagnostics.add(getArgumentArityError(node, signatures, args)); } else if (fallbackError) { diagnostics.add(createDiagnosticForNode(node, fallbackError)); } - // No signature was applicable. We have already reported the errors for the invalid signature. - // If this is a type resolution session, e.g. Language Service, try to get better information than anySignature. - // Pick the longest signature. This way we can get a contextual type for cases like: - // declare function f(a: { xa: number; xb: number; }, b: number); - // f({ | - // Also, use explicitly-supplied type arguments if they are provided, so we can get a contextual signature in cases like: - // declare function f(k: keyof T); - // f(" - if (!produceDiagnostics) { - Debug.assert(candidates.length > 0); // Else would have exited above. - const bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args!.length : apparentArgumentCount); - const candidate = candidates[bestIndex]; - - const { typeParameters } = candidate; - if (typeParameters && callLikeExpressionMayHaveTypeArguments(node) && node.typeArguments) { - const typeArguments = node.typeArguments.map(getTypeOfNode) as Type[]; // TODO: GH#18217 - while (typeArguments.length > typeParameters.length) { - typeArguments.pop(); - } - while (typeArguments.length < typeParameters.length) { - typeArguments.push(getDefaultTypeArgumentType(isInJavaScriptFile(node))); - } - - const instantiated = createSignatureInstantiation(candidate, typeArguments); - candidates[bestIndex] = instantiated; - return instantiated; - } - - return candidate; - } - - return resolveErrorCall(node); + return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); function chooseOverload(candidates: Signature[], relation: Map, signatureHelpTrailingComma = false) { candidateForArgumentError = undefined; + candidateForArgumentArityError = undefined; candidateForTypeArgumentError = undefined; if (isSingleNonGenericCandidate) { const candidate = candidates[0]; - if (!hasCorrectArity(node, args!, candidate, signatureHelpTrailingComma)) { + if (typeArguments || !hasCorrectArity(node, args!, candidate, signatureHelpTrailingComma)) { return undefined; } if (!checkApplicableSignature(node, args!, candidate, relation, excludeArgument, /*reportErrors*/ false)) { @@ -18820,7 +19156,7 @@ namespace ts { for (let candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) { const originalCandidate = candidates[candidateIndex]; - if (!hasCorrectArity(node, args!, originalCandidate, signatureHelpTrailingComma)) { + if (!hasCorrectTypeArgumentArity(originalCandidate, typeArguments) || !hasCorrectArity(node, args!, originalCandidate, signatureHelpTrailingComma)) { continue; } @@ -18848,6 +19184,12 @@ namespace ts { } const isJavascript = isInJavaScriptFile(candidate.declaration); candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); + // If the original signature has a generic rest type, instantiation may produce a + // signature with different arity and we need to perform another arity check. + if (getGenericRestType(originalCandidate) && !hasCorrectArity(node, args!, candidate, signatureHelpTrailingComma)) { + candidateForArgumentArityError = candidate; + break; + } } if (!checkApplicableSignature(node, args!, candidate, relation, excludeArgument, /*reportErrors*/ false)) { candidateForArgumentError = candidate; @@ -18871,6 +19213,97 @@ namespace ts { } } + // No signature was applicable. We have already reported the errors for the invalid signature. + // If this is a type resolution session, e.g. Language Service, try to get better information than anySignature. + function getCandidateForOverloadFailure( + node: CallLikeExpression, + candidates: Signature[], + args: ReadonlyArray, + hasCandidatesOutArray: boolean, + ): Signature { + Debug.assert(candidates.length > 0); // Else should not have called this. + // Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine. + // Don't do this if there is a `candidatesOutArray`, + // because then we want the chosen best candidate to be one of the overloads, not a combination. + return hasCandidatesOutArray || candidates.length === 1 || candidates.some(c => !!c.typeParameters) + ? pickLongestCandidateSignature(node, candidates, args) + : createUnionOfSignaturesForOverloadFailure(candidates); + } + + function createUnionOfSignaturesForOverloadFailure(candidates: ReadonlyArray): Signature { + const thisParameters = mapDefined(candidates, c => c.thisParameter); + let thisParameter: Symbol | undefined; + if (thisParameters.length) { + thisParameter = createCombinedSymbolFromTypes(thisParameters, thisParameters.map(getTypeOfParameter)); + } + const { min: minArgumentCount, max: maxNonRestParam } = minAndMax(candidates, getNumNonRestParameters); + const parameters: Symbol[] = []; + for (let i = 0; i < maxNonRestParam; i++) { + const symbols = mapDefined(candidates, ({ parameters, hasRestParameter }) => hasRestParameter ? + i < parameters.length - 1 ? parameters[i] : last(parameters) : + i < parameters.length ? parameters[i] : undefined); + Debug.assert(symbols.length !== 0); + parameters.push(createCombinedSymbolFromTypes(symbols, mapDefined(candidates, candidate => tryGetTypeAtPosition(candidate, i)))); + } + const restParameterSymbols = mapDefined(candidates, c => c.hasRestParameter ? last(c.parameters) : undefined); + const hasRestParameter = restParameterSymbols.length !== 0; + if (hasRestParameter) { + const type = createArrayType(getUnionType(mapDefined(candidates, tryGetRestTypeOfSignature), UnionReduction.Subtype)); + parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); + } + return createSignature( + candidates[0].declaration, + /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. + thisParameter, + parameters, + /*resolvedReturnType*/ getIntersectionType(candidates.map(getReturnTypeOfSignature)), + /*typePredicate*/ undefined, + minArgumentCount, + hasRestParameter, + /*hasLiteralTypes*/ candidates.some(c => c.hasLiteralTypes)); + } + + function getNumNonRestParameters(signature: Signature): number { + const numParams = signature.parameters.length; + return signature.hasRestParameter ? numParams - 1 : numParams; + } + + function createCombinedSymbolFromTypes(sources: ReadonlyArray, types: Type[]): Symbol { + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, UnionReduction.Subtype)); + } + + function createCombinedSymbolForOverloadFailure(sources: ReadonlyArray, type: Type): Symbol { + // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. + return createSymbolWithType(first(sources), type); + } + + function pickLongestCandidateSignature(node: CallLikeExpression, candidates: Signature[], args: ReadonlyArray): Signature { + // Pick the longest signature. This way we can get a contextual type for cases like: + // declare function f(a: { xa: number; xb: number; }, b: number); + // f({ | + // Also, use explicitly-supplied type arguments if they are provided, so we can get a contextual signature in cases like: + // declare function f(k: keyof T); + // f(" + const bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount); + const candidate = candidates[bestIndex]; + const { typeParameters } = candidate; + if (!typeParameters) { + return candidate; + } + + const typeArgumentNodes: ReadonlyArray = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments || emptyArray : emptyArray; + const typeArguments = typeArgumentNodes.map(n => getTypeOfNode(n) || anyType); + while (typeArguments.length > typeParameters.length) { + typeArguments.pop(); + } + while (typeArguments.length < typeParameters.length) { + typeArguments.push(getConstraintFromTypeParameter(typeParameters[typeArguments.length]) || getDefaultTypeArgumentType(isInJavaScriptFile(node))); + } + const instantiated = createSignatureInstantiation(candidate, typeArguments); + candidates[bestIndex] = instantiated; + return instantiated; + } + function getLongestCandidateIndex(candidates: Signature[], argsCount: number): number { let maxParamsIndex = -1; let maxParams = -1; @@ -18894,7 +19327,9 @@ namespace ts { if (node.expression.kind === SyntaxKind.SuperKeyword) { const superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { - forEach(node.arguments, checkExpresionNoReturn); // Still visit arguments so they get marked for visibility, etc + for (const arg of node.arguments) { + checkExpression(arg); // Still visit arguments so they get marked for visibility, etc + } return anySignature; } if (superType !== errorType) { @@ -19046,6 +19481,38 @@ namespace ts { return resolveErrorCall(node); } + function typeHasProtectedAccessibleBase(target: Symbol, type: InterfaceType): boolean { + const baseTypes = getBaseTypes(type); + if (!length(baseTypes)) { + return false; + } + const firstBase = baseTypes[0]; + if (firstBase.flags & TypeFlags.Intersection) { + const types = (firstBase as IntersectionType).types; + const mixinCount = countWhere(types, isMixinConstructorType); + let i = 0; + for (const intersectionMember of (firstBase as IntersectionType).types) { + i++; + // We want to ignore mixin ctors + if (mixinCount === 0 || mixinCount === types.length && i === 0 || !isMixinConstructorType(intersectionMember)) { + if (getObjectFlags(intersectionMember) & (ObjectFlags.Class | ObjectFlags.Interface)) { + if (intersectionMember.symbol === target) { + return true; + } + if (typeHasProtectedAccessibleBase(target, intersectionMember as InterfaceType)) { + return true; + } + } + } + } + return false; + } + if (firstBase.symbol === target) { + return true; + } + return typeHasProtectedAccessibleBase(target, firstBase as InterfaceType); + } + function isConstructorAccessible(node: NewExpression, signature: Signature) { if (!signature || !signature.declaration) { return true; @@ -19065,16 +19532,10 @@ namespace ts { // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { const containingClass = getContainingClass(node); - if (containingClass) { + if (containingClass && modifiers & ModifierFlags.Protected) { const containingType = getTypeOfNode(containingClass); - let baseTypes = getBaseTypes(containingType as InterfaceType); - while (baseTypes.length) { - const baseType = baseTypes[0]; - if (modifiers & ModifierFlags.Protected && - baseType.symbol === declaration.parent.symbol) { - return true; - } - baseTypes = getBaseTypes(baseType as InterfaceType); + if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType as InterfaceType)) { + return true; } } if (modifiers & ModifierFlags.Private) { @@ -19106,8 +19567,10 @@ namespace ts { if (importNode && !isImportCall(importNode)) { const sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target!), kind); if (!sigs || !sigs.length) return; - diagnostic.relatedInformation = diagnostic.relatedInformation || []; - diagnostic.relatedInformation.push(createDiagnosticForNode(importNode, Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead)); + + addRelatedInfo(diagnostic, + createDiagnosticForNode(importNode, Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead) + ); } } @@ -19320,7 +19783,8 @@ namespace ts { function getAssignedClassType(symbol: Symbol) { const decl = symbol.valueDeclaration; const assignmentSymbol = decl && decl.parent && - (isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || + (isFunctionDeclaration(decl) && getSymbolOfNode(decl) || + isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); if (assignmentSymbol) { const prototype = forEach(assignmentSymbol.declarations, getAssignedJavascriptPrototype); @@ -19454,7 +19918,7 @@ namespace ts { } const specifier = node.arguments[0]; const specifierType = checkExpressionCached(specifier); - // Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion + // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion for (let i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } @@ -19626,6 +20090,10 @@ namespace ts { } function getTypeAtPosition(signature: Signature, pos: number): Type { + return tryGetTypeAtPosition(signature, pos) || anyType; + } + + function tryGetTypeAtPosition(signature: Signature, pos: number): Type | undefined { const paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); if (pos < paramCount) { return getTypeOfParameter(signature.parameters[pos]); @@ -19641,9 +20109,30 @@ namespace ts { return tupleRestType; } } - return getIndexTypeOfType(restType, IndexKind.Number) || anyType; + return getIndexTypeOfType(restType, IndexKind.Number); } - return anyType; + return undefined; + } + + function getRestTypeAtPosition(source: Signature, pos: number): Type { + const paramCount = getParameterCount(source); + const hasRest = hasEffectiveRestParameter(source); + if (hasRest && pos === paramCount - 1) { + const genericRestType = getGenericRestType(source); + if (genericRestType) { + return genericRestType; + } + } + const start = hasRest ? Math.min(pos, paramCount - 1) : pos; + const types = []; + const names = []; + for (let i = start; i < paramCount; i++) { + types.push(getTypeAtPosition(source, i)); + names.push(getParameterNameAtPosition(source, i)); + } + const minArgumentCount = getMinArgumentCount(source); + const minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + return createTupleType(types, minLength, hasRest, names); } function getTypeOfRestParameter(signature: Signature) { @@ -19681,11 +20170,11 @@ namespace ts { return signature.minArgumentCount; } - function getRestTypeParameter(signature: Signature) { + function getGenericRestType(signature: Signature) { if (signature.hasRestParameter) { const restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); - if (restType.flags & TypeFlags.TypeParameter) { - return restType; + if (restType.flags & TypeFlags.Instantiable) { + return restType; } } return undefined; @@ -19739,11 +20228,11 @@ namespace ts { assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { + if (signature.hasRestParameter) { // parameter might be a transient symbol generated by use of `arguments` in the function body. const parameter = last(signature.parameters); if (isTransientSymbol(parameter) || !getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - const contextualParameterType = getTypeOfSymbol(last(context.parameters)); + const contextualParameterType = getRestTypeAtPosition(context, len); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -20103,15 +20592,20 @@ namespace ts { return type; } + function getReturnOrPromisedType(node: FunctionLikeDeclaration | MethodSignature, functionFlags: FunctionFlags) { + const returnTypeNode = getEffectiveReturnTypeNode(node); + return returnTypeNode && + ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async ? + checkAsyncFunctionReturnType(node, returnTypeNode) : // Async function + getTypeFromTypeNode(returnTypeNode)) || // AsyncGenerator function, Generator function, or normal function + getReturnTypeOfTypeTag(node); // type from JSDoc @type tag + } + function checkFunctionExpressionOrObjectLiteralMethodDeferred(node: ArrowFunction | FunctionExpression | MethodDeclaration) { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); const functionFlags = getFunctionFlags(node); - const returnTypeNode = getEffectiveReturnTypeNode(node); - const returnOrPromisedType = returnTypeNode && - ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async ? - checkAsyncFunctionReturnType(node) : // Async function - getTypeFromTypeNode(returnTypeNode)); // AsyncGenerator function, Generator function, or normal function + const returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); if ((functionFlags & FunctionFlags.Generator) === 0) { // Async function or normal function // return is not necessary in the body of generators @@ -20119,7 +20613,7 @@ namespace ts { } if (node.body) { - if (!returnTypeNode) { + if (!getEffectiveReturnTypeNode(node)) { // There are some checks that are only performed in getReturnTypeFromBody, that may produce errors // we need. An example is the noImplicitAny errors resulting from widening the return expression // of a function. Because checking of function expression bodies is deferred, there was never an @@ -20141,10 +20635,10 @@ namespace ts { if (returnOrPromisedType) { if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async) { // Async function const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function - checkTypeAssignableTo(exprType, returnOrPromisedType, node.body); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body); } } } @@ -20562,7 +21056,7 @@ namespace ts { Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { - checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; } @@ -20779,7 +21273,7 @@ namespace ts { getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], UnionReduction.Subtype) : leftType; case SyntaxKind.EqualsToken: - const special = getSpecialPropertyAssignmentKind(left.parent as BinaryExpression); + const special = isBinaryExpression(left.parent) ? getSpecialPropertyAssignmentKind(left.parent) : SpecialPropertyAssignmentKind.None; checkSpecialAssignment(special, right); if (isJSSpecialPropertyAssignment(special)) { return leftType; @@ -20861,15 +21355,16 @@ namespace ts { if (checkReferenceExpression(left, Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) && (!isIdentifier(left) || unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } } } function isJSSpecialPropertyAssignment(special: SpecialPropertyAssignmentKind) { switch (special) { - case SpecialPropertyAssignmentKind.ExportsProperty: case SpecialPropertyAssignmentKind.ModuleExports: + return true; + case SpecialPropertyAssignmentKind.ExportsProperty: case SpecialPropertyAssignmentKind.Property: case SpecialPropertyAssignmentKind.Prototype: case SpecialPropertyAssignmentKind.PrototypeProperty: @@ -20884,7 +21379,30 @@ namespace ts { } function reportOperatorError() { - error(errorNode || operatorToken, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, tokenToString(operatorToken.kind), typeToString(leftType), typeToString(rightType)); + const leftStr = typeToString(leftType); + const rightStr = typeToString(rightType); + const errNode = errorNode || operatorToken; + if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + error( + errNode, + Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, + tokenToString(operatorToken.kind), + leftStr, + rightStr, + ); + } + } + + function tryGiveBetterPrimaryError(errNode: Node, leftStr: string, rightStr: string) { + switch (operatorToken.kind) { + case SyntaxKind.EqualsEqualsEqualsToken: + case SyntaxKind.EqualsEqualsToken: + return error(errNode, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); + case SyntaxKind.ExclamationEqualsEqualsToken: + case SyntaxKind.ExclamationEqualsToken: + return error(errNode, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); + } + return undefined; } } @@ -20950,7 +21468,7 @@ namespace ts { const returnType = getEffectiveReturnTypeNode(func); if (returnType) { const signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(returnType), isAsync) || anyType; - checkTypeAssignableTo(yieldedType, signatureElementType, node.expression || node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } // Both yield and yield* expressions have type 'any' @@ -21160,10 +21678,6 @@ namespace ts { return type; } - function checkExpresionNoReturn(node: Expression) { - checkExpression(node); - } - // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the // expression is being inferentially typed (section 4.15.2 in spec) and provides the type mapper to use in @@ -21357,6 +21871,9 @@ namespace ts { if (func.kind === SyntaxKind.Constructor || func.kind === SyntaxKind.ConstructSignature || func.kind === SyntaxKind.ConstructorType) { error(node, Diagnostics.A_constructor_cannot_have_a_this_parameter); } + if (func.kind === SyntaxKind.ArrowFunction) { + error(node, Diagnostics.An_arrow_function_cannot_have_a_this_parameter); + } } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are @@ -21406,7 +21923,7 @@ namespace ts { else { const leadingError = () => chainDiagnosticMessages(/*details*/ undefined, Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); checkTypeAssignableTo(typePredicate.type, - getTypeOfNode(parent.parameters[typePredicate.parameterIndex])!, // TODO: GH#18217 + getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type, /*headMessage*/ undefined, leadingError); @@ -21548,7 +22065,7 @@ namespace ts { } } else if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async) { - checkAsyncFunctionReturnType(node); + checkAsyncFunctionReturnType(node, returnTypeNode); } } if (node.kind !== SyntaxKind.IndexSignature && node.kind !== SyntaxKind.JSDocFunctionType) { @@ -22072,7 +22589,7 @@ namespace ts { return hasModifier(node, ModifierFlags.Private) && !!(node.flags & NodeFlags.Ambient); } - function getEffectiveDeclarationFlags(n: Node, flagsToCheck: ModifierFlags): ModifierFlags { + function getEffectiveDeclarationFlags(n: Declaration, flagsToCheck: ModifierFlags): ModifierFlags { let flags = getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export @@ -22608,7 +23125,7 @@ namespace ts { * * @param node The signature to check */ - function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration | MethodSignature): Type { + function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration | MethodSignature, returnTypeNode: TypeNode): Type { // As part of our emit for an async function, we will need to emit the entity name of // the return type annotation as an expression. To meet the necessary runtime semantics // for __awaiter, we must also check that the type of the declaration (e.g. the static @@ -22633,7 +23150,6 @@ namespace ts { // then(...): Promise; // } // - const returnTypeNode = getEffectiveReturnTypeNode(node)!; // TODO: GH#18217 const returnType = getTypeFromTypeNode(returnTypeNode); if (languageVersion >= ScriptTarget.ES2015) { @@ -22738,7 +23254,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - const methodType = getTypeOfNode(node.parent)!; // TODO: GH#18217 + const methodType = getTypeOfNode(node.parent); const descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); break; @@ -23043,15 +23559,12 @@ namespace ts { const body = node.kind === SyntaxKind.MethodSignature ? undefined : node.body; checkSourceElement(body); - const returnTypeNode = getEffectiveReturnTypeNode(node); if ((functionFlags & FunctionFlags.Generator) === 0) { // Async function or normal function - const returnOrPromisedType = returnTypeNode && (functionFlags & FunctionFlags.Async - ? checkAsyncFunctionReturnType(node) // Async function - : getTypeFromTypeNode(returnTypeNode)); // normal function + const returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } - if (produceDiagnostics && !returnTypeNode) { + if (produceDiagnostics && !getEffectiveReturnTypeNode(node)) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method // in an ambient context if (noImplicitAny && nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { @@ -23065,6 +23578,14 @@ namespace ts { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } } + + // A js function declaration can have a @type tag instead of a return type node, but that type must have a call signature + if (isInJavaScriptFile(node)) { + const typeTag = getJSDocTypeTag(node); + if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) { + error(typeTag, Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature); + } + } } function registerForUnusedIdentifiersCheck(node: PotentiallyUnusedIdentifier): void { @@ -23136,7 +23657,7 @@ namespace ts { function errorUnusedLocal(declaration: Declaration, name: string, addDiagnostic: AddUnusedDiagnostic) { const node = getNameOfDeclaration(declaration) || declaration; const message = isTypeDeclaration(declaration) ? Diagnostics._0_is_declared_but_never_used : Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(UnusedKind.Local, createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, UnusedKind.Local, createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node: Node) { @@ -23157,13 +23678,13 @@ namespace ts { } const symbol = getSymbolOfNode(member); if (!symbol.isReferenced && hasModifier(member, ModifierFlags.Private)) { - addDiagnostic(UnusedKind.Local, createDiagnosticForNode(member.name!, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + addDiagnostic(member, UnusedKind.Local, createDiagnosticForNode(member.name!, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; case SyntaxKind.Constructor: for (const parameter of (member).parameters) { if (!parameter.symbol.isReferenced && hasModifier(parameter, ModifierFlags.Private)) { - addDiagnostic(UnusedKind.Local, createDiagnosticForNode(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, symbolName(parameter.symbol))); + addDiagnostic(parameter, UnusedKind.Local, createDiagnosticForNode(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, symbolName(parameter.symbol))); } } break; @@ -23188,7 +23709,7 @@ namespace ts { if (!(node.flags & NodeFlags.Ambient) && last(getSymbolOfNode(node).declarations) === node) { for (const typeParameter of typeParameters) { if (!(getMergedSymbol(typeParameter.symbol).isReferenced! & SymbolFlags.TypeParameter) && !isIdentifierThatStartsWithUnderscore(typeParameter.name)) { - addDiagnostic(UnusedKind.Parameter, createDiagnosticForNode(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(typeParameter.symbol))); + addDiagnostic(typeParameter, UnusedKind.Parameter, createDiagnosticForNode(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(typeParameter.symbol))); } } } @@ -23244,10 +23765,10 @@ namespace ts { } else { const parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - const name = getNameOfDeclaration(local.valueDeclaration); + const name = local.valueDeclaration && getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { if (!isParameterPropertyDeclaration(parameter) && !parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { - addDiagnostic(UnusedKind.Parameter, createDiagnosticForNode(name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(local))); + addDiagnostic(parameter, UnusedKind.Parameter, createDiagnosticForNode(name, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolName(local))); } } else { @@ -23263,7 +23784,7 @@ namespace ts { (importClause.namedBindings.kind === SyntaxKind.NamespaceImport ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(UnusedKind.Local, unuseds.length === 1 + addDiagnostic(importDecl, UnusedKind.Local, unuseds.length === 1 ? createDiagnosticForNode(importDecl, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(first(unuseds).name!)) : createDiagnosticForNode(importDecl, Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -23278,26 +23799,26 @@ namespace ts { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { - addDiagnostic(kind, bindingElements.length === 1 + addDiagnostic(bindingPattern, kind, bindingElements.length === 1 ? createDiagnosticForNode(bindingPattern, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(first(bindingElements).name, isIdentifier))) : createDiagnosticForNode(bindingPattern, Diagnostics.All_destructured_elements_are_unused)); } } else { for (const e of bindingElements) { - addDiagnostic(kind, createDiagnosticForNode(e, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(e.name, isIdentifier)))); + addDiagnostic(e, kind, createDiagnosticForNode(e, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(e.name, isIdentifier)))); } } }); unusedVariables.forEach(([declarationList, declarations]) => { if (declarationList.declarations.length === declarations.length) { - addDiagnostic(UnusedKind.Local, declarations.length === 1 + addDiagnostic(declarationList, UnusedKind.Local, declarations.length === 1 ? createDiagnosticForNode(first(declarations).name, Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(first(declarations).name)) : createDiagnosticForNode(declarationList.parent.kind === SyntaxKind.VariableStatement ? declarationList.parent : declarationList, Diagnostics.All_variables_are_unused)); } else { for (const decl of declarations) { - addDiagnostic(UnusedKind.Local, createDiagnosticForNode(decl, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(decl.name, isIdentifier)))); + addDiagnostic(decl, UnusedKind.Local, createDiagnosticForNode(decl, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(decl.name, isIdentifier)))); } } }); @@ -23671,7 +24192,7 @@ namespace ts { checkNonNullType(initializerType, node); } else { - checkTypeAssignableTo(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer); } checkParameterInitializer(node); } @@ -23689,7 +24210,7 @@ namespace ts { (initializer.properties.length === 0 || isPrototypeAccess(node.name)) && hasEntries(symbol.exports); if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== SyntaxKind.ForInStatement) { - checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -23705,7 +24226,7 @@ namespace ts { errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(getNameOfDeclaration(symbol.valueDeclaration), Diagnostics.All_declarations_of_0_must_have_identical_modifiers, declarationNameToString(node.name)); @@ -23878,7 +24399,7 @@ namespace ts { // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); + checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } } } @@ -24322,11 +24843,11 @@ namespace ts { } } else if (func.kind === SyntaxKind.Constructor) { - if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { + if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } - else if (getEffectiveReturnTypeNode(func) || isGetAccessorWithAnnotatedSetAccessor(func)) { + else if (getEffectiveReturnTypeNode(func) || isGetAccessorWithAnnotatedSetAccessor(func) || getReturnTypeOfTypeTag(func)) { if (functionFlags & FunctionFlags.Async) { // Async function const promisedType = getPromisedTypeOfPromise(returnType); const awaitedType = checkAwaitedType(exprType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -24338,7 +24859,7 @@ namespace ts { } } else { - checkTypeAssignableTo(exprType, returnType, node); + checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); } } } @@ -24541,7 +25062,7 @@ namespace ts { } const propDeclaration = prop.valueDeclaration; - const name = getNameOfDeclaration(propDeclaration); + const name = propDeclaration && getNameOfDeclaration(propDeclaration); // index is numeric and property name is not valid numeric literal if (indexKind === IndexKind.Number && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { @@ -25125,7 +25646,7 @@ namespace ts { } // In ambient enum declarations that specify no const modifier, enum member declarations that omit // a value are considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & NodeFlags.Ambient && !isConst(member.parent)) { + if (member.parent.flags & NodeFlags.Ambient && !isEnumConst(member.parent)) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -25141,7 +25662,7 @@ namespace ts { function computeConstantValue(member: EnumMember): string | number | undefined { const enumKind = getEnumKind(getSymbolOfNode(member.parent)); - const isConstEnum = isConst(member.parent); + const isConstEnum = isEnumConst(member.parent); const initializer = member.initializer!; const value = enumKind === EnumKind.Literal && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { @@ -25276,7 +25797,7 @@ namespace ts { computeEnumMemberValues(node); - const enumIsConst = isConst(node); + const enumIsConst = isEnumConst(node); if (compilerOptions.isolatedModules && enumIsConst && node.flags & NodeFlags.Ambient) { error(node.name, Diagnostics.Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided); } @@ -25293,7 +25814,7 @@ namespace ts { if (enumSymbol.declarations.length > 1) { // check that const is placed\omitted on all enum declarations forEach(enumSymbol.declarations, decl => { - if (isConstEnumDeclaration(decl) !== enumIsConst) { + if (isEnumDeclaration(decl) && isEnumConst(decl) !== enumIsConst) { error(getNameOfDeclaration(decl), Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); @@ -26091,6 +26612,12 @@ namespace ts { case SyntaxKind.ClassExpression: checkClassExpressionDeferred(node); break; + case SyntaxKind.JsxSelfClosingElement: + checkJsxSelfClosingElementDeferred(node); + break; + case SyntaxKind.JsxElement: + checkJsxElementDeferred(node); + break; } }); } @@ -26144,8 +26671,8 @@ namespace ts { } if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { - checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), (kind, diag) => { - if (unusedIsError(kind)) { + checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), (containingNode, kind, diag) => { + if (!containsParseError(containingNode) && unusedIsError(kind)) { diagnostics.add(diag); } }); @@ -26671,7 +27198,7 @@ namespace ts { resolveEntityName(node.propertyName || node.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } - function getTypeOfNode(node: Node): Type | undefined { + function getTypeOfNode(node: Node): Type { if (node.flags & NodeFlags.InWithStatement) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; @@ -26710,7 +27237,7 @@ namespace ts { if (isTypeDeclarationName(node)) { const symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); + return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; } if (isDeclaration(node)) { @@ -26721,11 +27248,11 @@ namespace ts { if (isDeclarationNameOrImportPropertyName(node)) { const symbol = getSymbolAtLocation(node); - return symbol && getTypeOfSymbol(symbol); + return symbol ? getTypeOfSymbol(symbol) : errorType; } if (isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true); + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { @@ -27151,8 +27678,9 @@ namespace ts { const symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & SymbolFlags.EnumMember)) { // inline property\index accesses only for const enums - if (isConstEnumDeclaration(symbol.valueDeclaration.parent)) { - return getEnumMemberValue(symbol.valueDeclaration); + const member = symbol.valueDeclaration as EnumMember; + if (isEnumConst(member.parent)) { + return getEnumMemberValue(member); } } @@ -27306,7 +27834,7 @@ namespace ts { } function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { - if (isConst(node)) { + if (isVariableDeclaration(node) && isVarConst(node)) { const type = getTypeOfSymbol(getSymbolOfNode(node)); return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral); } @@ -27505,9 +28033,14 @@ namespace ts { bindSourceFile(file, compilerOptions); } + amalgamatedDuplicates = createMap(); + // Initialize global symbol table let augmentations: ReadonlyArray[] | undefined; for (const file of host.getSourceFiles()) { + if (file.redirectInfo) { + continue; + } if (!isExternalOrCommonJsModule(file)) { mergeSymbolTable(globals, file.locals!); } @@ -27582,6 +28115,39 @@ namespace ts { } } } + + amalgamatedDuplicates.forEach(({ firstFile, secondFile, firstFileInstances, secondFileInstances }) => { + const conflictingKeys = arrayFrom(firstFileInstances.keys()); + // If not many things conflict, issue individual errors + if (conflictingKeys.length < 8) { + addErrorsForDuplicates(firstFileInstances, secondFileInstances); + addErrorsForDuplicates(secondFileInstances, firstFileInstances); + return; + } + // Otheriwse issue top-level error since the files appear very identical in terms of what they appear + const list = conflictingKeys.join(", "); + diagnostics.add(addRelatedInfo( + createDiagnosticForNode(firstFile, Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), + createDiagnosticForNode(secondFile, Diagnostics.Conflicts_are_in_this_file) + )); + diagnostics.add(addRelatedInfo( + createDiagnosticForNode(secondFile, Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), + createDiagnosticForNode(firstFile, Diagnostics.Conflicts_are_in_this_file) + )); + }); + amalgamatedDuplicates = undefined; + + function addErrorsForDuplicates(secondFileInstances: Map<{ instances: Node[]; blockScoped: boolean; }>, firstFileInstances: Map<{ instances: Node[]; blockScoped: boolean; }>) { + secondFileInstances.forEach((locations, symbolName) => { + const firstFileEquivalent = firstFileInstances.get(symbolName)!; + const message = locations.blockScoped + ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : Diagnostics.Duplicate_identifier_0; + locations.instances.forEach(node => { + addDuplicateDeclarationError(node, message, symbolName, firstFileEquivalent.instances[0]); + }); + }); + } } function checkExternalEmitHelpers(location: Node, helpers: ExternalEmitHelpers) { @@ -28611,7 +29177,7 @@ namespace ts { if (node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) { if (node.flags & NodeFlags.Ambient) { if (node.initializer) { - if (isConst(node) && !node.type) { + if (isVarConst(node) && !node.type) { if (!isStringOrNumberLiteralExpression(node.initializer)) { return grammarErrorOnNode(node.initializer, Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal); } @@ -28622,7 +29188,7 @@ namespace ts { return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } } - if (node.initializer && !(isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { + if (node.initializer && !(isVarConst(node) && isStringOrNumberLiteralExpression(node.initializer))) { // Error on equals token which immediate precedes the initializer const equalsTokenLength = "=".length; return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); @@ -28632,7 +29198,7 @@ namespace ts { if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (isConst(node)) { + if (isVarConst(node)) { return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); } } @@ -28647,7 +29213,7 @@ namespace ts { checkESModuleMarker(node.name); } - const checkLetConstNames = (isLet(node) || isConst(node)); + const checkLetConstNames = (isLet(node) || isVarConst(node)); // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". @@ -28727,7 +29293,7 @@ namespace ts { if (isLet(node.declarationList)) { return grammarErrorOnNode(node, Diagnostics.let_declarations_can_only_be_declared_inside_a_block); } - else if (isConst(node.declarationList)) { + else if (isVarConst(node.declarationList)) { return grammarErrorOnNode(node, Diagnostics.const_declarations_can_only_be_declared_inside_a_block); } } @@ -29009,6 +29575,11 @@ namespace ts { export const Element = "Element" as __String; export const IntrinsicAttributes = "IntrinsicAttributes" as __String; export const IntrinsicClassAttributes = "IntrinsicClassAttributes" as __String; + export const LibraryManagedAttributes = "LibraryManagedAttributes" as __String; // tslint:enable variable-name } + + function typeIsLiteralType(type: Type): type is LiteralType { + return !!(type.flags & TypeFlags.Literal); + } } diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index 989935a5edbf3..7dfda66c96579 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -72,11 +72,13 @@ namespace ts { const savedContainerEnd = containerEnd; const savedDeclarationListContainerEnd = declarationListContainerEnd; - if (!skipLeadingComments) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & EmitFlags.NoLeadingComments) !== 0)) { + // Advance the container position of comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & EmitFlags.NoTrailingComments) !== 0)) { + // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we @@ -426,4 +428,4 @@ namespace ts { return isRecognizedTripleSlashComment(currentText, commentPos, commentEnd); } } -} \ No newline at end of file +} diff --git a/src/compiler/core.ts b/src/compiler/core.ts index ff905db8dbf54..5ddc706aa2205 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1,7 +1,7 @@ namespace ts { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - export const versionMajorMinor = "3.0"; + export const versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ export const version = `${versionMajorMinor}.0-dev`; } @@ -531,7 +531,7 @@ namespace ts { return result; } - export function flatMapIterator(iter: Iterator, mapfn: (x: T) => U[] | Iterator | undefined): Iterator { + export function flatMapIterator(iter: Iterator, mapfn: (x: T) => ReadonlyArray | Iterator | undefined): Iterator { const first = iter.next(); if (first.done) { return emptyIterator; @@ -1418,7 +1418,9 @@ namespace ts { return typeof text === "string"; } - export function tryCast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined { + export function tryCast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined; + export function tryCast(value: T, test: (value: T) => boolean): T | undefined; + export function tryCast(value: T, test: (value: T) => boolean): T | undefined { return value !== undefined && test(value) ? value : undefined; } @@ -1864,6 +1866,9 @@ namespace ts { if (candidateName !== undefined && Math.abs(candidateName.length - nameLowerCase.length) <= maximumLengthDifference) { const candidateNameLowerCase = candidateName.toLowerCase(); if (candidateNameLowerCase === nameLowerCase) { + if (candidateName === name) { + continue; + } return candidate; } if (justCheckExactMatches) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 48c98970bde60..a9118945b055c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -971,7 +971,7 @@ "category": "Error", "code": 1339 }, - "Module '{0}' does not refer to a type, but is used as a type here.": { + "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?": { "category": "Error", "code": 1340 }, @@ -983,6 +983,10 @@ "category": "Error", "code": 1343 }, + "'A label is not allowed here.": { + "category": "Error", + "code": 1344 + }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -1252,6 +1256,10 @@ "category": "Error", "code": 2366 }, + "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap.": { + "category": "Error", + "code": 2367 + }, "Type parameter name cannot be '{0}'.": { "category": "Error", "code": 2368 @@ -1448,6 +1456,10 @@ "category": "Error", "code": 2417 }, + "Type of computed property's value is '{0}', which is not assignable to type '{1}'.": { + "category": "Error", + "code": 2418 + }, "Class '{0}' incorrectly implements interface '{1}'.": { "category": "Error", "code": 2420 @@ -2048,6 +2060,10 @@ "category": "Error", "code": 2574 }, + "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments.": { + "category": "Error", + "code": 2575 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 @@ -2393,6 +2409,18 @@ "category": "Error", "code": 2727 }, + "'{0}' is declared here.": { + "category": "Message", + "code": 2728 + }, + "Property '{0}' is used before its initialization.": { + "category": "Error", + "code": 2729 + }, + "An arrow function cannot have a 'this' parameter.": { + "category": "Error", + "code": 2730 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -2848,6 +2876,10 @@ "category": "Error", "code": 5070 }, + "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs'.": { + "category": "Error", + "code": 5071 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", @@ -3599,6 +3631,22 @@ "code": 6199, "reportsUnnecessary": true }, + "Definitions of the following identifiers conflict with those in another file: {0}": { + "category": "Error", + "code": 6200 + }, + "Conflicts are in this file.": { + "category": "Message", + "code": 6201 + }, + "'{0}' was also declared here.": { + "category": "Message", + "code": 6203 + }, + "and here.": { + "category": "Message", + "code": 6204 + }, "Projects to reference": { "category": "Message", @@ -3726,6 +3774,15 @@ "code": 6371 }, + "The expected type comes from property '{0}' which is declared here on type '{1}'": { + "category": "Message", + "code": 6500 + }, + "The expected type comes from this index signature.": { + "category": "Message", + "code": 6501 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 @@ -3845,7 +3902,7 @@ "code": 7037 }, "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.": { - "category": "Error", + "category": "Message", "code": 7038 }, "Mapped object type implicitly has an 'any' template type.": { @@ -3972,6 +4029,10 @@ "category": "Error", "code": 8029 }, + "The type of a function declaration must match the function's signature.": { + "category": "Error", + "code": 8030 + }, "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": { "category": "Error", "code": 9002 @@ -4442,5 +4503,13 @@ "Convert named export to default export": { "category": "Message", "code": 95062 + }, + "Add missing enum member '{0}'": { + "category": "Message", + "code": 95063 + }, + "Add all missing imports": { + "category": "Message", + "code": 95064 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 6e9e747d19f87..3b3fac5c7a53c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -43,17 +43,17 @@ namespace ts { if (sourceFile.kind === SyntaxKind.Bundle) { const jsFilePath = options.outFile || options.out!; const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = (forceDtsPaths || options.declaration) ? removeFileExtension(jsFilePath) + Extension.Dts : undefined; + const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(jsFilePath) + Extension.Dts : undefined; const declarationMapPath = getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; const bundleInfoPath = options.references && jsFilePath ? (removeFileExtension(jsFilePath) + infoExtension) : undefined; return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath }; } else { - const jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); + const jsFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); const sourceMapFilePath = isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error const isJs = isSourceFileJavaScript(sourceFile); - const declarationFilePath = ((forceDtsPaths || options.declaration) && !isJs) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + const declarationFilePath = ((forceDtsPaths || getEmitDeclarations(options)) && !isJs) ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; const declarationMapPath = getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath: undefined }; } @@ -192,7 +192,7 @@ namespace ts { // Setup and perform the transformation to retrieve declarations from the input files const nonJsFiles = filter(sourceFiles, isSourceFileNotJavaScript); const inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [createBundle(nonJsFiles, !isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; - if (emitOnlyDtsFiles && !compilerOptions.declaration) { + if (emitOnlyDtsFiles && !getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files nonJsFiles.forEach(collectLinkedAliases); @@ -1983,7 +1983,7 @@ namespace ts { } function emitVariableDeclarationList(node: VariableDeclarationList) { - writeKeyword(isLet(node) ? "let" : isConst(node) ? "const" : "var"); + writeKeyword(isLet(node) ? "let" : isVarConst(node) ? "const" : "var"); writeSpace(); emitList(node, node.declarations, ListFormat.VariableDeclarationList); } @@ -2451,7 +2451,7 @@ namespace ts { function emitJsxTagName(node: JsxTagNameExpression) { if (node.kind === SyntaxKind.Identifier) { - emitExpression(node); + emitExpression(node); } else { emit(node); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index b8b77193ed067..86911417cb6e3 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -272,10 +272,9 @@ namespace ts { } function parenthesizeForComputedName(expression: Expression): Expression { - return (isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken) || - expression.kind === SyntaxKind.CommaListExpression ? - createParen(expression) : - expression; + return isCommaSequence(expression) + ? createParen(expression) + : expression; } export function createComputedPropertyName(expression: Expression) { @@ -1170,7 +1169,7 @@ namespace ts { return node; } - /* @deprecated */ export function updateArrowFunction( + /** @deprecated */ export function updateArrowFunction( node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, @@ -1319,7 +1318,7 @@ namespace ts { return node; } - /* @deprecated */ export function updateConditional( + /** @deprecated */ export function updateConditional( node: ConditionalExpression, condition: Expression, whenTrue: Expression, @@ -1531,13 +1530,6 @@ namespace ts { return block; } - /* @internal */ - export function createExpressionStatement(expression: Expression): ExpressionStatement { - const node = createSynthesizedNode(SyntaxKind.ExpressionStatement); - node.expression = expression; - return node; - } - export function updateBlock(node: Block, statements: ReadonlyArray) { return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) @@ -1563,16 +1555,23 @@ namespace ts { return createSynthesizedNode(SyntaxKind.EmptyStatement); } - export function createStatement(expression: Expression) { - return createExpressionStatement(parenthesizeExpressionForExpressionStatement(expression)); + export function createExpressionStatement(expression: Expression): ExpressionStatement { + const node = createSynthesizedNode(SyntaxKind.ExpressionStatement); + node.expression = parenthesizeExpressionForExpressionStatement(expression); + return node; } - export function updateStatement(node: ExpressionStatement, expression: Expression) { + export function updateExpressionStatement(node: ExpressionStatement, expression: Expression) { return node.expression !== expression - ? updateNode(createStatement(expression), node) + ? updateNode(createExpressionStatement(expression), node) : node; } + /** @deprecated Use `createExpressionStatement` instead. */ + export const createStatement = createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + export const updateStatement = updateExpressionStatement; + export function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement) { const node = createSynthesizedNode(SyntaxKind.IfStatement); node.expression = expression; @@ -4166,8 +4165,7 @@ namespace ts { // 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 const emittedExpression = skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === SyntaxKind.BinaryExpression && (emittedExpression).operatorToken.kind === SyntaxKind.CommaToken || - emittedExpression.kind === SyntaxKind.CommaListExpression + return isCommaSequence(emittedExpression) ? createParen(e) : e; } @@ -4185,12 +4183,15 @@ namespace ts { */ export function parenthesizeDefaultExpression(e: Expression) { const check = skipPartiallyEmittedExpressions(e); - return (check.kind === SyntaxKind.ClassExpression || - check.kind === SyntaxKind.FunctionExpression || - check.kind === SyntaxKind.CommaListExpression || - isBinaryExpression(check) && check.operatorToken.kind === SyntaxKind.CommaToken) - ? createParen(e) - : e; + let needsParens = isCommaSequence(check); + if (!needsParens) { + switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { + case SyntaxKind.ClassExpression: + case SyntaxKind.FunctionExpression: + needsParens = true; + } + } + return needsParens ? createParen(e) : e; } /** @@ -4355,18 +4356,21 @@ namespace ts { node = (node).condition; continue; + case SyntaxKind.TaggedTemplateExpression: + node = (node).tag; + continue; + case SyntaxKind.CallExpression: if (stopAtCallExpressions) { return node; } // falls through + case SyntaxKind.AsExpression: case SyntaxKind.ElementAccessExpression: case SyntaxKind.PropertyAccessExpression: - node = (node).expression; - continue; - + case SyntaxKind.NonNullExpression: case SyntaxKind.PartiallyEmittedExpression: - node = (node).expression; + node = (node).expression; continue; } @@ -4376,13 +4380,18 @@ namespace ts { } export function parenthesizeConciseBody(body: ConciseBody): ConciseBody { - if (!isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === SyntaxKind.ObjectLiteralExpression) { + if (!isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === SyntaxKind.ObjectLiteralExpression)) { return setTextRange(createParen(body), body); } return body; } + export function isCommaSequence(node: Expression): node is BinaryExpression & {operatorToken: Token} | CommaListExpression { + return node.kind === SyntaxKind.BinaryExpression && (node).operatorToken.kind === SyntaxKind.CommaToken || + node.kind === SyntaxKind.CommaListExpression; + } + export const enum OuterExpressionKinds { Parentheses = 1 << 0, Assertions = 1 << 1, diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 349cabd6da615..b243ff348146f 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -9,7 +9,7 @@ namespace ts.moduleSpecifiers { export function getModuleSpecifier( compilerOptions: CompilerOptions, importingSourceFile: SourceFile, - importingSourceFileName: string, + importingSourceFileName: Path, toFileName: string, host: ModuleSpecifierResolutionHost, files: ReadonlyArray, @@ -18,7 +18,6 @@ namespace ts.moduleSpecifiers { const info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host); const modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host); return firstDefined(modulePaths, moduleFileName => getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions)) || - getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); } @@ -49,10 +48,10 @@ namespace ts.moduleSpecifiers { readonly moduleResolutionKind: ModuleResolutionKind; readonly addJsExtension: boolean; readonly getCanonicalFileName: GetCanonicalFileName; - readonly sourceDirectory: string; + readonly sourceDirectory: Path; } // importingSourceFileName is separate because getEditsForFileRename may need to specify an updated path - function getInfo(compilerOptions: CompilerOptions, importingSourceFile: SourceFile, importingSourceFileName: string, host: ModuleSpecifierResolutionHost): Info { + function getInfo(compilerOptions: CompilerOptions, importingSourceFile: SourceFile, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost): Info { const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); const addJsExtension = usesJsExtensionOnImports(importingSourceFile); const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true); @@ -67,8 +66,7 @@ namespace ts.moduleSpecifiers { compilerOptions: CompilerOptions, ) { return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory); } function getLocalModuleSpecifiers( @@ -76,10 +74,11 @@ namespace ts.moduleSpecifiers { { moduleResolutionKind, addJsExtension, getCanonicalFileName, sourceDirectory }: Info, compilerOptions: CompilerOptions, preferences: ModuleSpecifierPreferences, - ) { - const { baseUrl, paths } = compilerOptions; + ): ReadonlyArray { + const { baseUrl, paths, rootDirs } = compilerOptions; - const relativePath = removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { return [relativePath]; } @@ -150,10 +149,11 @@ namespace ts.moduleSpecifiers { const result = createMap(); if (symlinks) { const currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + const compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? compareStringsCaseSensitive : compareStringsCaseInsensitive; for (const [resolvedPath, originalPath] of symlinks) { const resolvedParts = getPathComponents(toPath(resolvedPath, currentDirectory, getCanonicalFileName)); const originalParts = getPathComponents(toPath(originalPath, currentDirectory, getCanonicalFileName)); - while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { + while (compareStrings(resolvedParts[resolvedParts.length - 1], originalParts[originalParts.length - 1]) === Comparison.EqualTo) { resolvedParts.pop(); originalParts.pop(); } @@ -194,7 +194,12 @@ namespace ts.moduleSpecifiers { const symlinks = mapDefined(files, sf => sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => res && res.resolvedFileName === importedFileName ? res.originalPath : undefined)); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; + const cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + const baseOptions = getAllModulePathsUsingIndirectSymlinks(files, getNormalizedAbsolutePath(importedFileName, cwd), getCanonicalFileName, host); + if (symlinks.length === 0) { + return baseOptions; + } + return deduplicate(concatenate(baseOptions, flatMap(symlinks, importedFileName => getAllModulePathsUsingIndirectSymlinks(files, getNormalizedAbsolutePath(importedFileName, cwd), getCanonicalFileName, host)))); } function getRelativePathNParents(relativePath: string): number { @@ -218,10 +223,7 @@ namespace ts.moduleSpecifiers { for (const patternText of paths[key]) { const pattern = removeFileExtension(normalizePath(patternText)); const indexOfStar = pattern.indexOf("*"); - if (indexOfStar === 0 && pattern.length === 1) { - continue; - } - else if (indexOfStar !== -1) { + if (indexOfStar !== -1) { const prefix = pattern.substr(0, indexOfStar); const suffix = pattern.substr(indexOfStar + 1); if (relativeToBaseUrl.length >= prefix.length + suffix.length && @@ -271,7 +273,7 @@ namespace ts.moduleSpecifiers { moduleFileName: string, host: ModuleSpecifierResolutionHost, getCanonicalFileName: (file: string) => string, - sourceDirectory: string, + sourceDirectory: Path, ): string | undefined { if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { // nothing to do here @@ -290,7 +292,7 @@ namespace ts.moduleSpecifiers { const moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) return undefined; + if (!startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; // If the module was found in @types, get the actual Node package name return getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d71edf64fed12..070e774d82f7b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -494,9 +494,9 @@ namespace ts { case SyntaxKind.JSDocSignature: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || - visitNodes(cbNode, cbNodes, (node).typeParameters) || - visitNodes(cbNode, cbNodes, (node).parameters) || - visitNode(cbNode, (node).type); + forEach((node).typeParameters, cbNode) || + forEach((node).parameters, cbNode) || + visitNode(cbNode, (node).type); case SyntaxKind.JSDocTypeLiteral: if ((node as JSDocTypeLiteral).jsDocPropertyTags) { for (const tag of (node as JSDocTypeLiteral).jsDocPropertyTags!) { @@ -1509,7 +1509,9 @@ namespace ts { case ParsingContext.ArgumentExpressions: return token() === SyntaxKind.DotDotDotToken || isStartOfExpression(); case ParsingContext.Parameters: - return isStartOfParameter(); + return isStartOfParameter(/*isJSDocParameter*/ false); + case ParsingContext.JSDocParameters: + return isStartOfParameter(/*isJSDocParameter*/ true); case ParsingContext.TypeArguments: case ParsingContext.TupleElementTypes: return token() === SyntaxKind.CommaToken || isStartOfType(); @@ -1612,6 +1614,7 @@ namespace ts { case ParsingContext.TupleElementTypes: case ParsingContext.ArrayBindingElements: return token() === SyntaxKind.CloseBracketToken; + case ParsingContext.JSDocParameters: case ParsingContext.Parameters: case ParsingContext.RestProperties: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery @@ -1795,6 +1798,7 @@ namespace ts { case ParsingContext.VariableDeclarations: return isReusableVariableDeclaration(node); + case ParsingContext.JSDocParameters: case ParsingContext.Parameters: return isReusableParameter(node); @@ -2009,6 +2013,7 @@ namespace ts { case ParsingContext.ArgumentExpressions: return Diagnostics.Argument_expression_expected; case ParsingContext.ObjectLiteralMembers: return Diagnostics.Property_assignment_expected; case ParsingContext.ArrayLiteralMembers: return Diagnostics.Expression_or_comma_expected; + case ParsingContext.JSDocParameters: return Diagnostics.Parameter_declaration_expected; case ParsingContext.Parameters: return Diagnostics.Parameter_declaration_expected; case ParsingContext.TypeParameters: return Diagnostics.Type_parameter_declaration_expected; case ParsingContext.TypeArguments: return Diagnostics.Type_argument_expected; @@ -2090,8 +2095,18 @@ namespace ts { return result; } - function createMissingList(): NodeArray { - return createNodeArray([], getNodePos()); + interface MissingList extends NodeArray { + isMissingList: true; + } + + function createMissingList(): MissingList { + const list = createNodeArray([], getNodePos()) as MissingList; + list.isMissingList = true; + return list; + } + + function isMissingList(arr: NodeArray): boolean { + return !!(arr as MissingList).isMissingList; } function parseBracketedList(kind: ParsingContext, parseElement: () => T, open: SyntaxKind, close: SyntaxKind): NodeArray { @@ -2260,8 +2275,7 @@ namespace ts { case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: { const { parameters, type } = node as FunctionOrConstructorTypeNode; - // parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()` - return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type); + return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } case SyntaxKind.ParenthesizedType: return typeHasArrowFunctionBlockingParseError((node as ParenthesizedTypeNode).type); @@ -2421,12 +2435,12 @@ namespace ts { return undefined; } - function isStartOfParameter(): boolean { + function isStartOfParameter(isJSDocParameter: boolean): boolean { return token() === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token()) || token() === SyntaxKind.AtToken || - isStartOfType(/*inStartOfParameter*/ true); + isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter(): ParameterDeclaration { @@ -2525,7 +2539,9 @@ namespace ts { setYieldContext(!!(flags & SignatureFlags.Yield)); setAwaitContext(!!(flags & SignatureFlags.Await)); - signature.parameters = parseDelimitedList(ParsingContext.Parameters, flags & SignatureFlags.JSDoc ? parseJSDocParameter : parseParameter); + signature.parameters = flags & SignatureFlags.JSDoc ? + parseDelimitedList(ParsingContext.JSDocParameters, parseJSDocParameter) : + parseDelimitedList(ParsingContext.Parameters, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -2951,6 +2967,8 @@ namespace ts { case SyntaxKind.InferKeyword: case SyntaxKind.ImportKeyword: return true; + case SyntaxKind.FunctionKeyword: + return !inStartOfParameter; case SyntaxKind.MinusToken: return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case SyntaxKind.OpenParenToken: @@ -2964,7 +2982,7 @@ namespace ts { function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === SyntaxKind.CloseParenToken || isStartOfParameter() || isStartOfType(); + return token() === SyntaxKind.CloseParenToken || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher(): TypeNode { @@ -3519,8 +3537,9 @@ namespace ts { } // If we had "(" followed by something that's not an identifier, - // then this definitely doesn't look like a lambda. - if (!isIdentifier()) { + // then this definitely doesn't look like a lambda. "this" is not + // valid, but we want to parse it and then give a semantic error. + if (!isIdentifier() && second !== SyntaxKind.ThisKeyword) { return Tristate.False; } @@ -4314,9 +4333,9 @@ namespace ts { // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression let expression: JsxTagNameExpression = token() === SyntaxKind.ThisKeyword ? - parseTokenNode() : parseIdentifierName(); + parseTokenNode() : parseIdentifierName(); while (parseOptional(SyntaxKind.DotToken)) { - const propertyAccess: PropertyAccessExpression = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); + const propertyAccess: JsxTagNamePropertyAccess = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -6246,6 +6265,7 @@ namespace ts { JsxChildren, // Things between opening and closing JSX tags ArrayLiteralMembers, // Members in array literal Parameters, // Parameters in parameter list + JSDocParameters, // JSDoc parameters in parameter list of JSDoc function type RestProperties, // Property names in a rest type list TypeParameters, // Type parameters in type parameter list TypeArguments, // Type arguments in type argument list @@ -7646,7 +7666,8 @@ namespace ts { } } - function isDeclarationFileName(fileName: string): boolean { + /** @internal */ + export function isDeclarationFileName(fileName: string): boolean { return fileExtensionIs(fileName, Extension.Dts); } @@ -7886,7 +7907,7 @@ namespace ts { } if (lhs.kind === SyntaxKind.Identifier) { - return (lhs).escapedText === (rhs).escapedText; + return lhs.escapedText === (rhs).escapedText; } if (lhs.kind === SyntaxKind.ThisKeyword) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b1a94e8e2030e..59ac93f467ef3 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -135,7 +135,7 @@ namespace ts { sys.writeFile(fileName, data, writeByteOrderMark); - const mtimeAfter = sys.getModifiedTime!(fileName); // TODO: GH#18217 + const mtimeAfter = sys.getModifiedTime!(fileName) || missingFileModifiedTime; // TODO: GH#18217 outputFingerprints.set(fileName, { hash, @@ -329,16 +329,17 @@ namespace ts { return context; } - function formatLocation(file: SourceFile, start: number, host: FormatDiagnosticsHost) { + /* @internal */ + export function formatLocation(file: SourceFile, start: number, host: FormatDiagnosticsHost, color = formatColorAndReset) { const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); // TODO: GH#18217 const relativeFileName = host ? convertToRelativePath(file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : file.fileName; let output = ""; - output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan); + output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += formatColorAndReset(`${firstLine + 1}`, ForegroundColorEscapeSequences.Yellow); + output += color(`${firstLine + 1}`, ForegroundColorEscapeSequences.Yellow); output += ":"; - output += formatColorAndReset(`${firstLineChar + 1}`, ForegroundColorEscapeSequences.Yellow); + output += color(`${firstLineChar + 1}`, ForegroundColorEscapeSequences.Yellow); return output; } @@ -591,6 +592,7 @@ namespace ts { const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); const supportedExtensions = getSupportedExtensions(options); + const supportedExtensionsWithJsonIfResolveJsonModule = options.resolveJsonModule ? [...supportedExtensions, Extension.Json] : undefined; // Map storing if there is emit blocking diagnostics for given input const hasEmitBlockingDiagnostics = createMap(); @@ -1248,6 +1250,7 @@ namespace ts { return host.fileExists(f); }, ...(host.directoryExists ? { directoryExists: f => host.directoryExists!(f) } : {}), + useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(), }; } @@ -1923,7 +1926,7 @@ namespace ts { refFile?: SourceFile): SourceFile | undefined { if (hasExtension(fileName)) { - if (!options.allowNonTsExtensions && !forEach(supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) { + if (!options.allowNonTsExtensions && !forEach(supportedExtensionsWithJsonIfResolveJsonModule || supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) { if (fail) fail(Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'"); return undefined; } @@ -2005,9 +2008,17 @@ namespace ts { if (filesByName.has(path)) { const file = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path - // NOTE: this only makes sense for case-insensitive file systems - if (file && options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== getNormalizedAbsolutePath(fileName, currentDirectory)) { - reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd); + // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected + if (file && options.forceConsistentCasingInFileNames) { + let inputName = fileName; + const checkedName = file.fileName; + const isRedirect = toPath(checkedName) !== toPath(inputName); + if (isRedirect) { + inputName = getProjectReferenceRedirect(fileName) || fileName; + } + if (getNormalizedAbsolutePath(checkedName, currentDirectory) !== getNormalizedAbsolutePath(inputName, currentDirectory)) { + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + } } // If the file was previously found via a node_modules search, but is now being processed as a root file, @@ -2327,7 +2338,7 @@ namespace ts { if (!sourceFile.isDeclarationFile) { const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); allFilesBelongToPath = false; } } @@ -2342,7 +2353,7 @@ namespace ts { const refPath = resolveProjectReferencePath(host, ref); // An absolute path pointing to the containing directory of the config file const basePath = getNormalizedAbsolutePath(getDirectoryPath(refPath), host.getCurrentDirectory()); - const sourceFile = host.getSourceFile(refPath, ScriptTarget.JSON) as JsonSourceFile; + const sourceFile = host.getSourceFile(refPath, ScriptTarget.JSON) as JsonSourceFile | undefined; if (sourceFile === undefined) { return undefined; } @@ -2363,7 +2374,7 @@ namespace ts { } function verifyCompilerOptions() { - if (options.strictPropertyInitialization && !options.strictNullChecks) { + if (options.strictPropertyInitialization && !getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } @@ -2498,7 +2509,7 @@ namespace ts { } } - if (options.declarationMap && !options.declaration) { + if (options.declarationMap && !getEmitDeclarations(options)) { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "declarationMap", "declaration"); } @@ -2546,6 +2557,10 @@ namespace ts { if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } + // Any emit other than common js is error + else if (getEmitModuleKind(options) !== ModuleKind.CommonJS) { + createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs, "resolveJsonModule", "module"); + } } // there has to be common source directory if user specified --outdir || --sourceRoot @@ -2821,10 +2836,14 @@ namespace ts { }; } + export interface ResolveProjectReferencePathHost { + fileExists(fileName: string): boolean; + } /** - * Returns the target config filename of a project reference + * Returns the target config filename of a project reference. + * Note: The file might not exist. */ - export function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName { + export function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName { if (!host.fileExists(ref.path)) { return combinePaths(ref.path, "tsconfig.json") as ResolvedConfigFileName; } diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index d5f574762a1c8..d05d83505089a 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -81,6 +81,7 @@ namespace ts { let filesWithInvalidatedResolutions: Map | undefined; let filesWithInvalidatedNonRelativeUnresolvedImports: Map> | undefined; let allFilesHaveInvalidatedResolution = false; + const nonRelativeExternalModuleResolutions = createMultiMap(); const getCurrentDirectory = memoize(() => resolutionHost.getCurrentDirectory!()); // TODO: GH#18217 const cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); @@ -154,6 +155,7 @@ namespace ts { function clear() { clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf); customFailedLookupPaths.clear(); + nonRelativeExternalModuleResolutions.clear(); closeTypeRootsWatch(); resolvedModuleNames.clear(); resolvedTypeReferenceDirectives.clear(); @@ -199,19 +201,20 @@ namespace ts { perDirectoryResolvedModuleNames.clear(); nonRelaticeModuleNameCache.clear(); perDirectoryResolvedTypeReferenceDirectives.clear(); + nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); + nonRelativeExternalModuleResolutions.clear(); } function finishCachingPerDirectoryResolution() { allFilesHaveInvalidatedResolution = false; filesWithInvalidatedNonRelativeUnresolvedImports = undefined; + clearPerDirectoryResolutions(); directoryWatchesOfFailedLookups.forEach((watcher, path) => { if (watcher.refCount === 0) { directoryWatchesOfFailedLookups.delete(path); watcher.watcher.close(); } }); - - clearPerDirectoryResolutions(); } function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): CachedResolvedModuleWithFailedLookupLocations { @@ -275,7 +278,7 @@ namespace ts { perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); - watchFailedLookupLocationOfResolution(resolution); + watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution); if (existingResolution) { stopWatchFailedLookupLocationOfResolution(existingResolution); } @@ -441,18 +444,27 @@ namespace ts { return fileExtensionIsOneOf(path, failedLookupDefaultExtensions); } - function watchFailedLookupLocationOfResolution(resolution: ResolutionWithFailedLookupLocations) { + function watchFailedLookupLocationsOfExternalModuleResolutions(name: string, resolution: ResolutionWithFailedLookupLocations) { // No need to set the resolution refCount - if (!resolution.failedLookupLocations || !resolution.failedLookupLocations.length) { - return; + if (resolution.failedLookupLocations && resolution.failedLookupLocations.length) { + if (resolution.refCount) { + resolution.refCount++; + } + else { + resolution.refCount = 1; + if (isExternalModuleNameRelative(name)) { + watchFailedLookupLocationOfResolution(resolution); + } + else { + nonRelativeExternalModuleResolutions.add(name, resolution); + } + } } + } - if (resolution.refCount !== undefined) { - resolution.refCount++; - return; - } + function watchFailedLookupLocationOfResolution(resolution: ResolutionWithFailedLookupLocations) { + Debug.assert(!!resolution.refCount); - resolution.refCount = 1; const { failedLookupLocations } = resolution; let setAtRoot = false; for (const failedLookupLocation of failedLookupLocations) { @@ -480,6 +492,16 @@ namespace ts { } } + function setRefCountToUndefined(resolution: ResolutionWithFailedLookupLocations) { + resolution.refCount = undefined; + } + + function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions: ResolutionWithFailedLookupLocations[], name: string) { + const updateResolution = resolutionHost.getCurrentProgram().getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ? + setRefCountToUndefined : watchFailedLookupLocationOfResolution; + resolutions.forEach(updateResolution); + } + function setDirectoryWatcher(dir: string, dirPath: Path, nonRecursive?: boolean) { const dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); if (dirWatcher) { @@ -492,11 +514,11 @@ namespace ts { } function stopWatchFailedLookupLocationOfResolution(resolution: ResolutionWithFailedLookupLocations) { - if (!resolution.failedLookupLocations || !resolution.failedLookupLocations.length) { + if (!resolution.refCount) { return; } - resolution.refCount!--; + resolution.refCount--; if (resolution.refCount) { return; } diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 8dfe91a6cff67..eff543849cd39 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -156,7 +156,6 @@ namespace ts { sourceMapNames: [], sourceMapMappings: "", sourceMapSourcesContent: compilerOptions.inlineSources ? [] : undefined, - sourceMapDecodedMappings: [] }; // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -171,7 +170,7 @@ namespace ts { 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(sourceFileOrBundle, host, sourceMapDir)); + sourceMapDir = getDirectoryPath(getSourceFilePathInNewDir(sourceFileOrBundle.fileName, host, sourceMapDir)); } if (!isRootedDiskPath(sourceMapDir) && !isUrl(sourceMapDir)) { @@ -216,17 +215,6 @@ namespace ts { sourceMapDataList = undefined!; } - interface SourceMapSection { - version: 3; - file: string; - sourceRoot?: string; - sources: string[]; - names?: string[]; - mappings: string; - sourcesContent?: (string | null)[]; - sections?: undefined; - } - type SourceMapSectionDefinition = | { offset: { line: number, column: number }, url: string } // Included for completeness | { offset: { line: number, column: number }, map: SourceMap }; @@ -299,7 +287,6 @@ namespace ts { } lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } /** @@ -393,24 +380,29 @@ namespace ts { const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; const resolvedPathCache = createMap(); - sourcemaps.calculateDecodedMappings(originalMap, (raw): void => { + const absolutePathCache = createMap(); + const sourcemapIterator = sourcemaps.decodeMappings(originalMap); + for (let { value: raw, done } = sourcemapIterator.next(); !done; { value: raw, done } = sourcemapIterator.next()) { + const pathCacheKey = "" + raw.sourceIndex; // Apply offsets to each position and fixup source entries - const rawPath = originalMap.sources[raw.sourceIndex]; - const relativePath = originalMap.sourceRoot ? combinePaths(originalMap.sourceRoot, rawPath) : rawPath; - const combinedPath = combinePaths(getDirectoryPath(node.sourceMapPath!), relativePath); - if (!resolvedPathCache.has(combinedPath)) { - resolvedPathCache.set(combinedPath, getRelativePathToDirectoryOrUrl( + if (!resolvedPathCache.has(pathCacheKey)) { + const rawPath = originalMap.sources[raw.sourceIndex]; + const relativePath = originalMap.sourceRoot ? combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + const combinedPath = combinePaths(getDirectoryPath(node.sourceMapPath!), relativePath); + const resolvedPath = getRelativePathToDirectoryOrUrl( sourcesDirectoryPath, combinedPath, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true - )); + ); + resolvedPathCache.set(pathCacheKey, resolvedPath); + absolutePathCache.set(pathCacheKey, getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath)); } - const resolvedPath = resolvedPathCache.get(combinedPath)!; - const absolutePath = getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath); + const resolvedPath = resolvedPathCache.get(pathCacheKey)!; + const absolutePath = absolutePathCache.get(pathCacheKey)!; // tslint:disable-next-line:no-null-keyword - setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null, resolvedPath); // TODO: Lookup content for inlining? const newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); // Then reencode all the updated spans into the overall map encodeLastRecordedSourceMapSpan(); @@ -420,7 +412,7 @@ namespace ts { emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset) : raw.emittedColumn, sourceIndex: newIndex, }; - }); + } // And actually emit the text these sourcemaps are for return emitCallback(hint, node); } @@ -519,17 +511,19 @@ namespace ts { setupSourceEntry(sourceFile.fileName, sourceFile.text); } - function setupSourceEntry(fileName: string, content: string | null) { - // Add the file to tsFilePaths - // If sourceroot option: Use the relative path corresponding to the common directory path - // otherwise source locations relative to map file location - const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; - - const source = getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, - fileName, - host.getCurrentDirectory(), - host.getCanonicalFileName, - /*isAbsolutePathAnUrl*/ true); + function setupSourceEntry(fileName: string, content: string | null, source?: string) { + if (!source) { + // Add the file to tsFilePaths + // If sourceroot option: Use the relative path corresponding to the common directory path + // otherwise source locations relative to map file location + const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + + source = getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, + fileName, + host.getCurrentDirectory(), + host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true); + } sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); if (sourceMapSourceIndex === -1) { @@ -577,6 +571,17 @@ namespace ts { } } + export interface SourceMapSection { + version: 3; + file: string; + sourceRoot?: string; + sources: string[]; + names?: string[]; + mappings: string; + sourcesContent?: (string | null)[]; + sections?: undefined; + } + const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function base64FormatEncode(inValue: number) { diff --git a/src/compiler/sourcemapDecoder.ts b/src/compiler/sourcemapDecoder.ts index 290f7699e5dfe..76f5943be66d4 100644 --- a/src/compiler/sourcemapDecoder.ts +++ b/src/compiler/sourcemapDecoder.ts @@ -61,7 +61,7 @@ namespace ts.sourcemaps { export function decode(host: SourceMapDecodeHost, mapPath: string, map: SourceMapData, program?: Program, fallbackCache = createSourceFileLikeCache(host)): SourceMapper { const currentDirectory = getDirectoryPath(mapPath); - const sourceRoot = map.sourceRoot || currentDirectory; + const sourceRoot = map.sourceRoot ? getNormalizedAbsolutePath(map.sourceRoot, currentDirectory) : currentDirectory; let decodedMappings: ProcessedSourceMapPosition[]; let generatedOrderedMappings: ProcessedSourceMapPosition[]; let sourceOrderedMappings: ProcessedSourceMapPosition[]; @@ -98,10 +98,10 @@ namespace ts.sourcemaps { function getSourceFileLike(fileName: string, location: string): SourceFileLike | undefined { // Lookup file in program, if provided - const file = program && program.getSourceFile(fileName); + const path = toPath(fileName, location, host.getCanonicalFileName); + const file = program && program.getSourceFile(path); if (!file) { // Otherwise check the cache (which may hit disk) - const path = toPath(fileName, location, host.getCanonicalFileName); return fallbackCache.get(path); } return file; @@ -190,7 +190,7 @@ namespace ts.sourcemaps { }; } - export function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { log?(s: string): void }): T[] { + function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { log?(s: string): void }): T[] { const decoder = decodeMappings(map); const positions = arrayFrom(decoder, processPosition); if (decoder.error) { diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index 5d41fa15b122b..cce6739d3596c 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -171,8 +171,8 @@ namespace ts { } const t = getTypeOfSymbol(symbol); visitType(t); // Should handle members on classes and such - if (symbol.flags & SymbolFlags.HasExports) { - symbol.exports!.forEach(visitSymbol); + if (symbol.exports) { + symbol.exports.forEach(visitSymbol); } forEach(symbol.declarations, d => { // Type queries are too far resolved when we just visit the symbol's type diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index e9f15b6fa84ca..8f6a58a3567c9 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -332,9 +332,9 @@ namespace ts { /*@internal*/ export interface RecursiveDirectoryWatcherHost { watchDirectory: HostWatchDirectory; + useCaseSensitiveFileNames: boolean; getAccessibleSortedChildDirectories(path: string): ReadonlyArray; directoryExists(dir: string): boolean; - filePathComparer: Comparer; realpath(s: string): string; } @@ -345,60 +345,94 @@ namespace ts { */ /*@internal*/ export function createRecursiveDirectoryWatcher(host: RecursiveDirectoryWatcherHost): (directoryName: string, callback: DirectoryWatcherCallback) => FileWatcher { - type ChildWatches = ReadonlyArray; - interface DirectoryWatcher extends FileWatcher { - childWatches: ChildWatches; + interface ChildDirectoryWatcher extends FileWatcher { dirName: string; } + type ChildWatches = ReadonlyArray; + interface HostDirectoryWatcher { + watcher: FileWatcher; + childWatches: ChildWatches; + refCount: number; + } + + const cache = createMap(); + const callbackCache = createMultiMap(); + const filePathComparer = getStringComparer(!host.useCaseSensitiveFileNames); + const toCanonicalFilePath = createGetCanonicalFileName(host.useCaseSensitiveFileNames); return createDirectoryWatcher; /** * Create the directory watcher for the dirPath. */ - function createDirectoryWatcher(dirName: string, callback: DirectoryWatcherCallback): DirectoryWatcher { - const watcher = host.watchDirectory(dirName, fileName => { - // Call the actual callback - callback(fileName); + function createDirectoryWatcher(dirName: string, callback?: DirectoryWatcherCallback): ChildDirectoryWatcher { + const dirPath = toCanonicalFilePath(dirName) as Path; + let directoryWatcher = cache.get(dirPath); + if (directoryWatcher) { + directoryWatcher.refCount++; + } + else { + directoryWatcher = { + watcher: host.watchDirectory(dirName, fileName => { + // Call the actual callback + callbackCache.forEach((callbacks, rootDirName) => { + if (rootDirName === dirPath || (startsWith(dirPath, rootDirName) && dirPath[rootDirName.length] === directorySeparator)) { + callbacks.forEach(callback => callback(fileName)); + } + }); - // Iterate through existing children and update the watches if needed - updateChildWatches(result, callback); - }); + // Iterate through existing children and update the watches if needed + updateChildWatches(dirName, dirPath); + }), + refCount: 1, + childWatches: emptyArray + }; + cache.set(dirPath, directoryWatcher); + updateChildWatches(dirName, dirPath); + } - let result: DirectoryWatcher = { - close: () => { - watcher.close(); - result.childWatches.forEach(closeFileWatcher); - result = undefined!; - }, + if (callback) { + callbackCache.add(dirPath, callback); + } + + return { dirName, - childWatches: emptyArray + close: () => { + const directoryWatcher = Debug.assertDefined(cache.get(dirPath)); + if (callback) callbackCache.remove(dirPath, callback); + directoryWatcher.refCount--; + + if (directoryWatcher.refCount) return; + + cache.delete(dirPath); + closeFileWatcherOf(directoryWatcher); + directoryWatcher.childWatches.forEach(closeFileWatcher); + } }; - updateChildWatches(result, callback); - return result; } - function updateChildWatches(watcher: DirectoryWatcher, callback: DirectoryWatcherCallback) { + function updateChildWatches(dirName: string, dirPath: Path) { // Iterate through existing children and update the watches if needed - if (watcher) { - watcher.childWatches = watchChildDirectories(watcher.dirName, watcher.childWatches, callback); + const parentWatcher = cache.get(dirPath); + if (parentWatcher) { + parentWatcher.childWatches = watchChildDirectories(dirName, parentWatcher.childWatches); } } /** * Watch the directories in the parentDir */ - function watchChildDirectories(parentDir: string, existingChildWatches: ChildWatches, callback: DirectoryWatcherCallback): ChildWatches { - let newChildWatches: DirectoryWatcher[] | undefined; - enumerateInsertsAndDeletes( + function watchChildDirectories(parentDir: string, existingChildWatches: ChildWatches): ChildWatches { + let newChildWatches: ChildDirectoryWatcher[] | undefined; + enumerateInsertsAndDeletes( host.directoryExists(parentDir) ? mapDefined(host.getAccessibleSortedChildDirectories(parentDir), child => { const childFullName = getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return host.filePathComparer(childFullName, host.realpath(childFullName)) === Comparison.EqualTo ? childFullName : undefined; + return filePathComparer(childFullName, normalizePath(host.realpath(childFullName))) === Comparison.EqualTo ? childFullName : undefined; }) : emptyArray, existingChildWatches, - (child, childWatcher) => host.filePathComparer(child, childWatcher.dirName), + (child, childWatcher) => filePathComparer(child, childWatcher.dirName), createAndAddChildDirectoryWatcher, closeFileWatcher, addChildDirectoryWatcher @@ -410,14 +444,14 @@ namespace ts { * Create new childDirectoryWatcher and add it to the new ChildDirectoryWatcher list */ function createAndAddChildDirectoryWatcher(childName: string) { - const result = createDirectoryWatcher(childName, callback); + const result = createDirectoryWatcher(childName); addChildDirectoryWatcher(result); } /** * Add child directory watcher to the new ChildDirectoryWatcher list */ - function addChildDirectoryWatcher(childWatcher: DirectoryWatcher) { + function addChildDirectoryWatcher(childWatcher: ChildDirectoryWatcher) { (newChildWatches || (newChildWatches = [])).push(childWatcher); } } @@ -448,7 +482,7 @@ namespace ts { getCurrentDirectory(): string; getDirectories(path: string): string[]; readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; - getModifiedTime?(path: string): Date; + getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; /** @@ -469,6 +503,7 @@ namespace ts { /*@internal*/ setBlocking?(): void; base64decode?(input: string): string; base64encode?(input: string): string; + /*@internal*/ bufferFrom?(input: string, encoding?: string): Buffer; } export interface FileWatcher { @@ -524,7 +559,7 @@ namespace ts { getEnvironmentVariable?(name: string): string; }; - // TODO: this is used as if it's certainly defined in many places. + // TODO: GH#18217 this is used as if it's certainly defined in many places. export let sys: System = (() => { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -641,19 +676,19 @@ namespace ts { process.stdout._handle.setBlocking(true); } }, - base64decode: Buffer.from ? input => { - return Buffer.from!(input, "base64").toString("utf8"); - } : input => { - return new Buffer(input, "base64").toString("utf8"); - }, - base64encode: Buffer.from ? input => { - return Buffer.from!(input).toString("base64"); - } : input => { - return new Buffer(input).toString("base64"); - } + bufferFrom, + base64decode: input => bufferFrom(input, "base64").toString("utf8"), + base64encode: input => bufferFrom(input).toString("base64"), }; return nodeSystem; + function bufferFrom(input: string, encoding?: string): Buffer { + // See https://github.com/Microsoft/TypeScript/issues/25652 + return Buffer.from && (Buffer.from as Function) !== Int8Array.from + ? Buffer.from(input, encoding) + : new Buffer(input, encoding); + } + function isFileSystemCaseSensitive(): boolean { // win32\win64 are case insensitive platforms if (platform === "win32" || platform === "win64") { @@ -710,7 +745,7 @@ namespace ts { createWatchDirectoryUsing(dynamicPollingWatchFile || createDynamicPriorityPollingWatchFile({ getModifiedTime, setTimeout })) : watchDirectoryUsingFsWatch; const watchDirectoryRecursively = createRecursiveDirectoryWatcher({ - filePathComparer: getStringComparer(!useCaseSensitiveFileNames), + useCaseSensitiveFileNames, directoryExists, getAccessibleSortedChildDirectories: path => getAccessibleFileSystemEntries(path).directories, watchDirectory, diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 35fb8e99170bb..dcfc50dd007de 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -11,11 +11,12 @@ namespace ts { const declarationEmitNodeBuilderFlags = NodeBuilderFlags.MultilineObjectLiterals | - TypeFormatFlags.WriteClassExpressionAsTypeLiteral | + NodeBuilderFlags.WriteClassExpressionAsTypeLiteral | NodeBuilderFlags.UseTypeOfFunction | NodeBuilderFlags.UseStructuralFallback | NodeBuilderFlags.AllowEmptyTuple | - NodeBuilderFlags.GenerateNamesForShadowedTypeParams; + NodeBuilderFlags.GenerateNamesForShadowedTypeParams | + NodeBuilderFlags.NoTruncation; /** * Transforms a ts file into a .d.ts file @@ -66,7 +67,13 @@ namespace ts { } } - function trackReferencedAmbientModule(node: ModuleDeclaration) { + function trackReferencedAmbientModule(node: ModuleDeclaration, symbol: Symbol) { + // If it is visible via `// `, then we should just use that + const directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, SymbolFlags.All); + if (length(directives)) { + return recordTypeReferenceDirectivesIfNecessary(directives); + } + // Otherwise we should emit a path-based reference const container = getSourceFileOfNode(node); refs.set("" + getOriginalNodeId(container), container); } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 8e2b487f13f2a..bffdc5809b0e8 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -529,7 +529,7 @@ namespace ts { createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList(taggedTemplateStringDeclarations))); } - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); return updateSourceFileNode( node, @@ -837,7 +837,7 @@ namespace ts { setEmitFlags(statement, EmitFlags.NoComments | EmitFlags.NoTokenSourceMaps); statements.push(statement); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const block = createBlock(setTextRange(createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); setEmitFlags(block, EmitFlags.NoComments); @@ -855,7 +855,7 @@ namespace ts { if (extendsClauseElement) { statements.push( setTextRange( - createStatement( + createExpressionStatement( createExtendsHelper(context, getInternalName(node)) ), /*location*/ extendsClauseElement @@ -980,7 +980,7 @@ namespace ts { ); } - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); @@ -1121,7 +1121,7 @@ namespace ts { } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression || createActualThis(), firstStatement); + captureThisForNode(statements, ctor, superCallExpression || createActualThis()); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { @@ -1280,7 +1280,7 @@ namespace ts { else if (initializer) { statements.push( setEmitFlags( - createStatement( + createExpressionStatement( createAssignment( temp, visitNode(initializer, visitor, isExpression) @@ -1307,7 +1307,7 @@ namespace ts { setEmitFlags( setTextRange( createBlock([ - createStatement( + createExpressionStatement( setEmitFlags( setTextRange( createAssignment( @@ -1409,7 +1409,7 @@ namespace ts { createBlock([ startOnNewLine( setTextRange( - createStatement( + createExpressionStatement( createAssignment( createElementAccess( expressionName, @@ -1443,7 +1443,7 @@ namespace ts { } } - function captureThisForNode(statements: Statement[], node: Node, initializer: Expression | undefined, originalStatement?: Statement): void { + function captureThisForNode(statements: Statement[], node: Node, initializer: Expression | undefined): void { enableSubstitutionsForCapturedThis(); const captureThisStatement = createVariableStatement( /*modifiers*/ undefined, @@ -1456,7 +1456,6 @@ namespace ts { ]) ); setEmitFlags(captureThisStatement, EmitFlags.NoComments | EmitFlags.CustomPrologue); - setTextRange(captureThisStatement, originalStatement); setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); } @@ -1594,7 +1593,7 @@ namespace ts { setSourceMapRange(memberFunction, sourceMapRange); const statement = setTextRange( - createStatement( + createExpressionStatement( createAssignment(memberName, memberFunction) ), /*location*/ member @@ -1619,7 +1618,7 @@ 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)); + const statement = createExpressionStatement(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. @@ -1892,7 +1891,7 @@ namespace ts { } const lexicalEnvironment = context.endLexicalEnvironment(); - prependStatements(statements, lexicalEnvironment); + addStatementsAfterPrologue(statements, lexicalEnvironment); prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block @@ -1949,9 +1948,9 @@ namespace ts { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { case SyntaxKind.ParenthesizedExpression: - return updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + return updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); case SyntaxKind.BinaryExpression: - return updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + return updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return visitEachChild(node, visitor, context); } @@ -2026,7 +2025,7 @@ namespace ts { } } if (assignments) { - updated = setTextRange(createStatement(inlineExpressions(assignments)), node); + updated = setTextRange(createExpressionStatement(inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -2207,7 +2206,7 @@ namespace ts { const statement = unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel); return isIterationStatement(statement, /*lookInLabeledStatements*/ false) ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) - : restoreEnclosingLabel(visitNode(statement, visitor, isStatement), node, convertedLoopState && resetLabel); + : restoreEnclosingLabel(visitNode(statement, visitor, isStatement, liftToBlock), node, convertedLoopState && resetLabel); } function visitIterationStatement(node: IterationStatement, outermostLabeledStatement: LabeledStatement) { @@ -2330,11 +2329,11 @@ namespace ts { const assignment = createAssignment(initializer, boundValue); if (isDestructuringAssignment(assignment)) { aggregateTransformFlags(assignment); - statements.push(createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + statements.push(createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { assignment.end = initializer.end; - statements.push(setTextRange(createStatement(visitNode(assignment, visitor, isExpression)), moveRangeEnd(initializer, -1))); + statements.push(setTextRange(createExpressionStatement(visitNode(assignment, visitor, isExpression)), moveRangeEnd(initializer, -1))); } } @@ -2483,7 +2482,7 @@ namespace ts { createCatchClause(createVariableDeclaration(catchVariable), setEmitFlags( createBlock([ - createStatement( + createExpressionStatement( createAssignment( errorRecord, createObjectLiteral([ @@ -2512,7 +2511,7 @@ namespace ts { createPropertyAccess(iterator, "return") ) ), - createStatement( + createExpressionStatement( createFunctionCall(returnMethod, iterator, []) ) ), @@ -2707,7 +2706,7 @@ namespace ts { if (loopOutParameters.length) { copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements); } - prependStatements(statements, lexicalEnvironment); + addStatementsAfterPrologue(statements, lexicalEnvironment); loopBody = createBlock(statements, /*multiline*/ true); } @@ -2868,7 +2867,7 @@ namespace ts { function copyOutParameters(outParams: LoopOutParameter[], copyDirection: CopyDirection, statements: Statement[]): void { for (const outParam of outParams) { - statements.push(createStatement(copyOutParameter(outParam, copyDirection))); + statements.push(createExpressionStatement(copyOutParameter(outParam, copyDirection))); } } @@ -2892,7 +2891,7 @@ namespace ts { ) : call; if (isSimpleLoop) { - statements.push(createStatement(callResult)); + statements.push(createExpressionStatement(callResult)); copyOutParameters(state.loopOutParameters!, CopyDirection.ToOriginal, statements); } else { @@ -3358,7 +3357,7 @@ namespace ts { // Add the class alias following the declaration. statements.push( - createStatement( + createExpressionStatement( createAssignment( aliasAssignment.left, cast(variable.name, isIdentifier) diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index a118e349ac382..f58a24fb0a9fa 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -144,7 +144,7 @@ namespace ts { function visitVariableStatementInAsyncBody(node: VariableStatement) { if (isVariableDeclarationListWithCollidingName(node.declarationList)) { const expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false); - return expression ? createStatement(expression) : undefined; + return expression ? createExpressionStatement(expression) : undefined; } return visitEachChild(node, visitor, context); } @@ -413,7 +413,7 @@ namespace ts { ) ); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const block = createBlock(statements, /*multiLine*/ true); setTextRange(block, node.body); diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index cf1c6c447bee9..b121eb315db84 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -446,7 +446,7 @@ namespace ts { createVariableDeclaration(catchVariable), setEmitFlags( createBlock([ - createStatement( + createExpressionStatement( createAssignment( errorRecord, createObjectLiteral([ @@ -473,7 +473,7 @@ namespace ts { createPropertyAccess(iterator, "return") ) ), - createStatement(createDownlevelAwait(callReturn)) + createExpressionStatement(createDownlevelAwait(callReturn)) ), EmitFlags.SingleLine ) @@ -675,7 +675,7 @@ namespace ts { ) ); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const block = updateBlock(node.body!, statements); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. @@ -707,7 +707,7 @@ namespace ts { const leadingStatements = endLexicalEnvironment(); if (statementOffset > 0 || some(statements) || some(leadingStatements)) { const block = convertToFunctionBody(body, /*multiLine*/ true); - prependStatements(statements, leadingStatements); + addStatementsAfterPrologue(statements, leadingStatements); addRange(statements, block.statements.slice(statementOffset)); return updateBlock(block, setTextRange(createNodeArray(statements), block.statements)); } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index a5e10c4b65ddf..5778b47a4f8b4 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -587,7 +587,7 @@ namespace ts { transformAndEmitStatements(body.statements, statementOffset); const buildResult = build(); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); statements.push(createReturn(buildResult)); // Restore previous generator state @@ -637,7 +637,7 @@ namespace ts { } return setSourceMapRange( - createStatement( + createExpressionStatement( inlineExpressions( map(variables, transformInitializedVariable) ) @@ -872,7 +872,7 @@ namespace ts { } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(OpCode.Statement, [createStatement(inlineExpressions(pendingExpressions))]); + emitWorker(OpCode.Statement, [createExpressionStatement(inlineExpressions(pendingExpressions))]); pendingExpressions = []; } @@ -1067,7 +1067,7 @@ namespace ts { function reduceProperty(expressions: Expression[], property: ObjectLiteralElementLike) { if (containsYield(property) && expressions.length > 0) { - emitStatement(createStatement(inlineExpressions(expressions))); + emitStatement(createExpressionStatement(inlineExpressions(expressions))); expressions = []; } @@ -1270,7 +1270,7 @@ namespace ts { } if (pendingExpressions.length) { - emitStatement(createStatement(inlineExpressions(pendingExpressions))); + emitStatement(createExpressionStatement(inlineExpressions(pendingExpressions))); variablesWritten += pendingExpressions.length; pendingExpressions = []; } @@ -1441,7 +1441,7 @@ namespace ts { else { emitStatement( setTextRange( - createStatement( + createExpressionStatement( visitNode(initializer, visitor, isExpression) ), initializer @@ -1461,7 +1461,7 @@ namespace ts { if (node.incrementor) { emitStatement( setTextRange( - createStatement( + createExpressionStatement( visitNode(node.incrementor, visitor, isExpression) ), node.incrementor @@ -1543,7 +1543,7 @@ namespace ts { createForIn( key, visitNode(node.expression, visitor, isExpression), - createStatement( + createExpressionStatement( createCall( createPropertyAccess(keysArray, "push"), /*typeArguments*/ undefined, @@ -1579,7 +1579,7 @@ namespace ts { transformAndEmitEmbeddedStatement(node.statement); markLabel(incrementLabel); - emitStatement(createStatement(createPostfixIncrement(keysIndex))); + emitStatement(createExpressionStatement(createPostfixIncrement(keysIndex))); emitBreak(conditionLabel); endLoopBlock(); @@ -2778,7 +2778,7 @@ namespace ts { // for each block in the protected region. const { startLabel, catchLabel, finallyLabel, endLabel } = currentExceptionBlock; statements.unshift( - createStatement( + createExpressionStatement( createCall( createPropertyAccess(createPropertyAccess(state, "trys"), "push"), /*typeArguments*/ undefined, @@ -2801,7 +2801,7 @@ namespace ts { // The case clause for the last label falls through to this label, so we // add an assignment statement to reflect the change in labels. statements.push( - createStatement( + createExpressionStatement( createAssignment( createPropertyAccess(state, "label"), createLiteral(labelNumber + 1) @@ -2985,7 +2985,7 @@ namespace ts { * @param operationLocation The source map location for the operation. */ function writeAssign(left: Expression, right: Expression, operationLocation: TextRange | undefined): void { - writeStatement(setTextRange(createStatement(createAssignment(left, right)), operationLocation)); + writeStatement(setTextRange(createExpressionStatement(createAssignment(left, right)), operationLocation)); } /** diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 50595d960e1af..09bf1b75b9c18 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -97,7 +97,7 @@ namespace ts { append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement)); addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset)); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const updated = updateSourceFileNode(node, setTextRange(createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { @@ -147,7 +147,7 @@ namespace ts { const updated = updateSourceFileNode(node, setTextRange( createNodeArray([ - createStatement( + createExpressionStatement( createCall( define, /*typeArguments*/ undefined, @@ -240,7 +240,7 @@ namespace ts { createIdentifier("v"), createIdentifier("undefined") ), - createStatement( + createExpressionStatement( createAssignment( createPropertyAccess(createIdentifier("module"), "exports"), createIdentifier("v") @@ -256,7 +256,7 @@ namespace ts { createPropertyAccess(createIdentifier("define"), "amd") ), createBlock([ - createStatement( + createExpressionStatement( createCall( createIdentifier("define"), /*typeArguments*/ undefined, @@ -299,7 +299,7 @@ namespace ts { node, setTextRange( createNodeArray([ - createStatement( + createExpressionStatement( createCall( umdHeader, /*typeArguments*/ undefined, @@ -396,7 +396,7 @@ namespace ts { if (expr === name) { return undefined; } - return createStatement(createAssignment(name, expr)); + return createExpressionStatement(createAssignment(name, expr)); } /** @@ -426,7 +426,7 @@ namespace ts { // End the lexical environment for the module body // and merge any new lexical declarations. - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const body = createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { @@ -460,7 +460,7 @@ namespace ts { statements.push(statement); } else { - const statement = createStatement( + const statement = createExpressionStatement( createAssignment( createPropertyAccess( createIdentifier("module"), @@ -652,7 +652,7 @@ namespace ts { createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; const body = createBlock([ - createStatement( + createExpressionStatement( createCall( createIdentifier("require"), /*typeArguments*/ undefined, @@ -767,7 +767,7 @@ namespace ts { if (moduleKind !== ModuleKind.AMD) { if (!node.importClause) { // import "mod"; - return setTextRange(createStatement(createRequireCall(node)), node); + return setOriginalNode(setTextRange(createExpressionStatement(createRequireCall(node)), node), node); } else { const variables: VariableDeclaration[] = []; @@ -806,15 +806,17 @@ namespace ts { } statements = append(statements, - setTextRange( - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList( - variables, - languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None - ) - ), - /*location*/ node + setOriginalNode( + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList( + variables, + languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None + ) + ), + /*location*/ node), + /*original*/ node ) ); } @@ -826,13 +828,15 @@ namespace ts { /*modifiers*/ undefined, createVariableDeclarationList( [ - setTextRange( - createVariableDeclaration( - getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, - getGeneratedNameForNode(node) - ), - /*location*/ node + setOriginalNode( + setTextRange( + createVariableDeclaration( + getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, + getGeneratedNameForNode(node) + ), + /*location*/ node), + /*original*/ node ) ], languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None @@ -880,33 +884,37 @@ namespace ts { if (moduleKind !== ModuleKind.AMD) { if (hasModifier(node, ModifierFlags.Export)) { statements = append(statements, - setTextRange( - createStatement( - createExportExpression( - node.name, - createRequireCall(node) - ) - ), + setOriginalNode( + setTextRange( + createExpressionStatement( + createExportExpression( + node.name, + createRequireCall(node) + ) + ), + node), node ) ); } else { statements = append(statements, - setTextRange( - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList( - [ - createVariableDeclaration( - getSynthesizedClone(node.name), - /*type*/ undefined, - createRequireCall(node) - ) - ], - /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None - ) - ), + setOriginalNode( + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList( + [ + createVariableDeclaration( + getSynthesizedClone(node.name), + /*type*/ undefined, + createRequireCall(node) + ) + ], + /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None + ) + ), + node), node ) ); @@ -915,10 +923,12 @@ namespace ts { else { if (hasModifier(node, ModifierFlags.Export)) { statements = append(statements, - setTextRange( - createStatement( - createExportExpression(getExportName(node), getLocalName(node)) - ), + setOriginalNode( + setTextRange( + createExpressionStatement( + createExportExpression(getExportName(node), getLocalName(node)) + ), + node), node ) ); @@ -956,18 +966,20 @@ namespace ts { // export { x, y } from "mod"; if (moduleKind !== ModuleKind.AMD) { statements.push( - setTextRange( - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList([ - createVariableDeclaration( - generatedName, - /*type*/ undefined, - createRequireCall(node) - ) - ]) - ), - /*location*/ node + setOriginalNode( + setTextRange( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration( + generatedName, + /*type*/ undefined, + createRequireCall(node) + ) + ]) + ), + /*location*/ node), + /* original */ node ) ); } @@ -977,10 +989,12 @@ namespace ts { specifier.propertyName || specifier.name ); statements.push( - setTextRange( - createStatement( - createExportExpression(getExportName(specifier), exportedValue) - ), + setOriginalNode( + setTextRange( + createExpressionStatement( + createExportExpression(getExportName(specifier), exportedValue) + ), + specifier), specifier ) ); @@ -990,10 +1004,12 @@ namespace ts { } else { // export * from "mod"; - return setTextRange( - createStatement( - createExportStarHelper(context, moduleKind !== ModuleKind.AMD ? createRequireCall(node) : generatedName) - ), + return setOriginalNode( + setTextRange( + createExpressionStatement( + createExportStarHelper(context, moduleKind !== ModuleKind.AMD ? createRequireCall(node) : generatedName) + ), + node), node ); } @@ -1140,7 +1156,7 @@ namespace ts { } if (expressions) { - statements = append(statements, setTextRange(createStatement(inlineExpressions(expressions)), node)); + statements = append(statements, setOriginalNode(setTextRange(createExpressionStatement(inlineExpressions(expressions)), node), node)); } } else { @@ -1429,7 +1445,7 @@ namespace ts { function createUnderscoreUnderscoreESModule() { let statement: Statement; if (languageVersion === ScriptTarget.ES3) { - statement = createStatement( + statement = createExpressionStatement( createExportExpression( createIdentifier("__esModule"), createLiteral(/*value*/ true) @@ -1437,7 +1453,7 @@ namespace ts { ); } else { - statement = createStatement( + statement = createExpressionStatement( createCall( createPropertyAccess(createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, @@ -1464,7 +1480,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 = setTextRange(createStatement(createExportExpression(name, value)), location); + const statement = setTextRange(createExpressionStatement(createExportExpression(name, value)), location); startOnNewLine(statement); if (!allowComments) { setEmitFlags(statement, EmitFlags.NoComments); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 9cad3cbb97c26..82815528c213e 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -103,7 +103,7 @@ namespace ts { node, setTextRange( createNodeArray([ - createStatement( + createExpressionStatement( createCall( createPropertyAccess(createIdentifier("System"), "register"), /*typeArguments*/ undefined, @@ -257,7 +257,7 @@ namespace ts { // We emit hoisted variables early to align roughly with our previous emit output. // Two key differences in this approach are: // - Temporary variables will appear at the top rather than at the bottom of the file - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const exportStarFunction = addExportStarIfNeeded(statements)!; // TODO: GH#18217 const moduleObject = createObjectLiteral([ @@ -428,7 +428,7 @@ namespace ts { setEmitFlags( createIf( condition, - createStatement( + createExpressionStatement( createAssignment( createElementAccess(exports, n), createElementAccess(m, n) @@ -439,7 +439,7 @@ namespace ts { ) ]) ), - createStatement( + createExpressionStatement( createCall( exportFunction, /*typeArguments*/ undefined, @@ -478,7 +478,7 @@ namespace ts { Debug.assert(importVariableName !== undefined); // save import into the local statements.push( - createStatement( + createExpressionStatement( createAssignment(importVariableName, parameterName) ) ); @@ -509,7 +509,7 @@ namespace ts { } statements.push( - createStatement( + createExpressionStatement( createCall( exportFunction, /*typeArguments*/ undefined, @@ -525,7 +525,7 @@ namespace ts { // // exportStar(foo_1_1); statements.push( - createStatement( + createExpressionStatement( createCall( exportStarFunction, /*typeArguments*/ undefined, @@ -703,7 +703,7 @@ namespace ts { // Rewrite the class declaration into an assignment of a class expression. statements = append(statements, setTextRange( - createStatement( + createExpressionStatement( createAssignment( name, setTextRange( @@ -759,7 +759,7 @@ namespace ts { let statements: Statement[] | undefined; if (expressions) { - statements = append(statements, setTextRange(createStatement(inlineExpressions(expressions)), node)); + statements = append(statements, setTextRange(createExpressionStatement(inlineExpressions(expressions)), node)); } if (isMarkedDeclaration) { @@ -1116,7 +1116,7 @@ namespace ts { * @param allowComments An optional value indicating whether to emit comments for the statement. */ function createExportStatement(name: Identifier | StringLiteral, value: Expression, allowComments?: boolean) { - const statement = createStatement(createExportExpression(name, value)); + const statement = createExpressionStatement(createExportExpression(name, value)); startOnNewLine(statement); if (!allowComments) { setEmitFlags(statement, EmitFlags.NoComments); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index e9507d6c8ffa2..bf4ae5ce7d33e 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -638,7 +638,7 @@ namespace ts { // Write any pending expressions from elided or moved computed property names if (some(pendingExpressions)) { - statements.push(createStatement(inlineExpressions(pendingExpressions!))); + statements.push(createExpressionStatement(inlineExpressions(pendingExpressions!))); } pendingExpressions = savedPendingExpressions; @@ -682,7 +682,7 @@ namespace ts { setEmitFlags(statement, EmitFlags.NoComments | EmitFlags.NoTokenSourceMaps); statements.push(statement); - prependStatements(statements, context.endLexicalEnvironment()); + addStatementsAfterPrologue(statements, context.endLexicalEnvironment()); const iife = createImmediatelyInvokedArrowFunction(statements); setEmitFlags(iife, EmitFlags.TypeScriptClassWrapper); @@ -1069,7 +1069,7 @@ namespace ts { // super(...arguments); // statements.push( - createStatement( + createExpressionStatement( createCall( createSuper(), /*typeArguments*/ undefined, @@ -1175,7 +1175,7 @@ namespace ts { return startOnNewLine( setEmitFlags( setTextRange( - createStatement( + createExpressionStatement( createAssignment( setTextRange( createPropertyAccess( @@ -1242,9 +1242,10 @@ namespace ts { */ function addInitializedPropertyStatements(statements: Statement[], properties: ReadonlyArray, receiver: LeftHandSideExpression) { for (const property of properties) { - const statement = createStatement(transformInitializedProperty(property, receiver)); + const statement = createExpressionStatement(transformInitializedProperty(property, receiver)); setSourceMapRange(statement, moveRangePastModifiers(property)); setCommentRange(statement, property); + setOriginalNode(statement, property); statements.push(statement); } } @@ -1262,6 +1263,7 @@ namespace ts { startOnNewLine(expression); setSourceMapRange(expression, moveRangePastModifiers(property)); setCommentRange(expression, property); + setOriginalNode(expression, property); expressions.push(expression); } @@ -1596,7 +1598,7 @@ namespace ts { function addConstructorDecorationStatement(statements: Statement[], node: ClassDeclaration) { const expression = generateConstructorDecorationExpression(node); if (expression) { - statements.push(setOriginalNode(createStatement(expression), node)); + statements.push(setOriginalNode(createExpressionStatement(expression), node)); } } @@ -1982,18 +1984,16 @@ namespace ts { const kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope); switch (kind) { case TypeReferenceSerializationKind.Unknown: - const serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); + const serialized = serializeEntityNameAsExpressionFallback(node.typeName); const temp = createTempVariable(hoistVariableDeclaration); - return createLogicalOr( - createLogicalAnd( - createTypeCheck(createAssignment(temp, serialized), "function"), - temp - ), + return createConditional( + createTypeCheck(createAssignment(temp, serialized), "function"), + temp, createIdentifier("Object") ); case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - return serializeEntityNameAsExpression(node.typeName, /*useFallback*/ false); + return serializeEntityNameAsExpression(node.typeName); case TypeReferenceSerializationKind.VoidNullableOrNeverType: return createVoidZero(); @@ -2028,14 +2028,46 @@ namespace ts { } } + function createCheckedValue(left: Expression, right: Expression) { + return createLogicalAnd( + createStrictInequality(createTypeOf(left), createLiteral("undefined")), + right + ); + } + + /** + * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw + * + * @param node The entity name to serialize. + */ + function serializeEntityNameAsExpressionFallback(node: EntityName): BinaryExpression { + if (node.kind === SyntaxKind.Identifier) { + // A -> typeof A !== undefined && A + const copied = serializeEntityNameAsExpression(node); + return createCheckedValue(copied, copied); + } + if (node.left.kind === SyntaxKind.Identifier) { + // A.B -> typeof A !== undefined && A.B + return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); + } + // A.B.C -> typeof A !== undefined && (_a = A.B) !== void 0 && _a.C + const left = serializeEntityNameAsExpressionFallback(node.left); + const temp = createTempVariable(hoistVariableDeclaration); + return createLogicalAnd( + createLogicalAnd( + left.left, + createStrictInequality(createAssignment(temp, left.right), createVoidZero()) + ), + createPropertyAccess(temp, node.right) + ); + } + /** * Serializes an entity name as an expression for decorator type metadata. * * @param node The entity name to serialize. - * @param useFallback A value indicating whether to use logical operators to test for the - * entity name at runtime. */ - function serializeEntityNameAsExpression(node: EntityName, useFallback: boolean): SerializedEntityNameAsExpression { + function serializeEntityNameAsExpression(node: EntityName): SerializedEntityNameAsExpression { switch (node.kind) { case SyntaxKind.Identifier: // Create a clone of the name with a new parent, and treat it as if it were @@ -2044,20 +2076,11 @@ namespace ts { name.flags &= ~NodeFlags.Synthesized; name.original = undefined; name.parent = getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. - if (useFallback) { - return createLogicalAnd( - createStrictInequality( - createTypeOf(name), - createLiteral("undefined") - ), - name - ); - } return name; case SyntaxKind.QualifiedName: - return serializeQualifiedNameAsExpression(node, useFallback); + return serializeQualifiedNameAsExpression(node); } } @@ -2068,26 +2091,8 @@ namespace ts { * @param useFallback A value indicating whether to use logical operators to test for the * qualified name at runtime. */ - function serializeQualifiedNameAsExpression(node: QualifiedName, useFallback: boolean): PropertyAccessExpression { - let left: SerializedEntityNameAsExpression; - if (node.left.kind === SyntaxKind.Identifier) { - left = serializeEntityNameAsExpression(node.left, useFallback); - } - else if (useFallback) { - const temp = createTempVariable(hoistVariableDeclaration); - left = createLogicalAnd( - createAssignment( - temp, - serializeEntityNameAsExpression(node.left, /*useFallback*/ true) - ), - temp - ); - } - else { - left = serializeEntityNameAsExpression(node.left, /*useFallback*/ false); - } - - return createPropertyAccess(left, node.right); + function serializeQualifiedNameAsExpression(node: QualifiedName): SerializedEntityNameAsExpression { + return createPropertyAccess(serializeEntityNameAsExpression(node.left), node.right); } /** @@ -2481,7 +2486,7 @@ namespace ts { } return setTextRange( - createStatement( + createExpressionStatement( inlineExpressions( map(variables, transformInitializedVariable) ) @@ -2602,7 +2607,7 @@ namespace ts { * @param node The enum declaration node. */ function shouldEmitEnumDeclaration(node: EnumDeclaration) { - return !isConst(node) + return !isEnumConst(node) || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } @@ -2628,7 +2633,8 @@ namespace ts { // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. - if (addVarForEnumOrModuleDeclaration(statements, node)) { + const varAdded = addVarForEnumOrModuleDeclaration(statements, node); + if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= EmitFlags.NoLeadingComments; @@ -2669,7 +2675,7 @@ namespace ts { // x[x["y"] = 0] = "y"; // ... // })(x || (x = {})); - const enumStatement = createStatement( + const enumStatement = createExpressionStatement( createCall( createFunctionExpression( /*modifiers*/ undefined, @@ -2686,8 +2692,13 @@ namespace ts { ); setOriginalNode(enumStatement, node); + if (varAdded) { + // If a variable was added, synthetic comments are emitted on it, not on the moduleStatement. + setSyntheticLeadingComments(enumStatement, undefined); + setSyntheticTrailingComments(enumStatement, undefined); + } setTextRange(enumStatement, node); - setEmitFlags(enumStatement, emitFlags); + addEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); // Add a DeclarationMarker for the enum to preserve trailing comments and mark @@ -2708,7 +2719,7 @@ namespace ts { const statements: Statement[] = []; startLexicalEnvironment(); const members = map(node.members, transformEnumMember); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); addRange(statements, members); currentNamespaceContainerName = savedCurrentNamespaceLocalName; @@ -2746,7 +2757,7 @@ namespace ts { name ); return setTextRange( - createStatement( + createExpressionStatement( setTextRange( outerAssignment, member @@ -2877,7 +2888,7 @@ namespace ts { // })(m1 || (m1 = {})); // trailing comment module // setCommentRange(statement, node); - setEmitFlags(statement, EmitFlags.NoTrailingComments | EmitFlags.HasEndOfDeclarationMarker); + addEmitFlags(statement, EmitFlags.NoTrailingComments | EmitFlags.HasEndOfDeclarationMarker); statements.push(statement); return true; } @@ -2917,7 +2928,8 @@ namespace ts { // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. - if (addVarForEnumOrModuleDeclaration(statements, node)) { + const varAdded = addVarForEnumOrModuleDeclaration(statements, node); + if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ModuleKind.System || currentLexicalScope !== currentSourceFile) { emitFlags |= EmitFlags.NoLeadingComments; @@ -2957,7 +2969,7 @@ namespace ts { // (function (x_1) { // x_1.y = ...; // })(x || (x = {})); - const moduleStatement = createStatement( + const moduleStatement = createExpressionStatement( createCall( createFunctionExpression( /*modifiers*/ undefined, @@ -2974,8 +2986,13 @@ namespace ts { ); setOriginalNode(moduleStatement, node); + if (varAdded) { + // If a variable was added, synthetic comments are emitted on it, not on the moduleStatement. + setSyntheticLeadingComments(moduleStatement, undefined); + setSyntheticTrailingComments(moduleStatement, undefined); + } setTextRange(moduleStatement, node); - setEmitFlags(moduleStatement, emitFlags); + addEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); // Add a DeclarationMarker for the namespace to preserve trailing comments and mark @@ -3023,7 +3040,7 @@ namespace ts { statementsLocation = moveRangePos(moduleBlock.statements, -1); } - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; @@ -3309,7 +3326,7 @@ namespace ts { * Creates a statement for the provided expression. This is used in calls to `map`. */ function expressionToStatement(expression: Expression) { - return createStatement(expression); + return createExpressionStatement(expression); } function addExportMemberAssignment(statements: Statement[], node: ClassDeclaration | FunctionDeclaration) { @@ -3319,14 +3336,14 @@ namespace ts { ); setSourceMapRange(expression, createRange(node.name ? node.name.pos : node.pos, node.end)); - const statement = createStatement(expression); + const statement = createExpressionStatement(expression); setSourceMapRange(statement, createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName: Identifier, exportValue: Expression, location?: TextRange) { return setTextRange( - createStatement( + createExpressionStatement( createAssignment( getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 007ec1afc7c99..205e7cd8940e1 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -126,12 +126,12 @@ namespace ts { */ export interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** @@ -291,18 +291,22 @@ namespace ts { function getOutputJavaScriptFileName(inputFileName: string, configFile: ParsedCommandLine) { const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath!), inputFileName, /*ignoreCase*/ true); const outputPath = resolvePath(configFile.options.outDir || getDirectoryPath(configFile.options.configFilePath!), relativePath); - return changeExtension(outputPath, (fileExtensionIs(inputFileName, Extension.Tsx) && configFile.options.jsx === JsxEmit.Preserve) ? Extension.Jsx : Extension.Js); + const newExtension = fileExtensionIs(inputFileName, Extension.Json) ? Extension.Json : + fileExtensionIs(inputFileName, Extension.Tsx) && configFile.options.jsx === JsxEmit.Preserve ? Extension.Jsx : Extension.Js; + return changeExtension(outputPath, newExtension); } function getOutputFileNames(inputFileName: string, configFile: ParsedCommandLine): ReadonlyArray { - if (configFile.options.outFile) { + // outFile is handled elsewhere; .d.ts files don't generate outputs + if (configFile.options.outFile || configFile.options.out || fileExtensionIs(inputFileName, Extension.Dts)) { return emptyArray; } const outputs: string[] = []; outputs.push(getOutputJavaScriptFileName(inputFileName, configFile)); - if (configFile.options.declaration) { - const dts = outputs.push(getOutputDeclarationFileName(inputFileName, configFile)); + if (getEmitDeclarations(configFile.options) && !fileExtensionIs(inputFileName, Extension.Json)) { + const dts = getOutputDeclarationFileName(inputFileName, configFile); + outputs.push(dts); if (configFile.options.declarationMap) { outputs.push(dts + ".map"); } @@ -316,7 +320,7 @@ namespace ts { } const outputs: string[] = []; outputs.push(project.options.outFile); - if (project.options.declaration) { + if (getEmitDeclarations(project.options)) { const dts = changeExtension(project.options.outFile, Extension.Dts); outputs.push(dts); if (project.options.declarationMap) { @@ -484,6 +488,7 @@ namespace ts { } if (watch) { + builder.buildAllProjects(); builder.startWatching(); return undefined; } @@ -493,10 +498,6 @@ namespace ts { function addProject(projectSpecification: string) { const fileName = resolvePath(compilerHost.getCurrentDirectory(), projectSpecification); const refPath = resolveProjectReferencePath(compilerHost, { path: fileName }); - if (!refPath) { - return buildHost.error(Diagnostics.File_0_does_not_exist, projectSpecification); - } - if (!compilerHost.fileExists(refPath)) { return buildHost.error(Diagnostics.File_0_does_not_exist, fileName); } @@ -769,7 +770,10 @@ namespace ts { const program = createProgram(programOptions); // Don't emit anything in the presence of syntactic errors or options diagnostics - const syntaxDiagnostics = [...program.getOptionsDiagnostics(), ...program.getSyntacticDiagnostics()]; + const syntaxDiagnostics = [ + ...program.getOptionsDiagnostics(), + ...program.getConfigFileParsingDiagnostics(), + ...program.getSyntacticDiagnostics()]; if (syntaxDiagnostics.length) { resultFlags |= BuildResultFlags.SyntaxErrors; for (const diag of syntaxDiagnostics) { @@ -780,7 +784,7 @@ namespace ts { } // Don't emit .d.ts if there are decl file errors - if (program.getCompilerOptions().declaration) { + if (getEmitDeclarations(program.getCompilerOptions())) { const declDiagnostics = program.getDeclarationDiagnostics(); if (declDiagnostics.length) { resultFlags |= BuildResultFlags.DeclarationEmitErrors; @@ -804,15 +808,19 @@ namespace ts { } let newestDeclarationFileContentChangedTime = minimumDate; + let anyDtsChanged = false; program.emit(/*targetSourceFile*/ undefined, (fileName, content, writeBom, onError) => { let priorChangeTime: Date | undefined; - if (isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { + if (!anyDtsChanged && isDeclarationFile(fileName) && compilerHost.fileExists(fileName)) { if (compilerHost.readFile(fileName) === content) { // Check for unchanged .d.ts files resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; priorChangeTime = compilerHost.getModifiedTime && compilerHost.getModifiedTime(fileName); } + else { + anyDtsChanged = true; + } } compilerHost.writeFile(fileName, content, writeBom, onError, emptyArray); @@ -822,7 +830,11 @@ namespace ts { } }); - context.projectStatus.setValue(proj, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime } as UpToDateStatus); + const status: UpToDateStatus = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime + }; + context.projectStatus.setValue(proj, status); return resultFlags; } @@ -831,14 +843,18 @@ namespace ts { return buildHost.message(Diagnostics.A_non_dry_build_would_build_project_0, proj.options.configFilePath!); } - if (context.options.verbose) buildHost.verbose(Diagnostics.Updating_output_timestamps_of_project_0, proj.options.configFilePath!); + if (context.options.verbose) { + buildHost.verbose(Diagnostics.Updating_output_timestamps_of_project_0, proj.options.configFilePath!); + } + const now = new Date(); const outputs = getAllProjectOutputs(proj); let priorNewestUpdateTime = minimumDate; for (const file of outputs) { if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, compilerHost.getModifiedTime!(file)); + priorNewestUpdateTime = newer(priorNewestUpdateTime, compilerHost.getModifiedTime!(file) || missingFileModifiedTime); } + compilerHost.setModifiedTime!(file, now); } @@ -1045,7 +1061,7 @@ namespace ts { }; } - const inputTime = host.getModifiedTime(inputFile); + const inputTime = host.getModifiedTime(inputFile) || missingFileModifiedTime; if (inputTime > newestInputFileTime) { newestInputFileName = inputFile; newestInputFileTime = inputTime; @@ -1077,7 +1093,7 @@ namespace ts { break; } - const outputTime = host.getModifiedTime(output); + const outputTime = host.getModifiedTime(output) || missingFileModifiedTime; if (outputTime < oldestOutputFileTime) { oldestOutputFileTime = outputTime; oldestOutputFileName = output; @@ -1105,7 +1121,8 @@ namespace ts { newestDeclarationFileContentChangedTime = newer(unchangedTime, newestDeclarationFileContentChangedTime); } else { - newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, host.getModifiedTime(output)); + const outputModifiedTime = host.getModifiedTime(output) || missingFileModifiedTime; + newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); } } } @@ -1137,13 +1154,13 @@ namespace ts { // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it - if (refStatus.newestInputFileTime <= oldestOutputFileTime) { + if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -1227,8 +1244,8 @@ namespace ts { if (status.newestInputFileTime !== undefined) { return formatMessage(Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(configFileName), - relName(status.newestInputFileName), - relName(status.oldestOutputFileName)); + relName(status.newestInputFileName || ""), + relName(status.oldestOutputFileName || "")); } // Don't report anything for "up to date because it was already built" -- too verbose break; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 64ee4a28f2c34..87664652b355b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -755,7 +755,7 @@ namespace ts { export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; - parent: DeclarationWithTypeParameters | InferTypeNode; + parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -1761,7 +1761,11 @@ namespace ts { export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + + export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } export interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; @@ -2032,7 +2036,8 @@ namespace ts { export type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + export type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + export type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; @@ -2840,7 +2845,6 @@ namespace ts { inputSourceFileNames: string[]; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMapSources list sourceMapNames?: string[]; // Source map's names field - list of names that can be indexed in this source map sourceMapMappings: string; // Source map's mapping field - encoded source map spans - sourceMapDecodedMappings: SourceMapSpan[]; // Raw source map spans that were encoded into the sourceMapMappings } /** Return code used by getEmitOutput function to indicate status of the function */ @@ -2879,6 +2883,7 @@ namespace ts { getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; + /* @internal */ getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; @@ -2932,7 +2937,7 @@ namespace ts { */ getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; - getTypeAtLocation(node: Node): Type | undefined; + getTypeAtLocation(node: Node): Type; getTypeFromTypeNode(node: TypeNode): Type; signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; @@ -2945,11 +2950,6 @@ namespace ts { /* @internal */ writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string; /* @internal */ writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; @@ -2995,9 +2995,9 @@ namespace ts { */ /* @internal */ tryGetMemberInModuleExportsAndProperties(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; - getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; - getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; + /* @internal */ getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; + /* @internal */ getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; + /* @internal */ getSuggestionForNonexistentExport(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; getDefaultFromTypeParameter(type: Type): Type | undefined; @@ -3046,6 +3046,11 @@ namespace ts { /* @internal */ getTypeCount(): number; /* @internal */ isArrayLikeType(type: Type): boolean; + /** + * True if `contextualType` should not be considered for completions because + * e.g. it specifies `kind: "a"` and obj has `kind: "b"`. + */ + /* @internal */ isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression): boolean; /** * For a union, will include a property if it's defined in *any* of the member types. * So for `{ a } | { b }`, this will include both `a` and `b`. @@ -3200,27 +3205,9 @@ namespace ts { walkSymbol(root: Symbol): { visitedTypes: ReadonlyArray, visitedSymbols: ReadonlyArray }; } - /** - * @deprecated - */ - export interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ - export interface SymbolWriter extends SymbolTracker { + // This was previously deprecated in our public API, but is still used internally + /* @internal */ + interface SymbolWriter extends SymbolTracker { writeKeyword(text: string): void; writeOperator(text: string): void; writePunctuation(text: string): void; @@ -3411,6 +3398,7 @@ namespace ts { Optional = 1 << 24, // Optional property Transient = 1 << 25, // Transient symbol (created during type check) JSContainer = 1 << 26, // Contains Javascript special declarations + ModuleExports = 1 << 27, // Symbol for CommonJS `module` of `module.exports` /* @internal */ All = FunctionScopedVariable | BlockScopedVariable | Property | EnumMember | Function | Class | Interface | ConstEnum | RegularEnum | ValueModule | NamespaceModule | TypeLiteral @@ -3453,9 +3441,6 @@ namespace ts { ExportHasLocal = Function | Class | Enum | ValueModule, - HasExports = Class | Enum | Module | Variable, - HasMembers = Class | Interface | TypeLiteral | ObjectLiteral, - BlockScoped = BlockScopedVariable | Class | Enum, PropertyOrAccessor = Property | Accessor, @@ -3658,6 +3643,7 @@ namespace ts { 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?: SuperCall; // 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 + jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node } export const enum TypeFlags { @@ -3766,6 +3752,8 @@ namespace ts { aliasTypeArguments?: ReadonlyArray; // Alias type arguments (if any) /* @internal */ wildcardInstantiation?: Type; // Instantiation with type parameters mapped to wildcard type + /* @internal */ + immediateBaseConstraint?: Type; // Immediate base constraint cache } /* @internal */ @@ -3820,6 +3808,12 @@ namespace ts { // Object types (TypeFlags.ObjectType) export interface ObjectType extends Type { objectFlags: ObjectFlags; + /* @internal */ members?: SymbolTable; // Properties by name + /* @internal */ properties?: Symbol[]; // Properties + /* @internal */ callSignatures?: ReadonlyArray; // Call signatures of type + /* @internal */ constructSignatures?: ReadonlyArray; // Construct signatures of type + /* @internal */ stringIndexInfo?: IndexInfo; // String indexing info + /* @internal */ numberIndexInfo?: IndexInfo; // Numeric indexing info } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ @@ -3946,8 +3940,6 @@ namespace ts { properties: Symbol[]; // Properties callSignatures: ReadonlyArray; // Call signatures of type constructSignatures: ReadonlyArray; // Construct signatures of type - stringIndexInfo?: IndexInfo; // String indexing info - numberIndexInfo?: IndexInfo; // Numeric indexing info } /* @internal */ @@ -4233,14 +4225,14 @@ namespace ts { } export interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } export interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -4371,7 +4363,7 @@ namespace ts { strictFunctionTypes?: boolean; // Always combine with strict property strictNullChecks?: boolean; // Always combine with strict property strictPropertyInitialization?: boolean; // Always combine with strict property - /* @internal */ stripInternal?: boolean; + stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; /* @internal */ suppressOutputPathCheck?: boolean; @@ -4692,7 +4684,7 @@ namespace ts { export interface UpToDateHost { fileExists(fileName: string): boolean; - getModifiedTime(fileName: string): Date; + getModifiedTime(fileName: string): Date | undefined; getUnchangedTime?(fileName: string): Date | undefined; getLastStatus?(fileName: string): UpToDateStatus | undefined; setLastStatus?(fileName: string, status: UpToDateStatus): void; @@ -4830,7 +4822,7 @@ namespace ts { /* @internal */ hasChangedAutomaticTypeDirectiveNames?: boolean; createHash?(data: string): string; - getModifiedTime?(fileName: string): Date; + getModifiedTime?(fileName: string): Date | undefined; setModifiedTime?(fileName: string, date: Date): void; deleteFile?(fileName: string): void; } @@ -5044,6 +5036,7 @@ namespace ts { /* @internal */ export interface EmitHost extends ScriptReferenceHost, ModuleSpecifierResolutionHost { getSourceFiles(): ReadonlyArray; + useCaseSensitiveFileNames(): boolean; getCurrentDirectory(): string; /* @internal */ @@ -5318,8 +5311,8 @@ namespace ts { getSourceFiles?(): ReadonlyArray; // Used for cached resolutions to find symlinks without traversing the fs (again) } - /** @deprecated See comment on SymbolWriter */ - // Note: this has non-deprecated internal uses. + // Note: this used to be deprecated in our public API, but is still used internally + /* @internal */ export interface SymbolTracker { // Called when the symbol writer encounters a symbol to write. Currently only used by the // declaration emitter to help determine if it should patch up the final declaration file @@ -5328,10 +5321,8 @@ namespace ts { reportInaccessibleThisError?(): void; reportPrivateInBaseOfClassExpression?(propertyName: string): void; reportInaccessibleUniqueSymbolError?(): void; - /* @internal */ moduleResolverHost?: ModuleSpecifierResolutionHost; - /* @internal */ - trackReferencedAmbientModule?(decl: ModuleDeclaration): void; + trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void; } export interface TextSpan { @@ -5349,6 +5340,9 @@ namespace ts { // Adds a diagnostic to this diagnostic collection. add(diagnostic: Diagnostic): void; + // Returns the first existing diagnostic that is equivalent to the given one (sans related information) + lookup(diagnostic: Diagnostic): Diagnostic | undefined; + // Gets all the diagnostics that aren't associated with a file. getGlobalDiagnostics(): Diagnostic[]; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9c933b44d0155..fbe37e73e9e88 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -21,6 +21,8 @@ namespace ts { export const externalHelpersModuleNameText = "tslib"; + export const defaultMaximumTruncationLength = 160; + export function getDeclarationOfKind(symbol: Symbol, kind: T["kind"]): T | undefined { const declarations = symbol.declarations; if (declarations) { @@ -140,6 +142,16 @@ namespace ts { return undefined; } + export function forEachAncestor(node: Node, callback: (n: Node) => T | undefined | "quit"): T | undefined { + while (true) { + const res = callback(node); + if (res === "quit") return undefined; + if (res !== undefined) return res; + if (isSourceFile(node)) return undefined; + node = node.parent; + } + } + /** * Calls `callback` for each entry in the map, returning the first truthy result. * Use `map.forEach` instead for normal iteration. @@ -399,21 +411,18 @@ namespace ts { } /** - * Appends a range of value to begin of an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. + * Prepends statements to an array while taking care of prologue directives. */ - export function prependStatements(to: T[], from: ReadonlyArray | undefined): T[] | undefined { + export function addStatementsAfterPrologue(to: T[], from: ReadonlyArray | undefined): T[] { if (from === undefined || from.length === 0) return to; - if (to === undefined) return from.slice(); - const prologue = to.length && isPrologueDirective(to[0]) && to.shift(); - to.unshift(...from); - if (prologue) { - to.unshift(prologue); + let statementIndex = 0; + // skip all prologue directives to insert at the correct position + for (; statementIndex < to.length; ++statementIndex) { + if (!isPrologueDirective(to[statementIndex])) { + break; + } } + to.splice(statementIndex, 0, ...from); return to; } @@ -559,14 +568,6 @@ namespace ts { return (identifier.length >= 2 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ ? "_" + identifier : identifier) as __String; } - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - export function escapeIdentifier(identifier: string): string { - return 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 { @@ -897,13 +898,12 @@ namespace ts { return file.scriptKind === ScriptKind.JSON; } - export function isConstEnumDeclaration(node: Node): boolean { - return node.kind === SyntaxKind.EnumDeclaration && isConst(node); + export function isEnumConst(node: EnumDeclaration): boolean { + return !!(getCombinedModifierFlags(node) & ModifierFlags.Const); } - export function isConst(node: Node): boolean { - return !!(getCombinedNodeFlags(node) & NodeFlags.Const) - || !!(getCombinedModifierFlags(node) & ModifierFlags.Const); + export function isVarConst(node: VariableDeclaration | VariableDeclarationList): boolean { + return !!(getCombinedNodeFlags(node) & NodeFlags.Const); } export function isLet(node: Node): boolean { @@ -919,9 +919,7 @@ namespace ts { } export function isLiteralImportTypeNode(n: Node): n is LiteralImportTypeNode { - return n.kind === SyntaxKind.ImportType && - (n as ImportTypeNode).argument.kind === SyntaxKind.LiteralType && - isStringLiteral(((n as ImportTypeNode).argument as LiteralTypeNode).literal); + return isImportTypeNode(n) && isLiteralTypeNode(n.argument) && isStringLiteral(n.argument.literal); } export function isPrologueDirective(node: Node): node is PrologueDirective { @@ -1184,7 +1182,7 @@ namespace ts { } export function isValidESSymbolDeclaration(node: Node): node is VariableDeclaration | PropertyDeclaration | SignatureDeclaration { - return isVariableDeclaration(node) ? isConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : + return isVariableDeclaration(node) ? isVarConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) : isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) : isPropertySignature(node) && hasReadonlyModifier(node); } @@ -1864,7 +1862,7 @@ namespace ts { } export function getRightMostAssignedExpression(node: Expression): Expression { - while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + while (isAssignmentExpression(node, /*excludeCompoundAssignments*/ true)) { node = node.right; } return node; @@ -2887,6 +2885,7 @@ namespace ts { return { add, + lookup, getGlobalDiagnostics, getDiagnostics, reattachFileDiagnostics @@ -2896,6 +2895,24 @@ namespace ts { forEach(fileDiagnostics.get(newFile.fileName), diagnostic => diagnostic.file = newFile); } + function lookup(diagnostic: Diagnostic): Diagnostic | undefined { + let diagnostics: SortedArray | undefined; + if (diagnostic.file) { + diagnostics = fileDiagnostics.get(diagnostic.file.fileName); + } + else { + diagnostics = nonFileDiagnostics; + } + if (!diagnostics) { + return undefined; + } + const result = binarySearch(diagnostics, diagnostic, identity, compareDiagnosticsSkipRelatedInformation); + if (result >= 0) { + return diagnostics[result]; + } + return undefined; + } + function add(diagnostic: Diagnostic): void { let diagnostics: SortedArray | undefined; if (diagnostic.file) { @@ -3145,26 +3162,38 @@ namespace ts { return referencePath ? ensurePathIsNonModuleName(extensionless) : extensionless; } - export function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string) { + export function getOwnEmitOutputFilePath(fileName: string, host: EmitHost, extension: string) { const compilerOptions = host.getCompilerOptions(); let emitOutputFilePathWithoutExtension: string; if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir)); } else { - emitOutputFilePathWithoutExtension = removeFileExtension(sourceFile.fileName); + emitOutputFilePathWithoutExtension = removeFileExtension(fileName); } return emitOutputFilePathWithoutExtension + extension; } - export function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost) { + export function getDeclarationEmitOutputFilePath(fileName: string, host: EmitHost) { + // TODO: GH#25810 following should work but makes the build break: + // return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), f => host.getCanonicalFileName(f)); + const options = host.getCompilerOptions(); const outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified const path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; + ? getSourceFilePathInNewDir(fileName, host, outputDir) + : fileName; + return removeFileExtension(path) + Extension.Dts; + } + + export function getDeclarationEmitOutputFilePathWorker(fileName: string, options: CompilerOptions, currentDirectory: string, commonSourceDirectory: string, getCanonicalFileName: GetCanonicalFileName): string { + const outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified + + const path = outputDir + ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName) + : fileName; return removeFileExtension(path) + Extension.Dts; } @@ -3206,10 +3235,13 @@ namespace ts { return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile); } - export function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) { - let sourceFilePath = getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - const commonSourceDirectory = host.getCommonSourceDirectory(); - const isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; + export function getSourceFilePathInNewDir(fileName: string, host: EmitHost, newDirPath: string): string { + return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), f => host.getCanonicalFileName(f)); + } + + export function getSourceFilePathInNewDirWorker(fileName: string, newDirPath: string, currentDirectory: string, commonSourceDirectory: string, getCanonicalFileName: GetCanonicalFileName): string { + let sourceFilePath = getNormalizedAbsolutePath(fileName, currentDirectory); + const isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0; sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; return combinePaths(newDirPath, sourceFilePath); } @@ -3341,21 +3373,6 @@ namespace ts { return node.type || (isInJavaScriptFile(node) ? getJSDocReturnType(node) : undefined); } - /** - * Gets the effective type parameters. If the node was parsed in a - * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. - */ - export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray { - if (isJSDocSignature(node)) { - return emptyArray; - } - if (isJSDocTypeAlias(node)) { - Debug.assert(node.parent.kind === SyntaxKind.JSDocComment); - return flatMap(node.parent.tags, tag => isJSDocTemplateTag(tag) ? tag.typeParameters : undefined) as ReadonlyArray; - } - return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : emptyArray); - } - export function getJSDocTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray { return flatMap(getJSDocTags(node), tag => isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined); } @@ -4302,8 +4319,8 @@ namespace ts { return !!forEachAncestorDirectory(directory, d => callback(d) ? true : undefined); } - export function isUMDExportSymbol(symbol: Symbol | undefined) { - return symbol && symbol.declarations && symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]); + export function isUMDExportSymbol(symbol: Symbol | undefined): boolean { + return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]); } export function showModuleSpecifier({ moduleSpecifier }: ImportDeclaration): string { @@ -4375,6 +4392,11 @@ namespace ts { return position >= span.start && position < textSpanEnd(span); } + /* @internal */ + export function textRangeContainsPositionInclusive(span: TextRange, position: number): boolean { + return position >= span.pos && position <= span.end; + } + // Returns true if 'span' contains 'other'. export function textSpanContainsTextSpan(span: TextSpan, other: TextSpan) { return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); @@ -4605,33 +4627,36 @@ namespace ts { return isEmptyBindingPattern(node.name); } - function walkUpBindingElementsAndPatterns(node: Node): Node { - while (node && (node.kind === SyntaxKind.BindingElement || isBindingPattern(node))) { - node = node.parent; + export function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration { + let node = binding.parent; + while (isBindingElement(node.parent)) { + node = node.parent.parent; } - - return node; + return node.parent; } - export function getCombinedModifierFlags(node: Node): ModifierFlags { - node = walkUpBindingElementsAndPatterns(node); - let flags = getModifierFlags(node); + function getCombinedFlags(node: Node, getFlags: (n: Node) => number): number { + if (isBindingElement(node)) { + node = walkUpBindingElementsAndPatterns(node); + } + let flags = getFlags(node); if (node.kind === SyntaxKind.VariableDeclaration) { node = node.parent; } - if (node && node.kind === SyntaxKind.VariableDeclarationList) { - flags |= getModifierFlags(node); + flags |= getFlags(node); node = node.parent; } - if (node && node.kind === SyntaxKind.VariableStatement) { - flags |= getModifierFlags(node); + flags |= getFlags(node); } - return flags; } + export function getCombinedModifierFlags(node: Declaration): ModifierFlags { + return getCombinedFlags(node, getModifierFlags); + } + // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't @@ -4640,23 +4665,7 @@ namespace ts { // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. export function getCombinedNodeFlags(node: Node): NodeFlags { - node = walkUpBindingElementsAndPatterns(node); - - let flags = node.flags; - if (node.kind === SyntaxKind.VariableDeclaration) { - node = node.parent; - } - - if (node && node.kind === SyntaxKind.VariableDeclarationList) { - flags |= node.flags; - node = node.parent; - } - - if (node && node.kind === SyntaxKind.VariableStatement) { - flags |= node.flags; - } - - return flags; + return getCombinedFlags(node, n => n.flags); } /** @@ -4801,16 +4810,6 @@ namespace ts { return unescapeLeadingUnderscores(symbol.escapedName); } - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - export function unescapeIdentifier(id: string): string { - return id; - } - /** * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol @@ -4874,17 +4873,9 @@ namespace ts { return !!(node as NamedDeclaration).name; // A 'name' property should always be a DeclarationName. } - export function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined { - if (!declaration) { - return undefined; - } + /** @internal */ + export function getNonAssignedNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined { switch (declaration.kind) { - case SyntaxKind.ClassExpression: - case SyntaxKind.FunctionExpression: - if (!(declaration as ClassExpression | FunctionExpression).name) { - return getAssignedName(declaration); - } - break; case SyntaxKind.Identifier: return declaration as Identifier; case SyntaxKind.JSDocPropertyTag: @@ -4907,8 +4898,6 @@ namespace ts { return undefined; } } - case SyntaxKind.JSDocCallbackTag: - return (declaration as JSDocCallbackTag).name; case SyntaxKind.JSDocTypedefTag: return getNameOfJSDocTypedef(declaration as JSDocTypedefTag); case SyntaxKind.ExportAssignment: { @@ -4919,6 +4908,12 @@ namespace ts { return (declaration as NamedDeclaration).name; } + export function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined { + if (declaration === undefined) return undefined; + return getNonAssignedNameOfDeclaration(declaration) || + (isFunctionExpression(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + } + function getAssignedName(node: Node): DeclarationName | undefined { if (!node.parent) { return undefined; @@ -5034,14 +5029,27 @@ namespace ts { } /** - * Gets the return type node for the node if provided via JSDoc's return tag. + * Gets the return type node for the node if provided via JSDoc return tag or type tag. * * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function - * gets the type from inside the braces. + * gets the type from inside the braces, after the fat arrow, etc. */ export function getJSDocReturnType(node: Node): TypeNode | undefined { const returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + if (returnTag && returnTag.typeExpression) { + return returnTag.typeExpression.type; + } + const typeTag = getJSDocTypeTag(node); + if (typeTag && typeTag.typeExpression) { + const type = typeTag.typeExpression.type; + if (isTypeLiteralNode(type)) { + const sig = find(type.members, isCallSignatureDeclaration); + return sig && sig.type; + } + if (isFunctionTypeNode(type)) { + return type.type; + } + } } /** Get all JSDoc tags related to a node, including those on parent nodes. */ @@ -5065,6 +5073,21 @@ namespace ts { export function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray { return getJSDocTags(node).filter(doc => doc.kind === kind); } + + /** + * Gets the effective type parameters. If the node was parsed in a + * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + */ + export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray { + if (isJSDocSignature(node)) { + return emptyArray; + } + if (isJSDocTypeAlias(node)) { + Debug.assert(node.parent.kind === SyntaxKind.JSDocComment); + return flatMap(node.parent.tags, tag => isJSDocTemplateTag(tag) ? tag.typeParameters : undefined) as ReadonlyArray; + } + return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : emptyArray); + } } // Simple node tests of the form `node.kind === SyntaxKind.Foo`. @@ -6584,45 +6607,6 @@ namespace ts { return !!(node as HasType).type; } - /* True if the node could have a type node a `.type` */ - /* @internal */ - export function couldHaveType(node: Node): node is HasType { - switch (node.kind) { - case SyntaxKind.Parameter: - case SyntaxKind.PropertySignature: - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.TypePredicate: - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - case SyntaxKind.ParenthesizedType: - case SyntaxKind.TypeOperator: - case SyntaxKind.MappedType: - case SyntaxKind.TypeAssertionExpression: - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.AsExpression: - case SyntaxKind.VariableDeclaration: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.TypeAliasDeclaration: - case SyntaxKind.JSDocTypeExpression: - case SyntaxKind.JSDocNullableType: - case SyntaxKind.JSDocNonNullableType: - case SyntaxKind.JSDocOptionalType: - case SyntaxKind.JSDocFunctionType: - case SyntaxKind.JSDocVariadicType: - return true; - } - return false; - } - /** True if has initializer node attached to it. */ /* @internal */ export function hasInitializer(node: Node): node is HasInitializer { @@ -6870,6 +6854,13 @@ namespace ts { /* @internal */ export function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + Comparison.EqualTo; + } + + /* @internal */ + export function compareDiagnosticsSkipRelatedInformation(d1: Diagnostic, d2: Diagnostic): Comparison { return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || compareValues(d1.start, d2.start) || compareValues(d1.length, d2.length) || @@ -6878,6 +6869,19 @@ namespace ts { Comparison.EqualTo; } + function compareRelatedInformation(d1: Diagnostic, d2: Diagnostic): Comparison { + if (!d1.relatedInformation && !d2.relatedInformation) { + return Comparison.EqualTo; + } + if (d1.relatedInformation && d2.relatedInformation) { + return compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || forEach(d1.relatedInformation, (d1i, index) => { + const d2i = d2.relatedInformation![index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || Comparison.EqualTo; + } + return d1.relatedInformation ? Comparison.LessThan : Comparison.GreaterThan; + } + function compareMessageText(t1: string | DiagnosticMessageChain, t2: string | DiagnosticMessageChain): Comparison { let text1: string | DiagnosticMessageChain | undefined = t1; let text2: string | DiagnosticMessageChain | undefined = t2; @@ -6931,7 +6935,7 @@ namespace ts { } export function getAreDeclarationMapsEnabled(options: CompilerOptions) { - return !!(options.declaration && options.declarationMap); + return !!(getEmitDeclarations(options) && options.declarationMap); } export function getAllowSyntheticDefaultImports(compilerOptions: CompilerOptions) { @@ -8098,4 +8102,28 @@ namespace ts { return findBestPatternMatch(patterns, _ => _, candidate); } + + export type Mutable = { -readonly [K in keyof T]: T[K] }; + + export function sliceAfter(arr: ReadonlyArray, value: T): ReadonlyArray { + const index = arr.indexOf(value); + Debug.assert(index !== -1); + return arr.slice(index); + } + + export function minAndMax(arr: ReadonlyArray, getValue: (value: T) => number): { readonly min: number, readonly max: number } { + Debug.assert(arr.length !== 0); + let min = getValue(arr[0]); + let max = min; + for (let i = 1; i < arr.length; i++) { + const value = getValue(arr[i]); + if (value < min) { + min = value; + } + else if (value > max) { + max = value; + } + } + return { min, max }; + } } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 886d3be337a12..2cfb469f15296 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -142,7 +142,7 @@ namespace ts { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, isStatement, start); if (ensureUseStrict && !startsWithUseStrict(statements)) { - statements = setTextRange(createNodeArray([createStatement(createLiteral("use strict")), ...statements]), statements); + statements = setTextRange(createNodeArray([createExpressionStatement(createLiteral("use strict")), ...statements]), statements); } const declarations = context.endLexicalEnvironment(); return setTextRange(createNodeArray(concatenate(declarations, statements)), statements); @@ -614,7 +614,7 @@ namespace ts { visitNode((node).declarationList, visitor, isVariableDeclarationList)); case SyntaxKind.ExpressionStatement: - return updateStatement(node, + return updateExpressionStatement(node, visitNode((node).expression, visitor, isExpression)); case SyntaxKind.IfStatement: @@ -1476,8 +1476,8 @@ namespace ts { } return isNodeArray(statements) - ? setTextRange(createNodeArray(prependStatements(statements.slice(), declarations)), statements) - : prependStatements(statements, declarations); + ? setTextRange(createNodeArray(addStatementsAfterPrologue(statements.slice(), declarations)), statements) + : addStatementsAfterPrologue(statements, declarations); } /** diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index e869dfc966cfb..4533d3358610c 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -475,22 +475,21 @@ namespace ts { // From tsc we want to get already parsed result and hence check for rootFileNames let newLine = updateNewLine(); + if (configFileName && host.configFileParsingResult) { + setConfigFileParsingResult(host.configFileParsingResult); + newLine = updateNewLine(); + } reportWatchDiagnostic(Diagnostics.Starting_compilation_in_watch_mode); - if (configFileName) { + if (configFileName && !host.configFileParsingResult) { newLine = getNewLineCharacter(optionsToExtendForConfigFile, () => host.getNewLine()); - if (host.configFileParsingResult) { - setConfigFileParsingResult(host.configFileParsingResult); - } - else { - Debug.assert(!rootFileNames); - parseConfigFile(); - } + Debug.assert(!rootFileNames); + parseConfigFile(); newLine = updateNewLine(); } const trace = host.trace && ((s: string) => { host.trace!(s + newLine); }); const watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? WatchLogLevel.Verbose : - compilerOptions.diagnostis ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; + compilerOptions.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None; const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? trace! : noop; // TODO: GH#18217 const { watchFile, watchFilePath, watchDirectory } = getWatchFactory(watchLogLevel, writeLog); diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index 45ae2e3547828..8fa04e52da3f3 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -398,7 +398,7 @@ namespace ts { case WatchLogLevel.TriggerOnly: return createFileWatcherWithTriggerLogging; case WatchLogLevel.Verbose: - return createFileWatcherWithLogging; + return addWatch === watchDirectory ? createDirectoryWatcherWithLogging : createFileWatcherWithLogging; } } @@ -413,9 +413,28 @@ namespace ts { }; } + function createDirectoryWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { + const watchInfo = `${watchCaption}:: Added:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`; + log(watchInfo); + const start = timestamp(); + const watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo); + const elapsed = timestamp() - start; + log(`Elapsed:: ${elapsed}ms ${watchInfo}`); + return { + close: () => { + const watchInfo = `${watchCaption}:: Close:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`; + log(watchInfo); + const start = timestamp(); + watcher.close(); + const elapsed = timestamp() - start; + log(`Elapsed:: ${elapsed}ms ${watchInfo}`); + } + }; + } + function createFileWatcherWithTriggerLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { return addWatch(host, file, (fileName, cbOptional) => { - const triggerredInfo = `${watchCaption}:: Triggered with ${fileName}${cbOptional !== undefined ? cbOptional : ""}:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`; + const triggerredInfo = `${watchCaption}:: Triggered with ${fileName} ${cbOptional !== undefined ? cbOptional : ""}:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`; log(triggerredInfo); const start = timestamp(); cb(fileName, cbOptional, passThrough); diff --git a/src/harness/client.ts b/src/harness/client.ts index 4cd29266027b5..ebe97aea0705d 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -73,7 +73,7 @@ namespace ts.server { return { span: this.decodeSpan(codeEdit, fileName), newText: codeEdit.newText }; } - private processRequest(command: string, args?: T["arguments"]): T { + private processRequest(command: string, args: T["arguments"]): T { const request: protocol.Request = { seq: this.sequence, type: "request", @@ -224,9 +224,9 @@ namespace ts.server { containerName: entry.containerName || "", containerKind: entry.containerKind || ScriptElementKind.unknown, kind: entry.kind, - kindModifiers: entry.kindModifiers!, // TODO: GH#18217 - matchKind: entry.matchKind!, // TODO: GH#18217 - isCaseSensitive: entry.isCaseSensitive!, // TODO: GH#18217 + kindModifiers: entry.kindModifiers || "", + matchKind: entry.matchKind as keyof typeof PatternMatchKind, + isCaseSensitive: entry.isCaseSensitive, fileName: entry.file, textSpan: this.decodeSpan(entry), })); @@ -278,9 +278,10 @@ namespace ts.server { const request = this.processRequest(CommandNames.DefinitionAndBoundSpan, args); const response = this.processResponse(request); + const body = Debug.assertDefined(response.body); // TODO: GH#18217 return { - definitions: response.body!.definitions.map(entry => ({ // TODO: GH#18217 + definitions: body.definitions.map(entry => ({ containerKind: ScriptElementKind.unknown, containerName: "", fileName: entry.file, @@ -288,7 +289,7 @@ namespace ts.server { kind: ScriptElementKind.unknown, name: "" })), - textSpan: this.decodeSpan(response.body!.textSpan, request.arguments.file) + textSpan: this.decodeSpan(body.textSpan, request.arguments.file) }; } @@ -341,8 +342,10 @@ namespace ts.server { })); } - getEmitOutput(_fileName: string): EmitOutput { - return notImplemented(); + getEmitOutput(file: string): EmitOutput { + const request = this.processRequest(protocol.CommandTypes.EmitOutput, { file }); + const response = this.processResponse(request); + return response.body; } getSyntacticDiagnostics(file: string): DiagnosticWithLocation[] { @@ -716,6 +719,10 @@ namespace ts.server { throw new Error("cleanupSemanticCache is not available through the server layer."); } + getSourceMapper(): never { + return notImplemented(); + } + dispose(): void { throw new Error("dispose is not available through the server layer."); } diff --git a/src/harness/compiler.ts b/src/harness/compiler.ts index 1290bbb4be8d2..7d41545708ba7 100644 --- a/src/harness/compiler.ts +++ b/src/harness/compiler.ts @@ -53,6 +53,7 @@ namespace compiler { public readonly js: ReadonlyMap; public readonly dts: ReadonlyMap; public readonly maps: ReadonlyMap; + public symlinks?: vfs.FileSet; // Location to store original symlinks so they may be used in both original and declaration file compilations private _inputs: documents.TextDocument[] = []; private _inputsAndOutputs: collections.SortedMap; diff --git a/src/harness/documents.ts b/src/harness/documents.ts index 52773bf774ae4..312339287e245 100644 --- a/src/harness/documents.ts +++ b/src/harness/documents.ts @@ -148,7 +148,7 @@ namespace documents { public static fromUrl(url: string) { const match = SourceMap._dataURLRegExp.exec(url); - return match ? new SourceMap(/*mapFile*/ undefined, new Buffer(match[1], "base64").toString("utf8")) : undefined; + return match ? new SourceMap(/*mapFile*/ undefined, ts.sys.base64decode!(match[1])) : undefined; } public static fromSource(text: string): SourceMap | undefined { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index f2ff965d4b2bd..6d50a66ad49df 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -709,7 +709,7 @@ namespace FourSlash { ts.zipWith(endMarkers, definitions, (endMarker, definition, i) => { const marker = this.getMarkerByName(endMarker); - if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) { + if (ts.comparePaths(marker.fileName, definition.fileName, /*ignoreCase*/ true) !== ts.Comparison.EqualTo || marker.position !== definition.textSpan.start) { this.raiseError(`${testName} failed for definition ${endMarker} (${i}): expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`); } }); @@ -1007,7 +1007,7 @@ namespace FourSlash { // If any of the expected values are undefined, assume that users don't // care about them. - if (replacementSpan && !TestState.textSpansEqual(replacementSpan, entry.replacementSpan)) { + if (replacementSpan && !ts.textSpansEqual(replacementSpan, entry.replacementSpan)) { return false; } else if (expectedText && text !== expectedText) { @@ -1426,18 +1426,22 @@ Actual: ${stringify(fullActual)}`); } } - public verifyNoSignatureHelp(markers: ReadonlyArray) { + public verifySignatureHelpPresence(expectPresent: boolean, triggerReason: ts.SignatureHelpTriggerReason | undefined, markers: ReadonlyArray) { if (markers.length) { for (const marker of markers) { this.goToMarker(marker); - this.verifyNoSignatureHelp(ts.emptyArray); + this.verifySignatureHelpPresence(expectPresent, triggerReason, ts.emptyArray); } return; } - - const actual = this.getSignatureHelp(); - if (actual) { - this.raiseError(`Expected no signature help, but got "${stringify(actual)}"`); + const actual = this.getSignatureHelp({ triggerReason }); + if (expectPresent !== !!actual) { + if (actual) { + this.raiseError(`Expected no signature help, but got "${stringify(actual)}"`); + } + else { + this.raiseError("Expected signature help, but none was returned."); + } } } @@ -1456,7 +1460,7 @@ Actual: ${stringify(fullActual)}`); } private verifySignatureHelpWorker(options: FourSlashInterface.VerifySignatureHelpOptions) { - const help = this.getSignatureHelp()!; + const help = this.getSignatureHelp({ triggerReason: options.triggerReason })!; const selectedItem = help.items[help.selectedItemIndex]; // Argument index may exceed number of parameters const currentParameter = selectedItem.parameters[help.argumentIndex] as ts.SignatureHelpParameter | undefined; @@ -1498,6 +1502,7 @@ Actual: ${stringify(fullActual)}`); const allKeys: ReadonlyArray = [ "marker", + "triggerReason", "overloadsCount", "docComment", "text", @@ -1510,7 +1515,9 @@ Actual: ${stringify(fullActual)}`); "argumentCount", ]; for (const key in options) { - ts.Debug.assert(ts.contains(allKeys, key)); + if (!ts.contains(allKeys, key)) { + ts.Debug.fail("Unexpected key " + key); + } } } @@ -1639,7 +1646,7 @@ Actual: ${stringify(fullActual)}`); }); } - public baselineGetEmitOutput(insertResultsIntoVfs?: boolean) { + private getEmitFiles(): ReadonlyArray { // Find file to be emitted const emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on @@ -1656,12 +1663,29 @@ Actual: ${stringify(fullActual)}`); this.raiseError("No emitThisFile is specified in the test file"); } + return emitFiles; + } + + public verifyGetEmitOutput(expectedOutputFiles: ReadonlyArray): void { + const outputFiles = ts.flatMap(this.getEmitFiles(), e => this.languageService.getEmitOutput(e.fileName).outputFiles); + + assert.deepEqual(outputFiles.map(f => f.name), expectedOutputFiles); + + for (const { name, text } of outputFiles) { + const fromTestFile = this.getFileContent(name); + if (fromTestFile !== text) { + this.raiseError("Emit output is not as expected: " + showTextDiff(fromTestFile, text)); + } + } + } + + public baselineGetEmitOutput(): void { Harness.Baseline.runBaseline( - this.testData.globalOptions[MetadataOptionNames.baselineFile], + ts.Debug.assertDefined(this.testData.globalOptions[MetadataOptionNames.baselineFile]), () => { let resultString = ""; // Loop through all the emittedFiles and emit them one by one - emitFiles.forEach(emitFile => { + for (const emitFile of this.getEmitFiles()) { const emitOutput = this.languageService.getEmitOutput(emitFile.fileName); // Print emitOutputStatus in readable format resultString += "EmitSkipped: " + emitOutput.emitSkipped + Harness.IO.newLine(); @@ -1687,13 +1711,10 @@ Actual: ${stringify(fullActual)}`); for (const outputFile of emitOutput.outputFiles) { const fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); - resultString = resultString + fileName + outputFile.text; - if (insertResultsIntoVfs) { - this.languageServiceAdapterHost.addScript(ts.getNormalizedAbsolutePath(outputFile.name, "/"), outputFile.text, /*isRootFile*/ true); - } + resultString = resultString + Harness.IO.newLine() + fileName + outputFile.text; } resultString += Harness.IO.newLine(); - }); + } return resultString; }); @@ -1724,7 +1745,7 @@ Actual: ${stringify(fullActual)}`); } public printCurrentParameterHelp() { - const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition, /*options*/ undefined); Harness.IO.log(stringify(help)); } @@ -1765,12 +1786,14 @@ Actual: ${stringify(fullActual)}`); } public printCurrentSignatureHelp() { - const help = this.getSignatureHelp()!; + const help = this.getSignatureHelp(ts.emptyOptions)!; Harness.IO.log(stringify(help.items[help.selectedItemIndex])); } - private getSignatureHelp(): ts.SignatureHelpItems | undefined { - return this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + private getSignatureHelp({ triggerReason }: FourSlashInterface.VerifySignatureHelpOptions): ts.SignatureHelpItems | undefined { + return this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition, { + triggerReason + }); } public printCompletionListMembers(preferences: ts.UserPreferences | undefined) { @@ -1866,13 +1889,18 @@ Actual: ${stringify(fullActual)}`); offset++; if (highFidelity) { - if (ch === "(" || ch === ",") { + if (ch === "(" || ch === "," || ch === "<") { /* Signature help*/ - this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset); + this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset, { + triggerReason: { + kind: "characterTyped", + triggerCharacter: ch + } + }); } else if (prevChar === " " && /A-Za-z_/.test(ch)) { /* Completions */ - this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset, ts.defaultPreferences); + this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset, ts.emptyOptions); } if (i % checkCadence === 0) { @@ -2125,11 +2153,10 @@ Actual: ${stringify(fullActual)}`); this.raiseError("verifyRangesInImplementationList failed - expected to find at least one implementation location but got 0"); } - const duplicate = findDuplicatedElement(implementations, implementationsAreEqual); + const duplicate = findDuplicatedElement(implementations, ts.documentSpansEqual); if (duplicate) { const { textSpan, fileName } = duplicate; - const end = textSpan.start + textSpan.length; - this.raiseError(`Duplicate implementations returned for range (${textSpan.start}, ${end}) in ${fileName}`); + this.raiseError(`Duplicate implementations returned for range (${textSpan.start}, ${ts.textSpanEnd(textSpan)}) in ${fileName}`); } const ranges = this.getRanges(); @@ -2196,10 +2223,6 @@ Actual: ${stringify(fullActual)}`); this.raiseError(error); } - function implementationsAreEqual(a: ImplementationLocationInformation, b: ImplementationLocationInformation) { - return a.fileName === b.fileName && TestState.textSpansEqual(a.textSpan, b.textSpan); - } - function displayPartIsEqualTo(a: ts.SymbolDisplayPart, b: ts.SymbolDisplayPart): boolean { return a.kind === b.kind && a.text === b.text; } @@ -2284,6 +2307,14 @@ Actual: ${stringify(fullActual)}`); } } + public verifyFormatDocumentChangesNothing(): void { + const { fileName } = this.activeFile; + const before = this.getFileContent(fileName); + this.formatDocument(); + const after = this.getFileContent(fileName); + this.assertObjectsEqual(after, before); + } + public verifyTextAtCaretIs(text: string) { const actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length); if (actual !== text) { @@ -2505,7 +2536,7 @@ Actual: ${stringify(fullActual)}`); `Expected '${fixId}'. Available action ids: ${ts.mapDefined(this.getCodeFixes(this.activeFile.fileName), a => a.fixId)}`); ts.Debug.assertEqual(fixWithId!.fixAllDescription, fixAllDescription); - const { changes, commands } = this.languageService.getCombinedCodeFix({ type: "file", fileName: this.activeFile.fileName }, fixId, this.formatCodeSettings, ts.defaultPreferences); + const { changes, commands } = this.languageService.getCombinedCodeFix({ type: "file", fileName: this.activeFile.fileName }, fixId, this.formatCodeSettings, ts.emptyOptions); assert.deepEqual | undefined>(commands, expectedCommands); assert(changes.every(c => c.fileName === this.activeFile.fileName), "TODO: support testing codefixes that touch multiple files"); this.applyChanges(changes); @@ -2585,7 +2616,7 @@ Actual: ${stringify(fullActual)}`); * Rerieves a codefix satisfying the parameters, or undefined if no such codefix is found. * @param fileName Path to file where error should be retrieved from. */ - private getCodeFixes(fileName: string, errorCode?: number, preferences: ts.UserPreferences = ts.defaultPreferences): ts.CodeFixAction[] { + private getCodeFixes(fileName: string, errorCode?: number, preferences: ts.UserPreferences = ts.emptyOptions): ts.CodeFixAction[] { const diagnosticsForCodeFix = this.getDiagnostics(fileName, /*includeSuggestions*/ true).map(diagnostic => ({ start: diagnostic.start, length: diagnostic.length, @@ -2631,7 +2662,7 @@ Actual: ${stringify(fullActual)}`); } const range = ts.firstOrUndefined(ranges); - const codeFixes = this.getCodeFixes(fileName, errorCode, preferences).filter(f => f.fixId === undefined); // TODO: GH#20315 filter out those that use the import fix ID; + const codeFixes = this.getCodeFixes(fileName, errorCode, preferences).filter(f => f.fixId === ts.codefix.importFixId); if (codeFixes.length === 0) { if (expectedTextArray.length !== 0) { @@ -2775,57 +2806,20 @@ Actual: ${stringify(fullActual)}`); } } - /* - Check number of navigationItems which match both searchValue and matchKind, - if a filename is passed in, limit the results to that file. - Report an error if expected value and actual value do not match. - */ - public verifyNavigationItemsCount(expected: number, searchValue: string, matchKind?: string, fileName?: string) { - const items = this.languageService.getNavigateToItems(searchValue, /*maxResultCount*/ undefined, fileName); - let actual = 0; - - // Count only the match that match the same MatchKind - for (const item of items) { - if (!matchKind || item.matchKind === matchKind) { - actual++; - } - } - - if (expected !== actual) { - this.raiseError(`verifyNavigationItemsCount failed - found: ${actual} navigation items, expected: ${expected}.`); - } - } - - /* - Verify that returned navigationItems from getNavigateToItems have matched searchValue, matchKind, and kind. - Report an error if getNavigateToItems does not find any matched searchValue. - */ - public verifyNavigationItemsListContains( - name: string, - kind: string, - searchValue: string, - matchKind: string, - fileName?: string, - parentName?: string) { - const items = this.languageService.getNavigateToItems(searchValue); - - if (!items || items.length === 0) { - this.raiseError("verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one."); - } - - for (const item of items) { - if (item && item.name === name && item.kind === kind && - (matchKind === undefined || item.matchKind === matchKind) && - (fileName === undefined || item.fileName === fileName) && - (parentName === undefined || item.containerName === parentName)) { - return; - } - } - - // if there was an explicit match kind specified, then it should be validated. - if (matchKind !== undefined) { - const missingItem = { name, kind, searchValue, matchKind, fileName, parentName }; - this.raiseError(`verifyNavigationItemsListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(items)})`); + public verifyNavigateTo(options: ReadonlyArray): void { + for (const { pattern, expected, fileName } of options) { + const items = this.languageService.getNavigateToItems(pattern, /*maxResultCount*/ undefined, fileName); + this.assertObjectsEqual(items, expected.map((e): ts.NavigateToItem => ({ + name: e.name, + kind: e.kind, + kindModifiers: e.kindModifiers || "", + matchKind: e.matchKind || "exact", + isCaseSensitive: e.isCaseSensitive === undefined ? true : e.isCaseSensitive, + fileName: e.range.fileName, + textSpan: ts.createTextSpanFromRange(e.range), + containerName: e.containerName || "", + containerKind: e.containerKind || ts.ScriptElementKind.unknown, + }))); } } @@ -3067,7 +3061,7 @@ Actual: ${stringify(fullActual)}`); this.raiseError(`Expected action description to be ${JSON.stringify(actionDescription)}, got: ${JSON.stringify(action.description)}`); } - const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, this.formatCodeSettings, range, refactorName, actionName, ts.defaultPreferences)!; + const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, this.formatCodeSettings, range, refactorName, actionName, ts.emptyOptions)!; for (const edit of editInfo.edits) { this.applyEdits(edit.fileName, edit.textChanges, /*isFormattingEdit*/ false); } @@ -3131,7 +3125,7 @@ Actual: ${stringify(fullActual)}`); const action = ts.first(refactor.actions); assert(action.name === "Move to a new file" && action.description === "Move to a new file"); - const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, this.formatCodeSettings, range, refactor.name, action.name, options.preferences || ts.defaultPreferences)!; + const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, this.formatCodeSettings, range, refactor.name, action.name, options.preferences || ts.emptyOptions)!; this.testNewFileContents(editInfo.edits, options.newFileContents, "move to new file"); } @@ -3173,14 +3167,14 @@ Actual: ${stringify(fullActual)}`); formattingOptions = formattingOptions || this.formatCodeSettings; const markerPos = this.getMarkerByName(markerName).position; - const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, markerPos, ts.defaultPreferences); + const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, markerPos, ts.emptyOptions); const applicableRefactorToApply = ts.find(applicableRefactors, refactor => refactor.name === refactorNameToApply); if (!applicableRefactorToApply) { this.raiseError(`The expected refactor: ${refactorNameToApply} is not available at the marker location.`); } - const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, formattingOptions, markerPos, refactorNameToApply, actionName, ts.defaultPreferences)!; + const editInfo = this.languageService.getEditsForRefactor(this.activeFile.fileName, formattingOptions, markerPos, refactorNameToApply, actionName, ts.emptyOptions)!; for (const edit of editInfo.edits) { this.applyEdits(edit.fileName, edit.textChanges, /*isFormattingEdit*/ false); @@ -3285,7 +3279,7 @@ Actual: ${stringify(fullActual)}`); if (spanIndex !== undefined) { const span = this.getTextSpanForRangeAtIndex(spanIndex); - assert.isTrue(TestState.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + stringify(entryId))); + assert.isTrue(ts.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + stringify(entryId))); } eq(item.hasAction, hasAction, "hasAction"); @@ -3371,13 +3365,9 @@ Actual: ${stringify(fullActual)}`); this.cancellationToken.resetCancelled(); } - private static textSpansEqual(a: ts.TextSpan | undefined, b: ts.TextSpan | undefined): boolean { - return !!a && !!b && a.start === b.start && a.length === b.length; - } - - public getEditsForFileRename({ oldPath, newPath, newFileContents }: FourSlashInterface.GetEditsForFileRenameOptions): void { + public getEditsForFileRename({ oldPath, newPath, newFileContents, preferences }: FourSlashInterface.GetEditsForFileRenameOptions): void { const test = (fileContents: { readonly [fileName: string]: string }, description: string): void => { - const changes = this.languageService.getEditsForFileRename(oldPath, newPath, this.formatCodeSettings, ts.defaultPreferences); + const changes = this.languageService.getEditsForFileRename(oldPath, newPath, this.formatCodeSettings, preferences); this.testNewFileContents(changes, fileContents, description); }; @@ -3387,11 +3377,11 @@ Actual: ${stringify(fullActual)}`); this.languageServiceAdapterHost.renameFileOrDirectory(oldPath, newPath); this.languageService.cleanupSemanticCache(); - const pathUpdater = ts.getPathUpdater(oldPath, newPath, ts.createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ false)); + const pathUpdater = ts.getPathUpdater(oldPath, newPath, ts.createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ false), /*sourceMapper*/ undefined); test(renameKeys(newFileContents, key => pathUpdater(key) || key), "with file moved"); } - private getApplicableRefactors(positionOrRange: number | ts.TextRange, preferences = ts.defaultPreferences): ReadonlyArray { + private getApplicableRefactors(positionOrRange: number | ts.TextRange, preferences = ts.emptyOptions): ReadonlyArray { return this.languageService.getApplicableRefactors(this.activeFile.fileName, positionOrRange, preferences) || ts.emptyArray; } } @@ -3576,8 +3566,13 @@ ${code} function getNonFileNameOptionInObject(optionObject: { [s: string]: string }): string | undefined { for (const option in optionObject) { - if (option !== MetadataOptionNames.fileName) { - return option; + switch (option) { + case MetadataOptionNames.fileName: + case MetadataOptionNames.baselineFile: + case MetadataOptionNames.emitThisFile: + break; + default: + return option; } } return undefined; @@ -4079,7 +4074,15 @@ namespace FourSlashInterface { } public noSignatureHelp(...markers: string[]): void { - this.state.verifyNoSignatureHelp(markers); + this.state.verifySignatureHelpPresence(/*expectPresent*/ false, /*triggerReason*/ undefined, markers); + } + + public noSignatureHelpForTriggerReason(reason: ts.SignatureHelpTriggerReason, ...markers: string[]): void { + this.state.verifySignatureHelpPresence(/*expectPresent*/ false, reason, markers); + } + + public signatureHelpPresentForTriggerReason(reason: ts.SignatureHelpTriggerReason, ...markers: string[]): void { + this.state.verifySignatureHelpPresence(/*expectPresent*/ true, reason, markers); } public signatureHelp(...options: VerifySignatureHelpOptions[]): void { @@ -4211,6 +4214,10 @@ namespace FourSlashInterface { this.state.verifyCurrentFileContent(text); } + public formatDocumentChangesNothing(): void { + this.state.verifyFormatDocumentChangesNothing(); + } + public goToDefinitionIs(endMarkers: ArrayOrSingle) { this.state.verifyGoToDefinitionIs(endMarkers); } @@ -4287,8 +4294,12 @@ namespace FourSlashInterface { this.state.baselineCurrentFileNameOrDottedNameSpans(); } - public baselineGetEmitOutput(insertResultsIntoVfs?: boolean) { - this.state.baselineGetEmitOutput(insertResultsIntoVfs); + public getEmitOutput(expectedOutputFiles: ReadonlyArray): void { + this.state.verifyGetEmitOutput(expectedOutputFiles); + } + + public baselineGetEmitOutput() { + this.state.baselineGetEmitOutput(); } public baselineQuickInfo() { @@ -4361,24 +4372,8 @@ namespace FourSlashInterface { this.state.verifyNavigationTree(json, options); } - public navigationItemsListCount(count: number, searchValue: string, matchKind?: string, fileName?: string) { - this.state.verifyNavigationItemsCount(count, searchValue, matchKind, fileName); - } - - public navigationItemsListContains( - name: string, - kind: string, - searchValue: string, - matchKind: string, - fileName?: string, - parentName?: string) { - this.state.verifyNavigationItemsListContains( - name, - kind, - searchValue, - matchKind, - fileName, - parentName); + public navigateTo(...options: VerifyNavigateToOptions[]): void { + this.state.verifyNavigateTo(options); } public occurrencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean) { @@ -4784,7 +4779,7 @@ namespace FourSlashInterface { } export interface VerifyCompletionsOptions { - readonly marker?: ArrayOrSingle; + readonly marker?: ArrayOrSingle; readonly isNewIdentifierLocation?: boolean; readonly exact?: ArrayOrSingle; readonly includes?: ArrayOrSingle; @@ -4810,6 +4805,24 @@ namespace FourSlashInterface { readonly isVariadic?: boolean; /** @default ts.emptyArray */ readonly tags?: ReadonlyArray; + readonly triggerReason?: ts.SignatureHelpTriggerReason; + } + + export interface VerifyNavigateToOptions { + readonly pattern: string; + readonly fileName?: string; + readonly expected: ReadonlyArray; + } + + export interface ExpectedNavigateToItem { + readonly name: string; + readonly kind: ts.ScriptElementKind; + readonly kindModifiers?: string; + readonly matchKind?: keyof typeof ts.PatternMatchKind; + readonly isCaseSensitive?: boolean; + readonly range: FourSlash.Range; + readonly containerName?: string; + readonly containerKind?: ts.ScriptElementKind; } export type ArrayOrSingle = T | ReadonlyArray; @@ -4877,6 +4890,7 @@ namespace FourSlashInterface { readonly oldPath: string; readonly newPath: string; readonly newFileContents: { readonly [fileName: string]: string }; + readonly preferences?: ts.UserPreferences; } export interface MoveToNewFileOptions { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 0b72834e1c2b6..58a63bc84c098 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -66,11 +66,8 @@ namespace Utils { export let currentExecutionEnvironment = getExecutionEnvironment(); - // Thanks to browserify, Buffer is always available nowadays - const Buffer: typeof global.Buffer = require("buffer").Buffer; - export function encodeString(s: string): string { - return Buffer.from(s).toString("utf8"); + return ts.sys.bufferFrom!(s).toString("utf8"); } export function byteLength(s: string, encoding?: string): number { @@ -1223,7 +1220,9 @@ namespace Harness { fs.apply(symlinks); } const host = new fakes.CompilerHost(fs, options); - return compiler.compileFiles(host, programFileNames, options); + const result = compiler.compileFiles(host, programFileNames, options); + result.symlinks = symlinks; + return result; } export interface DeclarationCompilationContext { @@ -1264,7 +1263,7 @@ namespace Harness { } function addDtsFile(file: TestFile, dtsFiles: TestFile[]) { - if (vpath.isDeclaration(file.unitName)) { + if (vpath.isDeclaration(file.unitName) || vpath.isJson(file.unitName)) { dtsFiles.push(file); } else if (vpath.isTypeScript(file.unitName)) { @@ -1305,12 +1304,12 @@ namespace Harness { } } - export function compileDeclarationFiles(context: DeclarationCompilationContext | undefined) { + export function compileDeclarationFiles(context: DeclarationCompilationContext | undefined, symlinks: vfs.FileSet | undefined) { if (!context) { return; } const { declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory } = context; - const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory); + const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory, symlinks); return { declInputFiles, declOtherFiles, declResult: output }; } @@ -1348,6 +1347,12 @@ namespace Harness { return "\r\n"; } + const formatDiagnsoticHost = { + getCurrentDirectory: () => options && options.currentDirectory ? options.currentDirectory : "", + getNewLine: () => IO.newLine(), + getCanonicalFileName: ts.createGetCanonicalFileName(options && options.caseSensitive !== undefined ? options.caseSensitive : true), + }; + function outputErrorText(error: ts.Diagnostic) { const message = ts.flattenDiagnosticMessageText(error.messageText, IO.newLine()); @@ -1356,6 +1361,11 @@ namespace Harness { .map(s => s.length > 0 && s.charAt(s.length - 1) === "\r" ? s.substr(0, s.length - 1) : s) .filter(s => s.length > 0) .map(s => "!!! " + ts.diagnosticCategoryName(error) + " TS" + error.code + ": " + s); + if (error.relatedInformation) { + for (const info of error.relatedInformation) { + errLines.push(`!!! related TS${info.code}${info.file ? " " + ts.formatLocation(info.file, info.start!, formatDiagnsoticHost, ts.identity) : ""}: ${ts.flattenDiagnosticMessageText(info.messageText, IO.newLine())}`); + } + } errLines.forEach(e => outputLines += (newLine() + e)); errorsReported++; @@ -1678,7 +1688,7 @@ namespace Harness { const declFileContext = prepareDeclarationCompilationContext( toBeCompiled, otherFiles, result, harnessSettings, options, /*currentDirectory*/ undefined ); - const declFileCompilationResult = compileDeclarationFiles(declFileContext); + const declFileCompilationResult = compileDeclarationFiles(declFileContext, result.symlinks); if (declFileCompilationResult && declFileCompilationResult.declResult.diagnostics.length) { jsCode += "\r\n\r\n//// [DtsFileErrors]\r\n"; @@ -1882,6 +1892,7 @@ namespace Harness { for (const line of lines) { let testMetaData: RegExpExecArray | null; const linkMetaData = linkRegex.exec(line); + linkRegex.lastIndex = 0; if (linkMetaData) { if (!symlinks) symlinks = {}; symlinks[linkMetaData[2].trim()] = new vfs.Symlink(linkMetaData[1].trim()); diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index e6b16efe6c7ca..fa9c88d3ffafc 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -155,7 +155,7 @@ namespace Harness.LanguageService { this.vfs.mkdirpSync(ts.getDirectoryPath(newPath)); this.vfs.renameSync(oldPath, newPath); - const updater = ts.getPathUpdater(oldPath, newPath, ts.createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ false)); + const updater = ts.getPathUpdater(oldPath, newPath, ts.createGetCanonicalFileName(this.useCaseSensitiveFileNames()), /*sourceMapper*/ undefined); this.scriptInfos.forEach((scriptInfo, key) => { const newFileName = updater(key); if (newFileName !== undefined) { @@ -189,6 +189,10 @@ namespace Harness.LanguageService { assert.isOk(script); return ts.computeLineAndCharacterOfPosition(script.getLineMap(), position); } + + useCaseSensitiveFileNames() { + return !this.vfs.ignoreCase; + } } /// Native adapter @@ -251,7 +255,6 @@ namespace Harness.LanguageService { return 0; } - log = ts.noop; trace = ts.noop; error = ts.noop; @@ -449,8 +452,8 @@ namespace Harness.LanguageService { getBreakpointStatementAtPosition(fileName: string, position: number): ts.TextSpan { return unwrapJSONCallResult(this.shim.getBreakpointStatementAtPosition(fileName, position)); } - getSignatureHelpItems(fileName: string, position: number): ts.SignatureHelpItems { - return unwrapJSONCallResult(this.shim.getSignatureHelpItems(fileName, position)); + getSignatureHelpItems(fileName: string, position: number, options: ts.SignatureHelpItemsOptions | undefined): ts.SignatureHelpItems { + return unwrapJSONCallResult(this.shim.getSignatureHelpItems(fileName, position, options)); } getRenameInfo(fileName: string, position: number): ts.RenameInfo { return unwrapJSONCallResult(this.shim.getRenameInfo(fileName, position)); @@ -557,6 +560,9 @@ namespace Harness.LanguageService { getSourceFile(): ts.SourceFile { throw new Error("SourceFile can not be marshaled across the shim layer."); } + getSourceMapper(): never { + return ts.notImplemented(); + } dispose(): void { this.shim.dispose({}); } } @@ -704,7 +710,9 @@ namespace Harness.LanguageService { return ts.sys.getEnvironmentVariable(name); } - readDirectory() { return ts.notImplemented(); } + readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[] { + return this.host.readDirectory(path, extensions, exclude, include, depth); + } watchFile(): ts.FileWatcher { return { close: ts.noop }; diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index 22f0659690b61..a1aa07f8733d0 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -305,7 +305,8 @@ namespace Harness.SourceMapRecorder { } SourceMapSpanWriter.initializeSourceMapSpanWriter(sourceMapRecorder, sourceMapData, currentFile); - for (const decodedSourceMapping of sourceMapData.sourceMapDecodedMappings) { + const mapper = ts.sourcemaps.decodeMappings({ mappings: sourceMapData.sourceMapMappings, sources: sourceMapData.sourceMapSources }); + for (let { value: decodedSourceMapping, done } = mapper.next(); !done; { value: decodedSourceMapping, done } = mapper.next()) { const currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex])!; if (currentSourceFile !== prevSourceFile) { SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text); diff --git a/src/harness/utils.ts b/src/harness/utils.ts index d7e113c45fbd9..4650badadafa3 100644 --- a/src/harness/utils.ts +++ b/src/harness/utils.ts @@ -63,10 +63,6 @@ namespace utils { return indentation; } - export function toUtf8(text: string): string { - return new Buffer(text).toString("utf8"); - } - export function getByteOrderMarkLength(text: string): number { if (text.length >= 1) { const ch0 = text.charCodeAt(0); diff --git a/src/harness/vfs.ts b/src/harness/vfs.ts index ae99187f5fade..ee9519f254c07 100644 --- a/src/harness/vfs.ts +++ b/src/harness/vfs.ts @@ -683,7 +683,7 @@ namespace vfs { if (isDirectory(node)) throw createIOError("EISDIR"); if (!isFile(node)) throw createIOError("EBADF"); - node.buffer = Buffer.isBuffer(data) ? data.slice() : Buffer.from("" + data, encoding || "utf8"); + node.buffer = Buffer.isBuffer(data) ? data.slice() : ts.sys.bufferFrom!("" + data, encoding || "utf8"); node.size = node.buffer.byteLength; node.mtimeMs = time; node.ctimeMs = time; @@ -1204,7 +1204,7 @@ namespace vfs { } }, readFileSync(path: string): Buffer { - return Buffer.from(host.readFile(path)!, "utf8"); // TODO: GH#18217 + return ts.sys.bufferFrom!(host.readFile(path)!, "utf8"); // TODO: GH#18217 } }; } diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index 6645e12c8321a..572c59bb305fd 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -78,7 +78,9 @@ interface Array {}` } export interface SymLink { + /** Location of the symlink. */ path: string; + /** Relative path to the real file. */ symLink: string; } @@ -350,9 +352,9 @@ interface Array {}` if (tscWatchDirectory === Tsc_WatchDirectory.WatchFile) { const watchDirectory: HostWatchDirectory = (directory, cb) => this.watchFile(directory, () => cb(directory), PollingInterval.Medium); this.customRecursiveWatchDirectory = createRecursiveDirectoryWatcher({ + useCaseSensitiveFileNames: this.useCaseSensitiveFileNames, directoryExists: path => this.directoryExists(path), getAccessibleSortedChildDirectories: path => this.getDirectories(path), - filePathComparer: this.useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive, watchDirectory, realpath: s => this.realpath(s) }); @@ -360,9 +362,9 @@ interface Array {}` else if (tscWatchDirectory === Tsc_WatchDirectory.NonRecursiveWatchDirectory) { const watchDirectory: HostWatchDirectory = (directory, cb) => this.watchDirectory(directory, fileName => cb(fileName), /*recursive*/ false); this.customRecursiveWatchDirectory = createRecursiveDirectoryWatcher({ + useCaseSensitiveFileNames: this.useCaseSensitiveFileNames, directoryExists: path => this.directoryExists(path), getAccessibleSortedChildDirectories: path => this.getDirectories(path), - filePathComparer: this.useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive, watchDirectory, realpath: s => this.realpath(s) }); @@ -371,9 +373,9 @@ interface Array {}` const watchFile = createDynamicPriorityPollingWatchFile(this); const watchDirectory: HostWatchDirectory = (directory, cb) => watchFile(directory, () => cb(directory), PollingInterval.Medium); this.customRecursiveWatchDirectory = createRecursiveDirectoryWatcher({ + useCaseSensitiveFileNames: this.useCaseSensitiveFileNames, directoryExists: path => this.directoryExists(path), getAccessibleSortedChildDirectories: path => this.getDirectories(path), - filePathComparer: this.useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive, watchDirectory, realpath: s => this.realpath(s) }); @@ -615,6 +617,13 @@ interface Array {}` } } + removeFile(filePath: string) { + const path = this.toFullPath(filePath); + const currentEntry = this.fs.get(path) as FsFile; + Debug.assert(isFsFile(currentEntry)); + this.removeFileOrFolder(currentEntry, returnFalse); + } + removeFolder(folderPath: string, recursive?: boolean) { const path = this.toFullPath(folderPath); const currentEntry = this.fs.get(path) as FsFolder; diff --git a/src/jsTyping/types.ts b/src/jsTyping/types.ts index dfa47ccd7def8..4e00c2eb6f5e4 100644 --- a/src/jsTyping/types.ts +++ b/src/jsTyping/types.ts @@ -1,4 +1,3 @@ -/* @internal */ declare namespace ts.server { export type ActionSet = "action::set"; export type ActionInvalidate = "action::invalidate"; diff --git a/src/lib/README.md b/src/lib/README.md index cbf80e4d0da6e..93c62e317bf0a 100644 --- a/src/lib/README.md +++ b/src/lib/README.md @@ -5,4 +5,4 @@ The files within this directory are used to generate `lib.d.ts` and `lib.es6.d.t ## Generated files Any files ending in `.generated.d.ts` aren't mean to be edited by hand. -If you need to make changes to such files, make a change to the input files for our [library generator](https://github.com/Microsoft/TSJS-lib-generator). +If you need to make changes to such files, make a change to the input files for [**our library generator**](https://github.com/Microsoft/TSJS-lib-generator). diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index fd49ca1f25b8a..46bb7af0c8fc7 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -9,8 +9,7 @@ interface Map { } interface MapConstructor { - new (): Map; - new (entries?: ReadonlyArray<[K, V]> | null): Map; + new (entries?: ReadonlyArray<[K, V]> | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; @@ -45,8 +44,7 @@ interface Set { } interface SetConstructor { - new (): Set; - new (values?: ReadonlyArray | null): Set; + new (values?: ReadonlyArray | null): Set; readonly prototype: Set; } declare var Set: SetConstructor; @@ -64,8 +62,7 @@ interface WeakSet { } interface WeakSetConstructor { - new (): WeakSet; - new (values?: ReadonlyArray | null): WeakSet; + new (values?: ReadonlyArray | null): WeakSet; readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index b7c04c60ce039..568d3596ddae3 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -135,7 +135,7 @@ interface MapConstructor { interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; } interface Set { @@ -183,7 +183,7 @@ interface SetConstructor { interface WeakSet { } interface WeakSetConstructor { - new (iterable: Iterable): WeakSet; + new (iterable: Iterable): WeakSet; } interface Promise { } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 5047af5a38c59..c00f37c260de3 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1125,15 +1125,15 @@ interface Array { * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. */ toLocaleString(): string; + /** + * Removes the last element from an array and returns it. + */ + pop(): T | undefined; /** * Appends new elements to an array, and returns the new length of the array. * @param items New elements of the Array. */ push(...items: T[]): number; - /** - * Removes the last element from an array and returns it. - */ - pop(): T | undefined; /** * Combines two or more arrays. * @param items Additional items to add to the end of array1. diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 9126fe3661d87..7dac9c42ec8e9 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -487,7 +487,7 @@ - + @@ -496,7 +496,7 @@ - + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index d0086211c523d..e9e3bb6cf834d 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -480,7 +480,7 @@ - + diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 0801c42405c20..be4f2290bccb9 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -346,6 +346,12 @@ namespace ts.server { * Container of all known scripts */ private readonly filenameToScriptInfo = createMap(); + /** + * Contains all the deleted script info's version information so that + * it does not reset when creating script info again + * (and could have potentially collided with version where contents mismatch) + */ + private readonly filenameToScriptInfoVersion = createMap(); // Set of all '.js' files ever opened. private readonly allJsFilesForOpenFileTelemetry = createMap(); @@ -471,7 +477,7 @@ namespace ts.server { this.hostConfiguration = { formatCodeOptions: getDefaultFormatCodeSettings(this.host), - preferences: defaultPreferences, + preferences: emptyOptions, hostInfo: "Unknown host", extraFileExtensions: [] }; @@ -693,12 +699,21 @@ namespace ts.server { } /* @internal */ - forEachProject(cb: (project: Project) => void) { + private forEachProject(cb: (project: Project) => void) { for (const p of this.inferredProjects) cb(p); this.configuredProjects.forEach(cb); this.externalProjects.forEach(cb); } + /* @internal */ + forEachEnabledProject(cb: (project: Project) => void) { + this.forEachProject(project => { + if (!project.isOrphan() && project.languageServiceEnabled) { + cb(project); + } + }); + } + getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined { return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName); } @@ -845,7 +860,7 @@ namespace ts.server { configFileExistenceInfo.exists = false; this.removeProject(project); - // Reload the configured projects for the open files in the map as they are affectected by this config file + // Reload the configured projects for the open files in the map as they are affected by this config file // Since the configured project was deleted, we want to reload projects for all the open files including files // that are not root of the inferred project this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, ConfigFileWatcherStatus.ReloadingFiles); @@ -1022,6 +1037,7 @@ namespace ts.server { private deleteScriptInfo(info: ScriptInfo) { this.filenameToScriptInfo.delete(info.path); + this.filenameToScriptInfoVersion.set(info.path, info.getVersion()); const realpath = info.getRealpathIfDifferent(); if (realpath) { this.realpathToScriptInfos!.remove(realpath, info); // TODO: GH#18217 @@ -1164,7 +1180,7 @@ namespace ts.server { */ private stopWatchingConfigFilesForClosedScriptInfo(info: ScriptInfo) { Debug.assert(!info.isScriptOpen()); - this.forEachConfigFileLocation(info, (configFileName, canonicalConfigFilePath) => { + this.forEachConfigFileLocation(info, /*infoShouldBeOpen*/ true, (configFileName, canonicalConfigFilePath) => { const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo) { const infoIsRootOfInferredProject = configFileExistenceInfo.openFilesImpactedByConfigFile.get(info.path); @@ -1198,7 +1214,7 @@ namespace ts.server { /* @internal */ startWatchingConfigFilesForInferredProjectRoot(info: ScriptInfo) { Debug.assert(info.isScriptOpen()); - this.forEachConfigFileLocation(info, (configFileName, canonicalConfigFilePath) => { + this.forEachConfigFileLocation(info, /*infoShouldBeOpen*/ true, (configFileName, canonicalConfigFilePath) => { let configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (!configFileExistenceInfo) { // Create the cache @@ -1226,7 +1242,7 @@ namespace ts.server { */ /* @internal */ stopWatchingConfigFilesForInferredProjectRoot(info: ScriptInfo) { - this.forEachConfigFileLocation(info, (configFileName, canonicalConfigFilePath) => { + this.forEachConfigFileLocation(info, /*infoShouldBeOpen*/ true, (configFileName, canonicalConfigFilePath) => { const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo && configFileExistenceInfo.openFilesImpactedByConfigFile.has(info.path)) { Debug.assert(info.isScriptOpen()); @@ -1249,18 +1265,18 @@ namespace ts.server { * The server must start searching from the directory containing * the newly opened file. */ - private forEachConfigFileLocation(info: ScriptInfo, action: (configFileName: NormalizedPath, canonicalConfigFilePath: string) => boolean | void) { + private forEachConfigFileLocation(info: ScriptInfo, infoShouldBeOpen: boolean, action: (configFileName: NormalizedPath, canonicalConfigFilePath: string) => boolean | void) { if (this.syntaxOnly) { return undefined; } - Debug.assert(this.openFiles.has(info.path)); + Debug.assert(!infoShouldBeOpen || this.openFiles.has(info.path)); const projectRootPath = this.openFiles.get(info.path); let searchPath = asNormalizedPath(getDirectoryPath(info.fileName)); const isSearchPathInProjectRoot = () => containsPath(projectRootPath!, searchPath, this.currentDirectory, !this.host.useCaseSensitiveFileNames); - // If projectRootPath doesnt contain info.path, then do normal search for config file + // If projectRootPath doesn't contain info.path, then do normal search for config file const anySearchPathOk = !projectRootPath || !isSearchPathInProjectRoot(); do { const canonicalSearchPath = normalizedPathToPath(searchPath, this.currentDirectory, this.toCanonicalFileName); @@ -1294,13 +1310,11 @@ namespace ts.server { * The server must start searching from the directory containing * the newly opened file. */ - private getConfigFileNameForFile(info: ScriptInfo) { - Debug.assert(info.isScriptOpen()); + private getConfigFileNameForFile(info: ScriptInfo, infoShouldBeOpen: boolean) { + if (infoShouldBeOpen) Debug.assert(info.isScriptOpen()); this.logger.info(`Search path: ${getDirectoryPath(info.fileName)}`); - const configFileName = this.forEachConfigFileLocation(info, - (configFileName, canonicalConfigFilePath) => - this.configFileExists(configFileName, canonicalConfigFilePath, info) - ); + const configFileName = this.forEachConfigFileLocation(info, infoShouldBeOpen, (configFileName, canonicalConfigFilePath) => + this.configFileExists(configFileName, canonicalConfigFilePath, info)); if (configFileName) { this.logger.info(`For info: ${info.fileName} :: Config file name: ${configFileName}`); } @@ -1769,6 +1783,15 @@ namespace ts.server { return this.getScriptInfoForNormalizedPath(toNormalizedPath(uncheckedFileName)); } + /* @internal */ + getScriptInfoOrConfig(uncheckedFileName: string): ScriptInfoOrConfig | undefined { + const path = toNormalizedPath(uncheckedFileName); + const info = this.getScriptInfoForNormalizedPath(path); + if (info) return info; + const configProject = this.configuredProjects.get(uncheckedFileName); + return configProject && configProject.getCompilerOptions().configFile; + } + /** * Returns the projects that contain script info through SymLink * Note that this does not return projects in info.containingProjects @@ -1833,13 +1856,11 @@ namespace ts.server { } } - /*@internal*/ - getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined, hostToQueryFileExistsOn: DirectoryStructureHost | undefined) { + private getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined, hostToQueryFileExistsOn: DirectoryStructureHost | undefined) { return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent, hostToQueryFileExistsOn); } - /*@internal*/ - getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, fileContent: string | undefined, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined) { + private getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, fileContent: string | undefined, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined) { return this.getOrCreateScriptInfoWorker(fileName, currentDirectory, /*openedByClient*/ true, fileContent, scriptKind, hasMixedContent); } @@ -1860,8 +1881,9 @@ namespace ts.server { if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; } - info = new ScriptInfo(this.host, fileName, scriptKind!, !!hasMixedContent, path); // TODO: GH#18217 + info = new ScriptInfo(this.host, fileName, scriptKind!, !!hasMixedContent, path, this.filenameToScriptInfoVersion.get(path)); // TODO: GH#18217 this.filenameToScriptInfo.set(info.path, info); + this.filenameToScriptInfoVersion.delete(info.path); if (!openedByClient) { this.watchClosedScriptInfo(info); } @@ -1981,7 +2003,7 @@ namespace ts.server { // we first detect if there is already a configured project created for it: if so, // we re- read the tsconfig file content and update the project only if we havent already done so // otherwise we create a new one. - const configFileName = this.getConfigFileNameForFile(info); + const configFileName = this.getConfigFileNameForFile(info, /*infoShouldBeOpen*/ true); if (configFileName) { const project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { @@ -2069,6 +2091,24 @@ namespace ts.server { return this.openClientFileWithNormalizedPath(toNormalizedPath(fileName), fileContent, scriptKind, /*hasMixedContent*/ false, projectRootPath ? toNormalizedPath(projectRootPath) : undefined); } + /** @internal */ + getProjectForFileWithoutOpening(fileName: NormalizedPath): { readonly scriptInfo: ScriptInfo, readonly projects: ReadonlyArray } | undefined { + const scriptInfo = this.filenameToScriptInfo.get(fileName) || + this.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName, this.currentDirectory, /*fileContent*/ undefined, /*scriptKind*/ undefined, /*hasMixedContent*/ undefined); + if (!scriptInfo) return undefined; + if (scriptInfo.containingProjects.length) { + return { scriptInfo, projects: scriptInfo.containingProjects }; + } + const configFileName = this.getConfigFileNameForFile(scriptInfo, /*infoShouldBeOpen*/ false); + const project = configFileName === undefined ? undefined : this.findConfiguredProjectByProjectName(configFileName) || this.createConfiguredProject(configFileName); + return project && project.containsScriptInfo(scriptInfo) ? { scriptInfo, projects: [project] } : undefined; + } + + /** @internal */ + fileExists(fileName: NormalizedPath): boolean { + return this.filenameToScriptInfo.has(fileName) || this.host.fileExists(fileName); + } + private findExternalProjectContainingOpenScriptInfo(info: ScriptInfo): ExternalProject | undefined { return find(this.externalProjects, proj => { // Ensure project structure is up-to-date to check if info is present in external project @@ -2082,10 +2122,11 @@ namespace ts.server { let configFileErrors: ReadonlyArray | undefined; const info = this.getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName, projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory, fileContent, scriptKind, hasMixedContent)!; // TODO: GH#18217 + this.openFiles.set(info.path, projectRootPath); let project: ConfiguredProject | ExternalProject | undefined = this.findExternalProjectContainingOpenScriptInfo(info); if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization - configFileName = this.getConfigFileNameForFile(info); + configFileName = this.getConfigFileNameForFile(info, /*infoShouldBeOpen*/ true); if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { @@ -2519,4 +2560,11 @@ namespace ts.server { return false; } } + + /* @internal */ + export type ScriptInfoOrConfig = ScriptInfo | TsConfigSourceFile; + /* @internal */ + export function isConfigFile(config: ScriptInfoOrConfig): config is TsConfigSourceFile { + return (config as TsConfigSourceFile).kind !== undefined; + } } diff --git a/src/server/project.ts b/src/server/project.ts index 343c4a2e97dfd..08b08eae04c8b 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -271,8 +271,8 @@ namespace ts.server { return this.projectStateVersion.toString(); } - getProjectReferences(): ReadonlyArray | undefined { - return undefined; + getProjectReferences(): ReadonlyArray { + return emptyArray; } getScriptFileNames() { @@ -461,6 +461,11 @@ namespace ts.server { return this.languageService; } + /** @internal */ + getSourceMapper(): SourceMapper { + return this.getLanguageService().getSourceMapper(); + } + private shouldEmitFile(scriptInfo: ScriptInfo) { return scriptInfo && !scriptInfo.isDynamicOrHasMixedContent(); } @@ -1351,8 +1356,8 @@ namespace ts.server { return asNormalizedPath(this.getProjectName()); } - getProjectReferences(): ReadonlyArray | undefined { - return this.projectReferences; + getProjectReferences(): ReadonlyArray { + return this.projectReferences || emptyArray; } updateReferences(refs: ReadonlyArray | undefined) { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 5e1599549563f..a04b7fe5da8b8 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -34,6 +34,8 @@ namespace ts.server.protocol { Implementation = "implementation", /* @internal */ ImplementationFull = "implementation-full", + /* @internal */ + EmitOutput = "emit-output", Exit = "exit", Format = "format", Formatonkey = "formatonkey", @@ -703,7 +705,7 @@ namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes?: ReadonlyArray; + errorCodes: ReadonlyArray; } export interface GetCombinedCodeFixRequestArgs { @@ -794,6 +796,21 @@ namespace ts.server.protocol { command: CommandTypes.Definition; } + export interface DefinitionAndBoundSpanRequest extends FileLocationRequest { + readonly command: CommandTypes.DefinitionAndBoundSpan; + } + + export interface DefinitionAndBoundSpanResponse extends Response { + readonly body: DefinitionInfoAndBoundSpan; + } + + /** @internal */ + export interface EmitOutputRequest extends FileRequest {} + /** @internal */ + export interface EmitOutputResponse extends Response { + readonly body: EmitOutput; + } + /** * Go to type request; value of command field is * "typeDefinition". Return response giving the file locations that @@ -1056,6 +1073,17 @@ namespace ts.server.protocol { arguments: RenameRequestArgs; } + /* @internal */ + export interface RenameFullRequest extends FileLocationRequest { + readonly command: CommandTypes.RenameLocationsFull; + readonly arguments: RenameRequestArgs; + } + + /* @internal */ + export interface RenameFullResponse extends Response { + readonly body: ReadonlyArray; + } + /** * Information about the item to be renamed. */ @@ -1246,7 +1274,7 @@ namespace ts.server.protocol { /* @internal */ export interface ProjectFiles { /** - * Information abount project verison + * Information about project verison */ info?: ProjectVersionInfo; /** @@ -1789,6 +1817,10 @@ namespace ts.server.protocol { * Optional prefix to apply to possible completions. */ prefix?: string; + /** + * Character that was responsible for triggering completion. + * Should be `undefined` if a user manually requested completion. + */ triggerCharacter?: CompletionsTriggerCharacter; /** * @deprecated Use UserPreferences.includeCompletionsForModuleExports @@ -2062,10 +2094,58 @@ namespace ts.server.protocol { argumentCount: number; } + export type SignatureHelpTriggerCharacter = "," | "(" | "<"; + export type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + + /** + * Arguments of a signature help request. + */ + export interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + /** + * Reason why signature help was invoked. + * See each individual possible + */ + triggerReason?: SignatureHelpTriggerReason; + } + + export type SignatureHelpTriggerReason = + | SignatureHelpInvokedReason + | SignatureHelpCharacterTypedReason + | SignatureHelpRetriggeredReason; + /** - * Arguments of a signature help request. + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. */ - export interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + export interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + export interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + export interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; } /** @@ -2254,11 +2334,16 @@ namespace ts.server.protocol { /** * Represents additional spans returned with a diagnostic which are relevant to it - * Like DiagnosticWithLinePosition, this is provided in two forms: - * - start and length of the span - * - startLocation and endLocation a pair of Location objects storing the start/end line offset of the span */ export interface DiagnosticRelatedInformation { + /** + * The category of the related information message, e.g. "error", "warning", or "suggestion". + */ + category: string; + /** + * The code used ot identify the related information + */ + code: number; /** * Text of related or additional information. */ @@ -2439,7 +2524,7 @@ namespace ts.server.protocol { /** * An item found in a navto response. */ - export interface NavtoItem { + export interface NavtoItem extends FileSpan { /** * The symbol's name. */ @@ -2453,33 +2538,18 @@ namespace ts.server.protocol { /** * exact, substring, or prefix. */ - matchKind?: string; + matchKind: string; /** * If this was a case sensitive or insensitive match. */ - isCaseSensitive?: boolean; + isCaseSensitive: boolean; /** * Optional modifiers for the kind (such as 'public'). */ kindModifiers?: string; - /** - * The file in which the symbol is found. - */ - file: string; - - /** - * The location within file at which the symbol is found. - */ - start: Location; - - /** - * One past the last character of the symbol. - */ - end: Location; - /** * Name of symbol's container symbol (if any); for example, * the class name if symbol is a class member. diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index e8f1d931ac2af..b5e892162ad80 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -1,13 +1,19 @@ namespace ts.server { + export interface ScriptInfoVersion { + svc: number; + text: number; + } /* @internal */ export class TextStorage { + /*@internal*/ + version: ScriptInfoVersion; + /** * Generated only on demand (based on edits, or information requested) * The property text is set to undefined when edits happen on the cache */ private svc: ScriptVersionCache | undefined; - private svcVersion = 0; /** * Stores the text when there are no changes to the script version cache @@ -19,7 +25,6 @@ namespace ts.server { * Line map for the text when there is no script version cache present */ private lineMap: number[] | undefined; - private textVersion = 0; /** * True if the text is for the file thats open in the editor @@ -34,13 +39,14 @@ namespace ts.server { */ private pendingReloadFromDisk: boolean; - constructor(private readonly host: ServerHost, private readonly fileName: NormalizedPath) { + constructor(private readonly host: ServerHost, private readonly fileName: NormalizedPath, initialVersion?: ScriptInfoVersion) { + this.version = initialVersion || { svc: 0, text: 0 }; } public getVersion() { return this.svc - ? `SVC-${this.svcVersion}-${this.svc.getSnapshotVersion()}` - : `Text-${this.textVersion}`; + ? `SVC-${this.version.svc}-${this.svc.getSnapshotVersion()}` + : `Text-${this.version.text}`; } public hasScriptVersionCache_TestOnly() { @@ -55,7 +61,7 @@ namespace ts.server { this.svc = undefined; this.text = newText; this.lineMap = undefined; - this.textVersion++; + this.version.text++; } public edit(start: number, end: number, newText: string) { @@ -163,7 +169,7 @@ namespace ts.server { private switchToScriptVersionCache(): ScriptVersionCache { if (!this.svc || this.pendingReloadFromDisk) { this.svc = ScriptVersionCache.fromString(this.getOrLoadText()); - this.svcVersion++; + this.version.svc++; } return this.svc; } @@ -235,10 +241,11 @@ namespace ts.server { readonly fileName: NormalizedPath, readonly scriptKind: ScriptKind, public readonly hasMixedContent: boolean, - readonly path: Path) { + readonly path: Path, + initialVersion?: ScriptInfoVersion) { this.isDynamic = isDynamicFileName(fileName); - this.textStorage = new TextStorage(host, fileName); + this.textStorage = new TextStorage(host, fileName, initialVersion); if (hasMixedContent || this.isDynamic) { this.textStorage.reload(""); this.realpath = this.path; @@ -248,6 +255,11 @@ namespace ts.server { : getScriptKindFromFileName(fileName); } + /*@internal*/ + getVersion() { + return this.textStorage.version; + } + /*@internal*/ public isDynamicOrHasMixedContent() { return this.hasMixedContent || this.isDynamic; @@ -419,7 +431,7 @@ namespace ts.server { if (preferences) { if (!this.preferences) { - this.preferences = defaultPreferences; + this.preferences = emptyOptions; } this.preferences = { ...this.preferences, ...preferences }; } diff --git a/src/server/session.ts b/src/server/session.ts index 2ad7c602d8647..aae9ab8980f55 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -42,31 +42,6 @@ namespace ts.server { return false; } - interface FileStart { - file: string; - start: protocol.Location; - } - - function compareNumber(a: number, b: number) { - return a - b; - } - - function compareFileStart(a: FileStart, b: FileStart) { - if (a.file < b.file) { - return -1; - } - else if (a.file === b.file) { - const n = compareNumber(a.start.line, b.start.line); - if (n === 0) { - return compareNumber(a.start.offset, b.start.offset); - } - else return n; - } - else { - return 1; - } - } - function formatDiag(fileName: NormalizedPath, project: Project, diag: Diagnostic): protocol.Diagnostic { const scriptInfo = project.getScriptInfoForNormalizedPath(fileName)!; // TODO: GH#18217 return { @@ -84,7 +59,9 @@ namespace ts.server { function formatRelatedInformation(info: DiagnosticRelatedInformation): protocol.DiagnosticRelatedInformation { if (!info.file) { return { - message: flattenDiagnosticMessageText(info.messageText, "\n") + message: flattenDiagnosticMessageText(info.messageText, "\n"), + category: diagnosticCategoryName(info), + code: info.code }; } return { @@ -93,7 +70,9 @@ namespace ts.server { end: convertToLocation(getLineAndCharacterOfPosition(info.file, info.start! + info.length!)), // TODO: GH#18217 file: info.file.fileName }, - message: flattenDiagnosticMessageText(info.messageText, "\n") + message: flattenDiagnosticMessageText(info.messageText, "\n"), + category: diagnosticCategoryName(info), + code: info.code }; } @@ -275,8 +254,8 @@ namespace ts.server { } type Projects = ReadonlyArray | { - projects: ReadonlyArray; - symLinkedProjects: MultiMap; + readonly projects: ReadonlyArray; + readonly symLinkedProjects: MultiMap; }; function isProjectsArray(projects: Projects): projects is ReadonlyArray { @@ -286,7 +265,14 @@ namespace ts.server { /** * This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project. */ - function combineProjectOutput(defaultValue: T, getValue: (path: Path) => T, projects: Projects, action: (project: Project, value: T) => ReadonlyArray | U | undefined, comparer?: (a: U, b: U) => number, areEqual?: (a: U, b: U) => boolean) { + function combineProjectOutput( + defaultValue: T, + getValue: (path: Path) => T, + projects: Projects, + action: (project: Project, value: T) => ReadonlyArray | U | undefined, + comparer?: (a: U, b: U) => number, + areEqual?: (a: U, b: U) => boolean, + ): U[] { const outputs = flatMap(isProjectsArray(projects) ? projects : projects.projects, project => action(project, defaultValue)); if (!isProjectsArray(projects) && projects.symLinkedProjects) { projects.symLinkedProjects.forEach((projects, path) => { @@ -300,6 +286,187 @@ namespace ts.server { : deduplicate(outputs, areEqual); } + function combineProjectOutputFromEveryProject(projectService: ProjectService, action: (project: Project) => ReadonlyArray, areEqual: (a: T, b: T) => boolean) { + const outputs: T[] = []; + projectService.forEachEnabledProject(project => { + const theseOutputs = action(project); + outputs.push(...theseOutputs.filter(output => !outputs.some(o => areEqual(o, output)))); + }); + return outputs; + } + + function combineProjectOutputWhileOpeningReferencedProjects( + projects: Projects, + defaultProject: Project, + projectService: ProjectService, + action: (project: Project) => ReadonlyArray, + getLocation: (t: T) => sourcemaps.SourceMappableLocation, + resultsEqual: (a: T, b: T) => boolean, + ): T[] { + const outputs: T[] = []; + combineProjectOutputWorker( + projects, + defaultProject, + /*initialLocation*/ undefined, + projectService, + ({ project }, tryAddToTodo) => { + for (const output of action(project)) { + if (!contains(outputs, output, resultsEqual) && !tryAddToTodo(project, getLocation(output))) { + outputs.push(output); + } + } + }, + /*getDefinition*/ undefined); + return outputs; + } + + function combineProjectOutputForRenameLocations( + projects: Projects, defaultProject: Project, initialLocation: sourcemaps.SourceMappableLocation, projectService: ProjectService, findInStrings: boolean, findInComments: boolean + ): ReadonlyArray { + const outputs: RenameLocation[] = []; + + combineProjectOutputWorker(projects, defaultProject, initialLocation, projectService, ({ project, location }, tryAddToTodo) => { + for (const output of project.getLanguageService().findRenameLocations(location.fileName, location.position, findInStrings, findInComments) || emptyArray) { + if (!contains(outputs, output, documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) { + outputs.push(output); + } + } + }, () => getDefinitionLocation(defaultProject, initialLocation)); + + return outputs; + } + + function getDefinitionLocation(defaultProject: Project, initialLocation: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined { + const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.position); + const info = infos && firstOrUndefined(infos); + return info && { fileName: info.fileName, position: info.textSpan.start }; + } + + function combineProjectOutputForReferences(projects: Projects, defaultProject: Project, initialLocation: sourcemaps.SourceMappableLocation, projectService: ProjectService): ReadonlyArray { + const outputs: ReferencedSymbol[] = []; + + combineProjectOutputWorker(projects, defaultProject, initialLocation, projectService, ({ project, location }, tryAddToTodo) => { + for (const outputReferencedSymbol of project.getLanguageService().findReferences(location.fileName, location.position) || emptyArray) { + let symbolToAddTo = find(outputs, o => documentSpansEqual(o.definition, outputReferencedSymbol.definition)); + if (!symbolToAddTo) { + symbolToAddTo = { definition: outputReferencedSymbol.definition, references: [] }; + outputs.push(symbolToAddTo); + } + + for (const ref of outputReferencedSymbol.references) { + if (!contains(symbolToAddTo.references, ref, documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(ref))) { + symbolToAddTo.references.push(ref); + } + } + } + }, () => getDefinitionLocation(defaultProject, initialLocation)); + + return outputs.filter(o => o.references.length !== 0); + } + + interface ProjectAndLocation { + readonly project: Project; + readonly location: TLocation; + } + + function forEachProjectInProjects(projects: Projects, path: string | undefined, cb: (project: Project, path: string | undefined) => void): void { + for (const project of isProjectsArray(projects) ? projects : projects.projects) { + cb(project, path); + } + if (!isArray(projects) && projects.symLinkedProjects) { + projects.symLinkedProjects.forEach((symlinkedProjects, symlinkedPath) => { + for (const project of symlinkedProjects) { + cb(project, symlinkedPath); + } + }); + } + } + + function combineProjectOutputWorker( + projects: Projects, + defaultProject: Project, + initialLocation: TLocation, + projectService: ProjectService, + cb: (where: ProjectAndLocation, getMappedLocation: (project: Project, location: sourcemaps.SourceMappableLocation) => boolean) => void, + getDefinition: (() => sourcemaps.SourceMappableLocation | undefined) | undefined, + ): void { + let toDo: ProjectAndLocation[] | undefined; + const seenProjects = createMap(); + forEachProjectInProjects(projects, initialLocation && initialLocation.fileName, (project, path) => { + // TLocation shoud be either `sourcemaps.SourceMappableLocation` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid. + const location = (initialLocation ? { fileName: path, position: initialLocation.position } : undefined) as TLocation; + toDo = callbackProjectAndLocation({ project, location }, projectService, toDo, seenProjects, cb); + }); + + // After initial references are collected, go over every other project and see if it has a reference for the symbol definition. + if (getDefinition) { + const memGetDefinition = memoize(getDefinition); + projectService.forEachEnabledProject(project => { + if (!addToSeen(seenProjects, project.projectName)) return; + const definition = getDefinitionInProject(memGetDefinition(), defaultProject, project); + if (definition) { + toDo = callbackProjectAndLocation({ project, location: definition as TLocation }, projectService, toDo, seenProjects, cb); + } + }); + } + + while (toDo && toDo.length) { + toDo = callbackProjectAndLocation(Debug.assertDefined(toDo.pop()), projectService, toDo, seenProjects, cb); + } + } + + function getDefinitionInProject(definition: sourcemaps.SourceMappableLocation | undefined, definingProject: Project, project: Project): sourcemaps.SourceMappableLocation | undefined { + if (!definition || project.containsFile(toNormalizedPath(definition.fileName))) return definition; + const mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedLocation(definition); + return mappedDefinition && project.containsFile(toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined; + } + + function callbackProjectAndLocation( + projectAndLocation: ProjectAndLocation, + projectService: ProjectService, + toDo: ProjectAndLocation[] | undefined, + seenProjects: Map, + cb: (where: ProjectAndLocation, getMappedLocation: (project: Project, location: sourcemaps.SourceMappableLocation) => boolean) => void, + ): ProjectAndLocation[] | undefined { + if (projectAndLocation.project.getCancellationToken().isCancellationRequested()) return undefined; // Skip rest of toDo if cancelled + cb(projectAndLocation, (project, location) => { + seenProjects.set(projectAndLocation.project.projectName, true); + const originalLocation = project.getSourceMapper().tryGetOriginalLocation(location); + if (!originalLocation) return false; + const originalProjectAndScriptInfo = projectService.getProjectForFileWithoutOpening(toNormalizedPath(originalLocation.fileName)); + if (!originalProjectAndScriptInfo) return false; + + if (originalProjectAndScriptInfo) { + toDo = toDo || []; + + for (const project of originalProjectAndScriptInfo.projects) { + addToTodo({ project, location: originalLocation as TLocation }, toDo, seenProjects); + } + const symlinkedProjectsMap = projectService.getSymlinkedProjects(originalProjectAndScriptInfo.scriptInfo); + if (symlinkedProjectsMap) { + symlinkedProjectsMap.forEach((symlinkedProjects) => { + for (const symlinkedProject of symlinkedProjects) addToTodo({ project: symlinkedProject, location: originalLocation as TLocation }, toDo!, seenProjects); + }); + } + } + return true; + }); + return toDo; + } + + function addToTodo(projectAndLocation: ProjectAndLocation, toDo: Push>, seenProjects: Map): void { + if (addToSeen(seenProjects, projectAndLocation.project.projectName)) toDo.push(projectAndLocation); + } + + function documentSpanLocation({ fileName, textSpan }: DocumentSpan): sourcemaps.SourceMappableLocation { + return { fileName, position: textSpan.start }; + } + + function getMappedLocation(location: sourcemaps.SourceMappableLocation, projectService: ProjectService, project: Project): sourcemaps.SourceMappableLocation | undefined { + const mapsTo = project.getSourceMapper().tryGetOriginalLocation(location); + return mapsTo && projectService.fileExists(toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined; + } + export interface SessionOptions { host: ServerHost; cancellationToken: ServerCancellationToken; @@ -686,46 +853,64 @@ namespace ts.server { private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - - const definitions = project.getLanguageService().getDefinitionAtPosition(file, position); - if (!definitions) { - return emptyArray; - } - - if (simplifiedResult) { - return this.mapDefinitionInfo(definitions, project); - } - - return definitions.map(Session.mapToOriginalLocation); + const definitions = this.mapDefinitionInfoLocations(project.getLanguageService().getDefinitionAtPosition(file, position) || emptyArray, project); + return simplifiedResult ? this.mapDefinitionInfo(definitions, project) : definitions.map(Session.mapToOriginalLocation); + } + + private mapDefinitionInfoLocations(definitions: ReadonlyArray, project: Project): ReadonlyArray { + return definitions.map((info): DefinitionInfo => { + const newLoc = getMappedLocation(documentSpanLocation(info), this.projectService, project); + return !newLoc ? info : { + containerKind: info.containerKind, + containerName: info.containerName, + fileName: newLoc.fileName, + kind: info.kind, + name: info.name, + textSpan: { + start: newLoc.position, + length: info.textSpan.length + }, + originalFileName: info.fileName, + originalTextSpan: info.textSpan, + }; + }); } private getDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - const scriptInfo = project.getScriptInfo(file)!; + const scriptInfo = Debug.assertDefined(project.getScriptInfo(file)); - const definitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position); + const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position); - if (!definitionAndBoundSpan || !definitionAndBoundSpan.definitions) { + if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) { return { definitions: emptyArray, textSpan: undefined! // TODO: GH#18217 }; } + const definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project); + const { textSpan } = unmappedDefinitionAndBoundSpan; + if (simplifiedResult) { return { - definitions: this.mapDefinitionInfo(definitionAndBoundSpan.definitions, project), - textSpan: this.toLocationTextSpan(definitionAndBoundSpan.textSpan, scriptInfo) + definitions: this.mapDefinitionInfo(definitions, project), + textSpan: this.toLocationTextSpan(textSpan, scriptInfo) }; } return { - ...definitionAndBoundSpan, - definitions: definitionAndBoundSpan.definitions.map(Session.mapToOriginalLocation) + definitions: definitions.map(Session.mapToOriginalLocation), + textSpan, }; } + private getEmitOutput(args: protocol.FileRequestArgs): EmitOutput { + const { file, project } = this.getFileAndProject(args); + return project.getLanguageService().getEmitOutput(file); + } + private mapDefinitionInfo(definitions: ReadonlyArray, project: Project): ReadonlyArray { return definitions.map(def => this.toFileSpan(def.fileName, def.textSpan, project)); } @@ -767,21 +952,31 @@ namespace ts.server { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - const definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); - if (!definitions) { - return emptyArray; - } - + const definitions = this.mapDefinitionInfoLocations(project.getLanguageService().getTypeDefinitionAtPosition(file, position) || emptyArray, project); return this.mapDefinitionInfo(definitions, project); } + private mapImplementationLocations(implementations: ReadonlyArray, project: Project): ReadonlyArray { + return implementations.map((info): ImplementationLocation => { + const newLoc = getMappedLocation(documentSpanLocation(info), this.projectService, project); + return !newLoc ? info : { + fileName: newLoc.fileName, + kind: info.kind, + displayParts: info.displayParts, + textSpan: { + start: newLoc.position, + length: info.textSpan.length + }, + originalFileName: info.fileName, + originalTextSpan: info.textSpan, + }; + }); + } + private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); - const implementations = project.getLanguageService().getImplementationAtPosition(file, position); - if (!implementations) { - return emptyArray; - } + const implementations = this.mapImplementationLocations(project.getLanguageService().getImplementationAtPosition(file, position) || emptyArray, project); if (simplifiedResult) { return implementations.map(({ fileName, textSpan }) => this.toFileSpan(fileName, textSpan, project)); } @@ -944,179 +1139,61 @@ namespace ts.server { return info.getDefaultProject(); } - private getRenameLocations(args: protocol.RenameRequestArgs, simplifiedResult: boolean): protocol.RenameResponseBody | ReadonlyArray | undefined { + private getRenameLocations(args: protocol.RenameRequestArgs, simplifiedResult: boolean): protocol.RenameResponseBody | ReadonlyArray { const file = toNormalizedPath(args.file); const position = this.getPositionInFile(args, file); const projects = this.getProjects(args); - if (simplifiedResult) { - - const defaultProject = this.getDefaultProject(args); - // The rename info should be the same for every project - const renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: emptyArray - }; - } - const fileSpans = combineProjectOutput( - file, - path => this.projectService.getScriptInfoForPath(path)!.fileName, - projects, - (project, file) => { - const renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings!, args.findInComments!); - if (!renameLocations) { - return emptyArray; - } - - return renameLocations.map(location => { - const locationScriptInfo = project.getScriptInfo(location.fileName)!; - return { - file: location.fileName, - start: locationScriptInfo.positionToLineOffset(location.textSpan.start), - end: locationScriptInfo.positionToLineOffset(textSpanEnd(location.textSpan)), - }; - }); - }, - compareRenameLocation, - (a, b) => a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset - ); - - const locs: protocol.SpanGroup[] = []; - for (const cur of fileSpans) { - let curFileAccum: protocol.SpanGroup | undefined; - if (locs.length > 0) { - curFileAccum = locs[locs.length - 1]; - if (curFileAccum.file !== cur.file) { - curFileAccum = undefined; - } - } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - locs.push(curFileAccum); - } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - } + const locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, position }, this.projectService, !!args.findInStrings, !!args.findInComments); + if (!simplifiedResult) return locations; - return { info: renameInfo, locs }; - } - else { - return combineProjectOutput( - file, - path => this.projectService.getScriptInfoForPath(path)!.fileName, - projects, - (p, file) => p.getLanguageService().findRenameLocations(file, position, args.findInStrings!, args.findInComments!), - /*comparer*/ undefined, - renameLocationIsEqualTo - ); - } + const defaultProject = this.getDefaultProject(args); + const renameInfo = Session.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position)); + return { info: renameInfo, locs: this.toSpanGroups(locations) }; + } - function renameLocationIsEqualTo(a: RenameLocation, b: RenameLocation) { - if (a === b) { - return true; - } - if (!a || !b) { - return false; - } - return a.fileName === b.fileName && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; - } + // strips 'triggerSpan' + private static mapRenameInfo({ canRename, localizedErrorMessage, displayName, fullDisplayName, kind, kindModifiers }: RenameInfo): protocol.RenameInfo { + return { canRename, localizedErrorMessage, displayName, fullDisplayName, kind, kindModifiers }; + } - function compareRenameLocation(a: protocol.FileSpan, b: protocol.FileSpan) { - if (a.file < b.file) { - return -1; - } - else if (a.file > b.file) { - return 1; - } - else { - // reverse sort assuming no overlap - if (a.start.line < b.start.line) { - return 1; - } - else if (a.start.line > b.start.line) { - return -1; - } - else { - return b.start.offset - a.start.offset; - } - } + private toSpanGroups(locations: ReadonlyArray): ReadonlyArray { + const map = createMap(); + for (const { fileName, textSpan } of locations) { + let group = map.get(fileName); + if (!group) map.set(fileName, group = { file: fileName, locs: [] }); + group.locs.push(this.toLocationTextSpan(textSpan, Debug.assertDefined(this.projectService.getScriptInfo(fileName)))); } + return arrayFrom(map.values()); } private getReferences(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.ReferencesResponseBody | undefined | ReadonlyArray { const file = toNormalizedPath(args.file); const projects = this.getProjects(args); + const position = this.getPositionInFile(args, file); + const references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, position }, this.projectService); - const defaultProject = this.getDefaultProject(args); - const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!; - const position = this.getPosition(args, scriptInfo); if (simplifiedResult) { + const defaultProject = this.getDefaultProject(args); + const scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file)!; const nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - const displayString = nameInfo ? displayPartsToString(nameInfo.displayParts) : ""; + const symbolDisplayString = nameInfo ? displayPartsToString(nameInfo.displayParts) : ""; const nameSpan = nameInfo && nameInfo.textSpan; - const nameColStart = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0; - const nameText = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : ""; - const refs = combineProjectOutput( - file, - path => this.projectService.getScriptInfoForPath(path)!.fileName, - projects, - (project, file) => { - const references = project.getLanguageService().getReferencesAtPosition(file, position); - if (!references) { - return emptyArray; - } - - return references.map(ref => { - const refScriptInfo = project.getScriptInfo(ref.fileName)!; - const start = refScriptInfo.positionToLineOffset(ref.textSpan.start); - const refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); - const lineText = refScriptInfo.getSnapshot().getText(refLineSpan.start, textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start, - lineText, - end: refScriptInfo.positionToLineOffset(textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess, - isDefinition: ref.isDefinition - }; - }); - }, - compareFileStart, - areReferencesResponseItemsForTheSameLocation - ); - - return { - refs, - symbolName: nameText, - symbolStartOffset: nameColStart, - symbolDisplayString: displayString - }; + const symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0; + const symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : ""; + const refs: protocol.ReferencesResponseItem[] = flatMap(references, referencedSymbol => + referencedSymbol.references.map(({ fileName, textSpan, isWriteAccess, isDefinition }): protocol.ReferencesResponseItem => { + const scriptInfo = Debug.assertDefined(this.projectService.getScriptInfo(fileName)); + const start = scriptInfo.positionToLineOffset(textSpan.start); + const lineSpan = scriptInfo.lineToTextSpan(start.line - 1); + const lineText = scriptInfo.getSnapshot().getText(lineSpan.start, textSpanEnd(lineSpan)).replace(/\r|\n/g, ""); + return { ...toFileSpan(fileName, textSpan, scriptInfo), lineText, isWriteAccess, isDefinition }; + })); + const result: protocol.ReferencesResponseBody = { refs, symbolName, symbolStartOffset, symbolDisplayString }; + return result; } else { - return combineProjectOutput( - file, - path => this.projectService.getScriptInfoForPath(path)!.fileName, - projects, - (project, file) => project.getLanguageService().findReferences(file, position), - /*comparer*/ undefined, - equateValues - ); - } - - function areReferencesResponseItemsForTheSameLocation(a: protocol.ReferencesResponseItem, b: protocol.ReferencesResponseItem) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; - } - return false; + return references; } } @@ -1383,7 +1460,7 @@ namespace ts.server { return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, this.getPreferences(file)); }); return simplifiedResult - ? result.map(details => ({ ...details, codeActions: map(details.codeActions, action => this.mapCodeAction(project, action)) })) + ? result.map(details => ({ ...details, codeActions: map(details.codeActions, action => this.mapCodeAction(action)) })) : result; } @@ -1430,7 +1507,7 @@ namespace ts.server { const { file, project } = this.getFileAndProject(args); const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!; const position = this.getPosition(args, scriptInfo); - const helpItems = project.getLanguageService().getSignatureHelpItems(file, position); + const helpItems = project.getLanguageService().getSignatureHelpItems(file, position, args); if (!helpItems) { return undefined; } @@ -1564,64 +1641,46 @@ namespace ts.server { } private getNavigateToItems(args: protocol.NavtoRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { - const projects = this.getProjects(args); - - const fileName = args.currentFileOnly ? args.file && normalizeSlashes(args.file) : undefined; - if (simplifiedResult) { - return combineProjectOutput( - fileName, - () => undefined, - projects, - (project, file) => { - if (fileName && !file) { - return undefined; - } - - const navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, /*excludeDts*/ project.isNonTsProject()); - if (!navItems) { - return emptyArray; - } + const full = this.getFullNavigateToItems(args); + return !simplifiedResult ? full : full.map((navItem) => { + const { file, project } = this.getFileAndProject({ file: navItem.fileName }); + const scriptInfo = project.getScriptInfo(file)!; + const bakedItem: protocol.NavtoItem = { + name: navItem.name, + kind: navItem.kind, + isCaseSensitive: navItem.isCaseSensitive, + matchKind: navItem.matchKind, + file: navItem.fileName, + start: scriptInfo.positionToLineOffset(navItem.textSpan.start), + end: scriptInfo.positionToLineOffset(textSpanEnd(navItem.textSpan)) + }; + if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { + bakedItem.kindModifiers = navItem.kindModifiers; + } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + } - return navItems.map((navItem) => { - const scriptInfo = project.getScriptInfo(navItem.fileName)!; - const bakedItem: protocol.NavtoItem = { - name: navItem.name, - kind: navItem.kind, - file: navItem.fileName, - start: scriptInfo.positionToLineOffset(navItem.textSpan.start), - end: scriptInfo.positionToLineOffset(textSpanEnd(navItem.textSpan)) - }; - if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.matchKind !== "none") { - bakedItem.matchKind = navItem.matchKind; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }, - /*comparer*/ undefined, - areNavToItemsForTheSameLocation - ); + private getFullNavigateToItems(args: protocol.NavtoRequestArgs): ReadonlyArray { + const { currentFileOnly, searchValue, maxResultCount } = args; + if (currentFileOnly) { + const { file, project } = this.getFileAndProject(args); + return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file); } else { - return combineProjectOutput( - fileName, - () => undefined, - projects, - (project, file) => { - if (fileName && !file) { - return undefined; - } - return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, /*excludeDts*/ project.isNonTsProject()); - }, - /*comparer*/ undefined, + return combineProjectOutputWhileOpeningReferencedProjects( + this.getProjects(args), + this.getDefaultProject(args), + this.projectService, + project => + project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()), + documentSpanLocation, navigateToItemIsEqualTo); } @@ -1643,15 +1702,6 @@ namespace ts.server { a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; } - - function areNavToItemsForTheSameLocation(a: protocol.NavtoItem, b: protocol.NavtoItem) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; - } - return false; - } } private getSupportedCodeFixes(): string[] { @@ -1713,7 +1763,7 @@ namespace ts.server { const renameScriptInfo = project.getScriptInfoForNormalizedPath(toNormalizedPath(renameFilename))!; mappedRenameLocation = getLocationInNewDocument(getSnapshotText(renameScriptInfo.getSnapshot()), renameFilename, renameLocation, edits); } - return { renameLocation: mappedRenameLocation, renameFilename, edits: this.mapTextChangesToCodeEdits(project, edits) }; + return { renameLocation: mappedRenameLocation, renameFilename, edits: this.mapTextChangesToCodeEdits(edits) }; } else { return result; @@ -1725,7 +1775,7 @@ namespace ts.server { const { file, project } = this.getFileAndProject(scope.args); const changes = project.getLanguageService().organizeImports({ type: "file", fileName: file }, this.getFormatOptions(file), this.getPreferences(file)); if (simplifiedResult) { - return this.mapTextChangesToCodeEdits(project, changes); + return this.mapTextChangesToCodeEdits(changes); } else { return changes; @@ -1737,32 +1787,21 @@ namespace ts.server { const newPath = toNormalizedPath(args.newFilePath); const formatOptions = this.getHostFormatOptions(); const preferences = this.getHostPreferences(); - - const changes: (protocol.FileCodeEdits | FileTextChanges)[] = []; - this.projectService.forEachProject(project => { - if (project.isOrphan() || !project.languageServiceEnabled) return; - for (const fileTextChanges of project.getLanguageService().getEditsForFileRename(oldPath, newPath, formatOptions, preferences)) { - // Subsequent projects may make conflicting edits to the same file -- just go with the first. - if (!changes.some(f => f.fileName === fileTextChanges.fileName)) { - changes.push(simplifiedResult ? this.mapTextChangeToCodeEdit(project, fileTextChanges) : fileTextChanges); - } - } - }); - - return changes as ReadonlyArray | ReadonlyArray; + const changes = combineProjectOutputFromEveryProject( + this.projectService, + project => project.getLanguageService().getEditsForFileRename(oldPath, newPath, formatOptions, preferences), + (a, b) => a.fileName === b.fileName); + return simplifiedResult ? changes.map(c => this.mapTextChangeToCodeEdit(c)) : changes; } private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray | undefined { - if (args.errorCodes!.length === 0) { // TODO: GH#18217 - return undefined; - } const { file, project } = this.getFileAndProject(args); const scriptInfo = project.getScriptInfoForNormalizedPath(file)!; const { startPosition, endPosition } = this.getStartAndEndPosition(args, scriptInfo); - const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes!, this.getFormatOptions(file), this.getPreferences(file)); - return simplifiedResult ? codeActions.map(codeAction => this.mapCodeFixAction(project, codeAction)) : codeActions; + const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file)); + return simplifiedResult ? codeActions.map(codeAction => this.mapCodeFixAction(codeAction)) : codeActions; } private getCombinedCodeFix({ scope, fixId }: protocol.GetCombinedCodeFixRequestArgs, simplifiedResult: boolean): protocol.CombinedCodeActions | CombinedCodeActions { @@ -1770,7 +1809,7 @@ namespace ts.server { const { file, project } = this.getFileAndProject(scope.args); const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId, this.getFormatOptions(file), this.getPreferences(file)); if (simplifiedResult) { - return { changes: this.mapTextChangesToCodeEdits(project, res.changes), commands: res.commands }; + return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands }; } else { return res; @@ -1810,21 +1849,20 @@ namespace ts.server { return { startPosition, endPosition }; } - private mapCodeAction(project: Project, { description, changes, commands }: CodeAction): protocol.CodeAction { - return { description, changes: this.mapTextChangesToCodeEdits(project, changes), commands }; + private mapCodeAction({ description, changes, commands }: CodeAction): protocol.CodeAction { + return { description, changes: this.mapTextChangesToCodeEdits(changes), commands }; } - private mapCodeFixAction(project: Project, { fixName, description, changes, commands, fixId, fixAllDescription }: CodeFixAction): protocol.CodeFixAction { - return { fixName, description, changes: this.mapTextChangesToCodeEdits(project, changes), commands, fixId, fixAllDescription }; + private mapCodeFixAction({ fixName, description, changes, commands, fixId, fixAllDescription }: CodeFixAction): protocol.CodeFixAction { + return { fixName, description, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId, fixAllDescription }; } - private mapTextChangesToCodeEdits(project: Project, textChanges: ReadonlyArray): protocol.FileCodeEdits[] { - return textChanges.map(change => this.mapTextChangeToCodeEdit(project, change)); + private mapTextChangesToCodeEdits(textChanges: ReadonlyArray): protocol.FileCodeEdits[] { + return textChanges.map(change => this.mapTextChangeToCodeEdit(change)); } - private mapTextChangeToCodeEdit(project: Project, change: FileTextChanges): protocol.FileCodeEdits { - const path = normalizedPathToPath(toNormalizedPath(change.fileName), this.host.getCurrentDirectory(), fileName => this.getCanonicalFileName(fileName)); - return mapTextChangesToCodeEdits(change, project.getSourceFileOrConfigFile(path)); + private mapTextChangeToCodeEdit(change: FileTextChanges): protocol.FileCodeEdits { + return mapTextChangesToCodeEdits(change, this.projectService.getScriptInfoOrConfig(change.fileName)); } private convertTextChangeToCodeEdit(change: TextChange, scriptInfo: ScriptInfo): protocol.CodeEdit { @@ -1973,6 +2011,9 @@ namespace ts.server { [CommandNames.DefinitionAndBoundSpanFull]: (request: protocol.DefinitionRequest) => { return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false)); }, + [CommandNames.EmitOutput]: (request: protocol.EmitOutputRequest) => { + return this.requiredResponse(this.getEmitOutput(request.arguments)); + }, [CommandNames.TypeDefinition]: (request: protocol.FileLocationRequest) => { return this.requiredResponse(this.getTypeDefinition(request.arguments)); }, @@ -1988,10 +2029,10 @@ namespace ts.server { [CommandNames.ReferencesFull]: (request: protocol.FileLocationRequest) => { return this.requiredResponse(this.getReferences(request.arguments, /*simplifiedResult*/ false)); }, - [CommandNames.Rename]: (request: protocol.Request) => { + [CommandNames.Rename]: (request: protocol.RenameRequest) => { return this.requiredResponse(this.getRenameLocations(request.arguments, /*simplifiedResult*/ true)); }, - [CommandNames.RenameLocationsFull]: (request: protocol.RenameRequest) => { + [CommandNames.RenameLocationsFull]: (request: protocol.RenameFullRequest) => { return this.requiredResponse(this.getRenameLocations(request.arguments, /*simplifiedResult*/ false)); }, [CommandNames.RenameInfoFull]: (request: protocol.FileLocationRequest) => { @@ -2329,25 +2370,27 @@ namespace ts.server { readonly project: Project; } - function mapTextChangesToCodeEdits(textChanges: FileTextChanges, sourceFile: SourceFile | undefined): protocol.FileCodeEdits { - Debug.assert(!!textChanges.isNewFile === !sourceFile); - if (sourceFile) { - return { - fileName: textChanges.fileName, - textChanges: textChanges.textChanges.map(textChange => convertTextChangeToCodeEdit(textChange, sourceFile)), - }; - } - else { - return convertNewFileTextChangeToCodeEdit(textChanges); - } + function toFileSpan(fileName: string, textSpan: TextSpan, scriptInfo: ScriptInfo): protocol.FileSpan { + return { file: fileName, start: scriptInfo.positionToLineOffset(textSpan.start), end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)) }; } - function convertTextChangeToCodeEdit(change: TextChange, sourceFile: SourceFile): protocol.CodeEdit { - return { - start: convertToLocation(sourceFile.getLineAndCharacterOfPosition(change.span.start)), - end: convertToLocation(sourceFile.getLineAndCharacterOfPosition(change.span.start + change.span.length)), - newText: change.newText ? change.newText : "", - }; + function mapTextChangesToCodeEdits(textChanges: FileTextChanges, scriptInfo: ScriptInfoOrConfig | undefined): protocol.FileCodeEdits { + Debug.assert(!!textChanges.isNewFile === !scriptInfo, "Expected isNewFile for (only) new files", () => JSON.stringify({ isNewFile: !!textChanges.isNewFile, hasScriptInfo: !!scriptInfo })); + return scriptInfo + ? { fileName: textChanges.fileName, textChanges: textChanges.textChanges.map(textChange => convertTextChangeToCodeEdit(textChange, scriptInfo)) } + : convertNewFileTextChangeToCodeEdit(textChanges); + } + + function convertTextChangeToCodeEdit(change: TextChange, scriptInfo: ScriptInfoOrConfig): protocol.CodeEdit { + return { start: positionToLineOffset(scriptInfo, change.span.start), end: positionToLineOffset(scriptInfo, textSpanEnd(change.span)), newText: change.newText }; + } + + function positionToLineOffset(info: ScriptInfoOrConfig, position: number): protocol.Location { + return isConfigFile(info) ? locationFromLineAndCharacter(info.getLineAndCharacterOfPosition(position)) : info.positionToLineOffset(position); + } + + function locationFromLineAndCharacter(lc: LineAndCharacter): protocol.Location { + return { line: lc.line + 1, offset: lc.character + 1 }; } function convertNewFileTextChangeToCodeEdit(textChanges: FileTextChanges): protocol.FileCodeEdits { diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index 076bf553677ab..ad4e37974b3bc 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -1,9 +1,9 @@ /* @internal */ namespace ts { export interface CodeFixRegistration { - errorCodes: number[]; + errorCodes: ReadonlyArray; getCodeActions(context: CodeFixContext): CodeFixAction[] | undefined; - fixIds?: string[]; + fixIds?: ReadonlyArray; getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions; } @@ -27,7 +27,7 @@ namespace ts { const errorCodeToFixes = createMultiMap(); const fixIdToRegistration = createMap(); - type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string]; + export type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string]; function diagnosticToString(diag: DiagnosticAndArguments): string { return isArray(diag) ? formatStringFromArgs(getLocaleSpecificMessage(diag[0]), diag.slice(1) as ReadonlyArray) @@ -71,7 +71,7 @@ namespace ts { return fixIdToRegistration.get(cast(context.fixId, isString))!.getAllCodeActions!(context); } - function createCombinedCodeActions(changes: FileTextChanges[], commands?: CodeActionCommand[]): CombinedCodeActions { + export function createCombinedCodeActions(changes: FileTextChanges[], commands?: CodeActionCommand[]): CombinedCodeActions { return { changes, commands }; } @@ -89,7 +89,7 @@ namespace ts { return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } - function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: number[], cb: (diag: DiagnosticWithLocation) => void): void { + export function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: ReadonlyArray, cb: (diag: DiagnosticWithLocation) => void): void { for (const diag of program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(computeSuggestionDiagnostics(sourceFile, program, cancellationToken))) { if (contains(errorCodes, diag.code)) { cb(diag as DiagnosticWithLocation); diff --git a/src/services/codefixes/convertFunctionToEs6Class.ts b/src/services/codefixes/convertFunctionToEs6Class.ts index b98f2abb708fc..c204117988855 100644 --- a/src/services/codefixes/convertFunctionToEs6Class.ts +++ b/src/services/codefixes/convertFunctionToEs6Class.ts @@ -13,7 +13,6 @@ namespace ts.codefix { }); function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, checker: TypeChecker): void { - const deletedNodes: { node: Node, inList: boolean }[] = []; const ctorSymbol = checker.getSymbolAtLocation(getTokenAtPosition(sourceFile, position))!; if (!ctorSymbol || !(ctorSymbol.flags & (SymbolFlags.Function | SymbolFlags.Variable))) { @@ -28,7 +27,7 @@ namespace ts.codefix { switch (ctorDeclaration.kind) { case SyntaxKind.FunctionDeclaration: precedingNode = ctorDeclaration; - deleteNode(ctorDeclaration); + changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration as FunctionDeclaration); break; @@ -37,10 +36,10 @@ namespace ts.codefix { newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration as VariableDeclaration); if ((ctorDeclaration.parent).declarations.length === 1) { copyComments(precedingNode, newClassDeclaration!, sourceFile); // TODO: GH#18217 - deleteNode(precedingNode); + changes.delete(sourceFile, precedingNode); } else { - deleteNode(ctorDeclaration, /*inList*/ true); + changes.delete(sourceFile, ctorDeclaration); } break; } @@ -53,21 +52,6 @@ namespace ts.codefix { // Because the preceding node could be touched, we need to insert nodes before delete nodes. changes.insertNodeAfter(sourceFile, precedingNode!, newClassDeclaration); - for (const { node, inList } of deletedNodes) { - if (inList) { - changes.deleteNodeInList(sourceFile, node); - } - else { - changes.deleteNode(sourceFile, node); - } - } - - function deleteNode(node: Node, inList = false) { - // If parent node has already been deleted, do nothing - if (!deletedNodes.some(n => isNodeDescendantOf(node, n.node))) { - deletedNodes.push({ node, inList }); - } - } function createClassElementsFromSymbol(symbol: Symbol) { const memberElements: ClassElement[] = []; @@ -115,7 +99,7 @@ namespace ts.codefix { // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end const nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === SyntaxKind.ExpressionStatement ? assignmentBinaryExpression.parent : assignmentBinaryExpression; - deleteNode(nodeToDelete); + changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { return createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, diff --git a/src/services/codefixes/convertToEs6Module.ts b/src/services/codefixes/convertToEs6Module.ts index bd1e02845cd86..87a1f49cc4864 100644 --- a/src/services/codefixes/convertToEs6Module.ts +++ b/src/services/codefixes/convertToEs6Module.ts @@ -197,7 +197,7 @@ namespace ts.codefix { if (isExportsOrModuleExportsOrAlias(sourceFile, left)) { if (isExportsOrModuleExportsOrAlias(sourceFile, right)) { // `const alias = module.exports;` or `module.exports = alias;` can be removed. - changes.deleteNode(sourceFile, assignment.parent); + changes.delete(sourceFile, assignment.parent); } else { const replacement = isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right) @@ -297,7 +297,7 @@ namespace ts.codefix { if (!right.name) changes.insertName(sourceFile, right, name); const semi = findChildOfKind(parent, SyntaxKind.SemicolonToken, sourceFile); - if (semi) changes.deleteNode(sourceFile, semi, { useNonAdjustedEndPosition: true }); + if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 38f4324af62c8..de741e3e7d02f 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -11,43 +11,107 @@ namespace ts.codefix { getCodeActions(context) { const info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; - const { classDeclaration, classDeclarationSourceFile, inJs, makeStatic, token, call } = info; - const methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, context.preferences); + + if (info.kind === InfoKind.enum) { + const { token, parentDeclaration } = info; + const changes = textChanges.ChangeTracker.with(context, t => addEnumMemberDeclaration(t, context.program.getTypeChecker(), token, parentDeclaration)); + return [createCodeFixAction(fixName, changes, [Diagnostics.Add_missing_enum_member_0, token.text], fixId, Diagnostics.Add_all_missing_members)]; + } + const { parentDeclaration, classDeclarationSourceFile, inJs, makeStatic, token, call } = info; + const methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); const addMember = inJs ? - singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, classDeclaration, token.text, makeStatic)) : - getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, classDeclaration, token, makeStatic); + singleElementArray(getActionsForAddMissingMemberInJavaScriptFile(context, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic)) : + getActionsForAddMissingMemberInTypeScriptFile(context, classDeclarationSourceFile, parentDeclaration, token, makeStatic); return concatenate(singleElementArray(methodCodeAction), addMember); }, fixIds: [fixId], getAllCodeActions: context => { - const seenNames = createMap(); - return codeFixAll(context, errorCodes, (changes, diag) => { - const { program, preferences } = context; - const info = getInfo(diag.file, diag.start, program.getTypeChecker()); - if (!info) return; - const { classDeclaration, classDeclarationSourceFile, inJs, makeStatic, token, call } = info; - if (!addToSeen(seenNames, token.text)) { - return; - } - - // Always prefer to add a method declaration if possible. - if (call) { - addMethodDeclaration(context, changes, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, preferences); - } - else { - if (inJs) { - addMissingMemberInJs(changes, classDeclarationSourceFile, classDeclaration, token.text, makeStatic); + const { program, preferences } = context; + const checker = program.getTypeChecker(); + const seen = createMap(); + + const classToMembers = new NodeMap(); + + return createCombinedCodeActions(textChanges.ChangeTracker.with(context, changes => { + eachDiagnostic(context, errorCodes, diag => { + const info = getInfo(diag.file, diag.start, checker); + if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + info.token.text)) { + return; + } + + if (info.kind === InfoKind.enum) { + const { token, parentDeclaration } = info; + addEnumMemberDeclaration(changes, checker, token, parentDeclaration); } else { - const typeNode = getTypeNode(program.getTypeChecker(), classDeclaration, token); - addPropertyDeclaration(changes, classDeclarationSourceFile, classDeclaration, token.text, typeNode, makeStatic); + const { parentDeclaration, token } = info; + const infos = classToMembers.getOrUpdate(parentDeclaration, () => []); + if (!infos.some(i => i.token.text === token.text)) infos.push(info); } - } - }); + }); + + classToMembers.forEach((infos, classDeclaration) => { + const superClasses = getAllSuperClasses(classDeclaration, checker); + for (const info of infos) { + // If some superclass added this property, don't add it again. + if (superClasses.some(superClass => { + const superInfos = classToMembers.get(superClass); + return !!superInfos && superInfos.some(({ token }) => token.text === info.token.text); + })) continue; + + const { parentDeclaration, classDeclarationSourceFile, inJs, makeStatic, token, call } = info; + + // Always prefer to add a method declaration if possible. + if (call) { + addMethodDeclaration(context, changes, classDeclarationSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + } + else { + if (inJs) { + addMissingMemberInJs(changes, classDeclarationSourceFile, parentDeclaration, token.text, makeStatic); + } + else { + const typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token); + addPropertyDeclaration(changes, classDeclarationSourceFile, parentDeclaration, token.text, typeNode, makeStatic); + } + } + } + }); + })); }, }); - interface Info { token: Identifier; classDeclaration: ClassLikeDeclaration; makeStatic: boolean; classDeclarationSourceFile: SourceFile; inJs: boolean; call: CallExpression | undefined; } + function getAllSuperClasses(cls: ClassLikeDeclaration | undefined, checker: TypeChecker): ReadonlyArray { + const res: ClassLikeDeclaration[] = []; + while (cls) { + const superElement = getClassExtendsHeritageElement(cls); + const superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); + const superDecl = superSymbol && find(superSymbol.declarations, isClassLike); + if (superDecl) { res.push(superDecl); } + cls = superDecl; + } + return res; + } + + interface InfoBase { + readonly kind: InfoKind; + readonly token: Identifier; + readonly parentDeclaration: EnumDeclaration | ClassLikeDeclaration; + } + enum InfoKind { enum, class } + interface EnumInfo extends InfoBase { + readonly kind: InfoKind.enum; + readonly parentDeclaration: EnumDeclaration; + } + interface ClassInfo extends InfoBase { + readonly kind: InfoKind.class; + readonly parentDeclaration: ClassLikeDeclaration; + readonly makeStatic: boolean; + readonly classDeclarationSourceFile: SourceFile; + readonly inJs: boolean; + readonly call: CallExpression | undefined; + } + type Info = EnumInfo | ClassInfo; + function getInfo(tokenSourceFile: SourceFile, tokenPos: number, checker: TypeChecker): Info | undefined { // The identifier of the missing property. eg: // this.missing = 1; @@ -60,17 +124,23 @@ namespace ts.codefix { const { parent } = token; if (!isPropertyAccessExpression(parent)) return undefined; - const leftExpressionType = skipConstraint(checker.getTypeAtLocation(parent.expression)!); + const leftExpressionType = skipConstraint(checker.getTypeAtLocation(parent.expression)); const { symbol } = leftExpressionType; - const classDeclaration = symbol && symbol.declarations && find(symbol.declarations, isClassLike); - if (!classDeclaration) return undefined; + if (!symbol || !symbol.declarations) return undefined; - const makeStatic = (leftExpressionType as TypeReference).target !== checker.getDeclaredTypeOfSymbol(symbol); - const classDeclarationSourceFile = classDeclaration.getSourceFile(); - const inJs = isSourceFileJavaScript(classDeclarationSourceFile); - const call = tryCast(parent.parent, isCallExpression); - - return { token, classDeclaration, makeStatic, classDeclarationSourceFile, inJs, call }; + const classDeclaration = find(symbol.declarations, isClassLike); + if (classDeclaration) { + const makeStatic = (leftExpressionType as TypeReference).target !== checker.getDeclaredTypeOfSymbol(symbol); + const classDeclarationSourceFile = classDeclaration.getSourceFile(); + const inJs = isSourceFileJavaScript(classDeclarationSourceFile); + const call = tryCast(parent.parent, isCallExpression); + return { kind: InfoKind.class, token, parentDeclaration: classDeclaration, makeStatic, classDeclarationSourceFile, inJs, call }; + } + const enumDeclaration = find(symbol.declarations, isEnumDeclaration); + if (enumDeclaration) { + return { kind: InfoKind.enum, token, parentDeclaration: enumDeclaration }; + } + return undefined; } function getActionsForAddMissingMemberInJavaScriptFile(context: CodeFixContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, tokenName: string, makeStatic: boolean): CodeFixAction | undefined { @@ -113,7 +183,7 @@ namespace ts.codefix { if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { const binaryExpression = token.parent.parent as BinaryExpression; const otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; - const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)!)); // TODO: GH#18217 + const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); typeNode = checker.typeToTypeNode(widenedType, classDeclaration); } return typeNode || createKeywordTypeNode(SyntaxKind.AnyKeyword); @@ -209,4 +279,25 @@ namespace ts.codefix { changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); } } + + function addEnumMemberDeclaration(changes: textChanges.ChangeTracker, checker: TypeChecker, token: Identifier, enumDeclaration: EnumDeclaration) { + /** + * create initializer only literal enum that has string initializer. + * value of initializer is a string literal that equal to name of enum member. + * numeric enum or empty enum will not create initializer. + */ + const hasStringInitializer = some(enumDeclaration.members, member => { + const type = checker.getTypeAtLocation(member); + return !!(type && type.flags & TypeFlags.StringLike); + }); + + const enumMember = createEnumMember(token, hasStringInitializer ? createStringLiteral(token.text) : undefined); + changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, updateEnumDeclaration( + enumDeclaration, + enumDeclaration.decorators, + enumDeclaration.modifiers, + enumDeclaration.name, + concatenate(enumDeclaration.members, singleElementArray(enumMember)) + )); + } } diff --git a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts index b558a270decb1..b382b9a2f0558 100644 --- a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts +++ b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts @@ -2,7 +2,8 @@ namespace ts.codefix { const fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof"; const fixId = fixIdAddMissingTypeof; - const errorCodes = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here.code]; + const errorCodes = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code]; + registerCodeFix({ errorCodes, getCodeActions: context => { diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index b292e6d1cdd91..9d9972c03e819 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -34,7 +34,7 @@ namespace ts.codefix { function addMissingMembers(classDeclaration: ClassLikeDeclaration, sourceFile: SourceFile, checker: TypeChecker, changeTracker: textChanges.ChangeTracker, preferences: UserPreferences): void { const extendsNode = getEffectiveBaseTypeNode(classDeclaration)!; - const instantiatedExtendsType = checker.getTypeAtLocation(extendsNode)!; + const instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 04830511c2759..4401625000aa0 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -51,7 +51,7 @@ namespace ts.codefix { const implementedTypeSymbols = checker.getPropertiesOfType(implementedType); const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(and(symbolPointsToNonPrivateMember, symbol => !maybeHeritageClauseSymbol.has(symbol.escapedName))); - const classType = checker.getTypeAtLocation(classDeclaration)!; + const classType = checker.getTypeAtLocation(classDeclaration); if (!classType.getNumberIndexType()) { createMissingIndexSignatureDeclaration(implementedType, IndexKind.Number); diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 8ee9b60051f84..1c26c39b10c1a 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -29,7 +29,7 @@ namespace ts.codefix { function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, constructor: ConstructorDeclaration, superCall: ExpressionStatement): void { changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall); - changes.deleteNode(sourceFile, superCall); + changes.delete(sourceFile, superCall); } function getNodes(sourceFile: SourceFile, pos: number): { readonly constructor: ConstructorDeclaration, readonly superCall: ExpressionStatement } | undefined { diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index ab8014bd0b466..85dff7fb09be6 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -77,7 +77,7 @@ namespace ts.codefix { } function getImportCodeFixesForExpression(context: CodeFixContext, expr: Node): CodeFixAction[] | undefined { - const type = context.program.getTypeChecker().getTypeAtLocation(expr)!; // TODO: GH#18217 + const type = context.program.getTypeChecker().getTypeAtLocation(expr); if (!(type.symbol && (type.symbol as TransientSymbol).originatingImport)) { return []; } diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index fbe3953c1b567..5dd57b6c45408 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -4,6 +4,8 @@ namespace ts.codefix { const errorCodes = [ Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code, Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, + Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code, + Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code, Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2.code, ]; registerCodeFix({ @@ -35,7 +37,7 @@ namespace ts.codefix { let suggestion: string | undefined; if (isPropertyAccessExpression(node.parent) && node.parent.name === node) { Debug.assert(node.kind === SyntaxKind.Identifier); - const containingType = checker.getTypeAtLocation(node.parent.expression)!; + const containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType); } else if (isImportSpecifier(node.parent) && node.parent.name === node) { @@ -43,7 +45,7 @@ namespace ts.codefix { const importDeclaration = findAncestor(node, isImportDeclaration)!; const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { - suggestion = checker.getSuggestionForNonexistentModule(node as Identifier, resolvedSourceFile.symbol); + suggestion = checker.getSuggestionForNonexistentExport(node as Identifier, resolvedSourceFile.symbol); } } else { diff --git a/src/services/codefixes/fixUnreachableCode.ts b/src/services/codefixes/fixUnreachableCode.ts index 6c279d75ab393..2d1c2f0fc38d9 100644 --- a/src/services/codefixes/fixUnreachableCode.ts +++ b/src/services/codefixes/fixUnreachableCode.ts @@ -5,74 +5,55 @@ namespace ts.codefix { registerCodeFix({ errorCodes, getCodeActions(context) { - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, context.span.start)); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, context.span.start, context.span.length)); return [createCodeFixAction(fixId, changes, Diagnostics.Remove_unreachable_code, fixId, Diagnostics.Remove_all_unreachable_code)]; }, fixIds: [fixId], - getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => doChange(changes, diag.file, diag.start)), + getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => doChange(changes, diag.file, diag.start, diag.length)), }); - function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, start: number): void { + function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, start: number, length: number): void { const token = getTokenAtPosition(sourceFile, start); const statement = findAncestor(token, isStatement)!; Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); const container = (isBlock(statement.parent) ? statement.parent : statement).parent; - switch (container.kind) { - case SyntaxKind.IfStatement: - if ((container as IfStatement).elseStatement) { - if (isBlock(statement.parent)) { - changes.deleteNodeRange(sourceFile, first(statement.parent.statements), last(statement.parent.statements)); + if (!isBlock(statement.parent) || statement === first(statement.parent.statements)) { + switch (container.kind) { + case SyntaxKind.IfStatement: + if ((container as IfStatement).elseStatement) { + if (isBlock(statement.parent)) { + break; + } + else { + changes.replaceNode(sourceFile, statement, createBlock(emptyArray)); + } + return; } - else { - changes.replaceNode(sourceFile, statement, createBlock(emptyArray)); - } - break; - } - // falls through - case SyntaxKind.WhileStatement: - case SyntaxKind.ForStatement: - changes.deleteNode(sourceFile, container); - break; - default: - if (isBlock(statement.parent)) { - split(sliceAfter(statement.parent.statements, statement), shouldRemove, (start, end) => changes.deleteNodeRange(sourceFile, start, end)); - } - else { - changes.deleteNode(sourceFile, statement); - } + // falls through + case SyntaxKind.WhileStatement: + case SyntaxKind.ForStatement: + changes.delete(sourceFile, container); + return; + } } - } - - function shouldRemove(s: Statement): boolean { - // Don't remove statements that can validly be used before they appear. - return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && - // `var x;` may declare a variable used above - !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & (NodeFlags.Let | NodeFlags.Const)) && s.declarationList.declarations.some(d => !d.initializer)); - } - function isPurelyTypeDeclaration(s: Statement): boolean { - switch (s.kind) { - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.TypeAliasDeclaration: - return true; - case SyntaxKind.ModuleDeclaration: - return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated; - case SyntaxKind.EnumDeclaration: - return hasModifier(s, ModifierFlags.Const); - default: - return false; + if (isBlock(statement.parent)) { + const end = start + length; + const lastStatement = Debug.assertDefined(lastWhere(sliceAfter(statement.parent.statements, statement), s => s.pos < end)); + changes.deleteNodeRange(sourceFile, statement, lastStatement); + } + else { + changes.delete(sourceFile, statement); } } - function sliceAfter(arr: ReadonlyArray, value: T): ReadonlyArray { - const index = arr.indexOf(value); - Debug.assert(index !== -1); - return arr.slice(index); - } - - // Calls 'cb' with the start and end of each range where 'pred' is true. - function split(arr: ReadonlyArray, pred: (t: T) => boolean, cb: (start: T, end: T) => void): void { - getRangesWhere(arr, pred, (start, afterEnd) => cb(arr[start], arr[afterEnd - 1])); + function lastWhere(a: ReadonlyArray, pred: (value: T) => boolean): T | undefined { + let last: T | undefined; + for (const value of a) { + if (!pred(value)) break; + last = value; + } + return last; } } diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index d164d4eee9fdf..f70c9ce648222 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -22,7 +22,7 @@ namespace ts.codefix { const importDecl = tryGetFullImport(token); if (importDecl) { - const changes = textChanges.ChangeTracker.with(context, t => t.deleteNode(sourceFile, importDecl)); + const changes = textChanges.ChangeTracker.with(context, t => t.delete(sourceFile, importDecl)); return [createCodeFixAction(fixName, changes, [Diagnostics.Remove_import_from_0, showModuleSpecifier(importDecl)], fixIdDelete, Diagnostics.Delete_all_unused_declarations)]; } const delDestructure = textChanges.ChangeTracker.with(context, t => @@ -67,7 +67,7 @@ namespace ts.codefix { case fixIdDelete: { const importDecl = tryGetFullImport(token); if (importDecl) { - changes.deleteDeclaration(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && !tryDeleteFullVariableStatement(sourceFile, token, changes)) { @@ -94,7 +94,7 @@ namespace ts.codefix { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { - changes.deleteDeclaration(sourceFile, decl); + changes.delete(sourceFile, decl); } return true; } @@ -102,7 +102,7 @@ namespace ts.codefix { function tryDeleteFullVariableStatement(sourceFile: SourceFile, token: Node, changes: textChanges.ChangeTracker): boolean { const declarationList = tryCast(token.parent, isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.deleteDeclaration(sourceFile, declarationList.parent.kind === SyntaxKind.VariableStatement ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === SyntaxKind.VariableStatement ? declarationList.parent : declarationList); return true; } return false; @@ -140,7 +140,7 @@ namespace ts.codefix { FindAllReferences.Core.eachSymbolReferenceInFile(token, checker, sourceFile, (ref: Node) => { if (ref.parent.kind === SyntaxKind.PropertyAccessExpression) ref = ref.parent; if (ref.parent.kind === SyntaxKind.BinaryExpression && ref.parent.parent.kind === SyntaxKind.ExpressionStatement) { - changes.deleteDeclaration(sourceFile, ref.parent.parent); + changes.delete(sourceFile, ref.parent.parent); } }); } @@ -151,13 +151,13 @@ namespace ts.codefix { tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, isFixAll); } else { - changes.deleteDeclaration(sourceFile, isImportClause(parent) ? token : isComputedPropertyName(parent) ? parent.parent : parent); + changes.delete(sourceFile, isImportClause(parent) ? token : isComputedPropertyName(parent) ? parent.parent : parent); } } function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: ReadonlyArray, isFixAll: boolean): void { if (mayDeleteParameter(p, checker, isFixAll)) { - changes.deleteDeclaration(sourceFile, p); + changes.delete(sourceFile, p); deleteUnusedArguments(changes, sourceFile, p, sourceFiles, checker); } } @@ -199,7 +199,7 @@ namespace ts.codefix { FindAllReferences.Core.eachSignatureCall(deletedParameter.parent, sourceFiles, checker, call => { const index = deletedParameter.parent.parameters.indexOf(deletedParameter); if (call.arguments.length > index) { // Just in case the call didn't provide enough arguments. - changes.deleteDeclaration(sourceFile, call.arguments[index]); + changes.delete(sourceFile, call.arguments[index]); } }); } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index d2f1095ef4cca..9b18fe3637aa3 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1,58 +1,122 @@ /* @internal */ namespace ts.codefix { - import ChangeTracker = textChanges.ChangeTracker; + export const importFixId = "fixMissingImport"; + const errorCodes: ReadonlyArray = [ + Diagnostics.Cannot_find_name_0.code, + Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, + Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code, + Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_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, + Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, + ]; registerCodeFix({ - errorCodes: [ - Diagnostics.Cannot_find_name_0.code, - Diagnostics.Cannot_find_name_0_Did_you_mean_1.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, - Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, - ], - getCodeActions: context => context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(context) - : getActionsForNonUMDImport(context), - // TODO: GH#20315 - fixIds: [], - getAllCodeActions: notImplemented, - }); - - interface SymbolContext extends textChanges.TextChangesContext { - sourceFile: SourceFile; - symbolName: string; - } - - interface ImportCodeFixContext extends SymbolContext { - symbolToken: Node | undefined; - program: Program; - checker: TypeChecker; - compilerOptions: CompilerOptions; - getCanonicalFileName: GetCanonicalFileName; - preferences: UserPreferences; - } - - function createCodeAction(descriptionDiagnostic: DiagnosticMessage, diagnosticArgs: [string, string], changes: FileTextChanges[]): CodeFixAction { - // TODO: GH#20315 - return createCodeFixActionNoFixId("import", changes, [descriptionDiagnostic, ...diagnosticArgs] as [DiagnosticMessage, string, string]); - } + errorCodes, + getCodeActions(context) { + const { errorCode, preferences, sourceFile, span } = context; + const info = getFixesInfo(context, errorCode, span.start); + if (!info) return undefined; + const { fixes, symbolName } = info; + const quotePreference = getQuotePreference(sourceFile, preferences); + return fixes.map(fix => codeActionForFix(context, sourceFile, symbolName, fix, quotePreference)); + }, + fixIds: [importFixId], + getAllCodeActions: context => { + const { sourceFile, preferences } = context; + + // Namespace fixes don't conflict, so just build a list. + const addToNamespace: FixUseNamespaceImport[] = []; + // Keys are import clause node IDs. + const addToExisting = createMap<{ readonly importClause: ImportClause, defaultImport: string | undefined; readonly namedImports: string[] }>(); + // Keys are module specifiers. + const newImports = createMap>(); + + eachDiagnostic(context, errorCodes, diag => { + const info = getFixesInfo(context, diag.code, diag.start); + if (!info || !info.fixes.length) return; + const { fixes, symbolName } = info; + + const fix = first(fixes); + switch (fix.kind) { + case ImportFixKind.UseNamespace: + addToNamespace.push(fix); + break; + case ImportFixKind.AddToExisting: { + const { importClause, importKind } = fix; + const key = String(getNodeId(importClause)); + let entry = addToExisting.get(key); + if (!entry) { + addToExisting.set(key, entry = { importClause, defaultImport: undefined, namedImports: [] }); + } + if (importKind === ImportKind.Named) { + pushIfUnique(entry.namedImports, symbolName); + } + else { + Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + } + break; + } + case ImportFixKind.AddNew: { + const { moduleSpecifier, importKind } = fix; + let entry = newImports.get(moduleSpecifier); + if (!entry) { + newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined }); + } + switch (importKind) { + case ImportKind.Default: + Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + entry.defaultImport = symbolName; + break; + case ImportKind.Named: + pushIfUnique(entry.namedImports, symbolName); + break; + case ImportKind.Equals: + case ImportKind.Namespace: + Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + entry.namespaceLikeImport = { importKind, name: symbolName }; + break; + } + break; + } + default: + Debug.assertNever(fix); + } + }); - function convertToImportCodeFixContext(context: CodeFixContext, symbolToken: Node, symbolName: string): ImportCodeFixContext { - const { program } = context; - const checker = program.getTypeChecker(); + return createCombinedCodeActions(textChanges.ChangeTracker.with(context, changes => { + for (const fix of addToNamespace) { + addNamespaceQualifier(changes, sourceFile, fix); + } + addToExisting.forEach(({ importClause, defaultImport, namedImports }) => { + doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports); + }); + const quotePreference = getQuotePreference(sourceFile, preferences); + newImports.forEach((imports, moduleSpecifier) => { + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports); + }); + })); + }, + }); - return { - host: context.host, - formatContext: context.formatContext, - sourceFile: context.sourceFile, - program, - checker, - compilerOptions: program.getCompilerOptions(), - getCanonicalFileName: createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(context.host)), - symbolName, - symbolToken, - preferences: context.preferences, - }; + // Sorted with the preferred fix coming first. + const enum ImportFixKind { UseNamespace, AddToExisting, AddNew } + type ImportFix = FixUseNamespaceImport | FixAddToExistingImport | FixAddNewImport; + interface FixUseNamespaceImport { + readonly kind: ImportFixKind.UseNamespace; + readonly namespacePrefix: string; + readonly symbolToken: Identifier; + } + interface FixAddToExistingImport { + readonly kind: ImportFixKind.AddToExisting; + readonly importClause: ImportClause; + readonly importKind: ImportKind.Default | ImportKind.Named; + } + interface FixAddNewImport { + readonly kind: ImportFixKind.AddNew; + readonly moduleSpecifier: string; + readonly importKind: ImportKind; } const enum ImportKind { @@ -69,17 +133,11 @@ namespace ts.codefix { } /** Information needed to augment an existing import declaration. */ - interface ExistingImportInfo { + interface FixAddToExistingImportInfo { readonly declaration: AnyImportSyntax; readonly importKind: ImportKind; } - /** Information needed to create a new import declaration. */ - interface NewImportInfo { - readonly moduleSpecifier: string; - readonly importKind: ImportKind; - } - export function getImportCompletionAction( exportedSymbol: Symbol, moduleSymbol: Symbol, @@ -88,10 +146,8 @@ namespace ts.codefix { host: LanguageServiceHost, program: Program, checker: TypeChecker, - compilerOptions: CompilerOptions, allSourceFiles: ReadonlyArray, formatContext: formatting.FormatContext, - getCanonicalFileName: GetCanonicalFileName, symbolToken: Node | undefined, preferences: UserPreferences, ): { readonly moduleSpecifier: string, readonly codeAction: CodeAction } { @@ -99,8 +155,8 @@ namespace ts.codefix { Debug.assert(exportInfos.some(info => info.moduleSymbol === moduleSymbol)); // We sort the best codefixes first, so taking `first` is best for completions. const moduleSpecifier = first(getNewImportInfos(program, sourceFile, exportInfos, host, preferences)).moduleSpecifier; - const ctx: ImportCodeFixContext = { host, program, checker, compilerOptions, sourceFile, formatContext, symbolName, getCanonicalFileName, symbolToken, preferences }; - return { moduleSpecifier, codeAction: first(getCodeActionsForImport(exportInfos, ctx)) }; + const fix = first(getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences)); + return { moduleSpecifier, codeAction: codeActionForFix({ host, formatContext }, sourceFile, symbolName, fix, getQuotePreference(sourceFile, preferences)) }; } function getAllReExportingModules(exportedSymbol: Symbol, exportingModuleSymbol: Symbol, symbolName: string, sourceFile: SourceFile, checker: TypeChecker, allSourceFiles: ReadonlyArray): ReadonlyArray { const result: SymbolExportInfo[] = []; @@ -120,26 +176,25 @@ namespace ts.codefix { return result; } - function getCodeActionsForImport(exportInfos: ReadonlyArray, context: ImportCodeFixContext): CodeFixAction[] { - const result: CodeFixAction[] = []; - getCodeActionsForImport_separateExistingAndNew(exportInfos, context, result, result); - return result; + function getFixForImport( + exportInfos: ReadonlyArray, + symbolName: string, + symbolToken: Node | undefined, + program: Program, + sourceFile: SourceFile, + host: LanguageServiceHost, + preferences: UserPreferences, + ): ReadonlyArray { + const checker = program.getTypeChecker(); + const existingImports = flatMap(exportInfos, info => getExistingImportDeclarations(info, checker, sourceFile)); + const useNamespace = tryUseExistingNamespaceImport(existingImports, symbolName, symbolToken, checker); + const addToExisting = tryAddToExistingImport(existingImports); + // Don't bother providing an action to add a new import if we can add to an existing one. + const addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, host, preferences); + return [...(useNamespace ? [useNamespace] : emptyArray), ...addImport]; } - function getCodeActionsForImport_separateExistingAndNew(exportInfos: ReadonlyArray, context: ImportCodeFixContext, useExisting: Push, addNew: Push): void { - const existingImports = flatMap(exportInfos, info => getExistingImportDeclarations(info, context.checker, context.sourceFile)); - - append(useExisting, tryUseExistingNamespaceImport(existingImports, context, context.symbolToken, context.checker)); - const addToExisting = tryAddToExistingImport(existingImports, context); - - if (addToExisting) { - useExisting.push(addToExisting); - } - else { // Don't bother providing an action to add a new import if we can add to an existing one. - getCodeActionsForAddImport(exportInfos, context, existingImports, addNew); - } - } - function tryUseExistingNamespaceImport(existingImports: ReadonlyArray, context: SymbolContext, symbolToken: Node | undefined, checker: TypeChecker): CodeFixAction | undefined { + function tryUseExistingNamespaceImport(existingImports: ReadonlyArray, symbolName: string, symbolToken: Node | undefined, checker: TypeChecker): FixUseNamespaceImport | undefined { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -152,25 +207,26 @@ namespace ts.codefix { // 1. change "member3" to "ns.member3" // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. - return !symbolToken || !isIdentifier(symbolToken) ? undefined : firstDefined(existingImports, ({ declaration }) => { + return !symbolToken || !isIdentifier(symbolToken) ? undefined : firstDefined(existingImports, ({ declaration }): FixUseNamespaceImport | undefined => { const namespace = getNamespaceImportName(declaration); if (namespace) { - const moduleSymbol = namespace && checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)!); - if (moduleSymbol && moduleSymbol.exports!.has(escapeLeadingUnderscores(context.symbolName))) { - return getCodeActionForUseExistingNamespaceImport(namespace.text, context, symbolToken); + const moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)!); + if (moduleSymbol && moduleSymbol.exports!.has(escapeLeadingUnderscores(symbolName))) { + return { kind: ImportFixKind.UseNamespace, namespacePrefix: namespace.text, symbolToken }; } } }); } - function tryAddToExistingImport(existingImports: ReadonlyArray, context: SymbolContext): CodeFixAction | undefined { - return firstDefined(existingImports, ({ declaration, importKind }) => { - if (declaration.kind === SyntaxKind.ImportDeclaration && declaration.importClause) { - const changes = tryUpdateExistingImport(context, declaration.importClause, importKind); - if (changes) { - const moduleSpecifierWithoutQuotes = stripQuotes(declaration.moduleSpecifier.getText()); - return createCodeAction(Diagnostics.Add_0_to_existing_import_declaration_from_1, [context.symbolName, moduleSpecifierWithoutQuotes], changes); - } - } + + function tryAddToExistingImport(existingImports: ReadonlyArray): FixAddToExistingImport | undefined { + return firstDefined(existingImports, ({ declaration, importKind }): FixAddToExistingImport | undefined => { + if (declaration.kind !== SyntaxKind.ImportDeclaration) return undefined; + const { importClause } = declaration; + if (!importClause) return undefined; + const { name, namedBindings } = importClause; + return importKind === ImportKind.Default && !name || importKind === ImportKind.Named && (!namedBindings || namedBindings.kind === SyntaxKind.NamedImports) + ? { kind: ImportFixKind.AddToExisting, importClause, importKind } + : undefined; }); } @@ -184,180 +240,82 @@ namespace ts.codefix { } } - function getExistingImportDeclarations({ moduleSymbol, importKind }: SymbolExportInfo, checker: TypeChecker, { imports }: SourceFile): ReadonlyArray { - return mapDefined(imports, moduleSpecifier => { + function getExistingImportDeclarations({ moduleSymbol, importKind }: SymbolExportInfo, checker: TypeChecker, { imports }: SourceFile): ReadonlyArray { + return mapDefined(imports, moduleSpecifier => { const i = importFromModuleSpecifier(moduleSpecifier); return (i.kind === SyntaxKind.ImportDeclaration || i.kind === SyntaxKind.ImportEqualsDeclaration) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind } : undefined; }); } - function getCodeActionForNewImport(context: SymbolContext & { preferences: UserPreferences }, { moduleSpecifier, importKind }: NewImportInfo): CodeFixAction { - const { sourceFile, symbolName, preferences } = context; - - const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier); - const quotedModuleSpecifier = makeStringLiteral(moduleSpecifierWithoutQuotes, getQuotePreference(sourceFile, preferences)); - const importDecl = importKind !== ImportKind.Equals - ? createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - createImportClauseOfKind(importKind, symbolName), - quotedModuleSpecifier) - : createImportEqualsDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - createIdentifier(symbolName), - createExternalModuleReference(quotedModuleSpecifier)); - - const changes = ChangeTracker.with(context, t => insertImport(t, sourceFile, importDecl)); - - // 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 separating code and import statements. - return createCodeAction(Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); - } - - function createImportClauseOfKind(kind: ImportKind.Default | ImportKind.Named | ImportKind.Namespace, symbolName: string) { - const id = createIdentifier(symbolName); - switch (kind) { - case ImportKind.Default: - return createImportClause(id, /*namedBindings*/ undefined); - case ImportKind.Namespace: - return createImportClause(/*name*/ undefined, createNamespaceImport(id)); - case ImportKind.Named: - return createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, id)])); - default: - Debug.assertNever(kind); - } - } - function getNewImportInfos( program: Program, sourceFile: SourceFile, moduleSymbols: ReadonlyArray, host: LanguageServiceHost, preferences: UserPreferences, - ): ReadonlyArray { - const choicesForEachExportingModule = flatMap(moduleSymbols, ({ moduleSymbol, importKind }) => { + ): ReadonlyArray { + const choicesForEachExportingModule = flatMap>(moduleSymbols, ({ moduleSymbol, importKind }) => { const modulePathsGroups = moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences); - return modulePathsGroups.map(group => group.map(moduleSpecifier => ({ moduleSpecifier, importKind }))); + return modulePathsGroups.map(group => group.map((moduleSpecifier): FixAddNewImport => ({ kind: ImportFixKind.AddNew, moduleSpecifier, importKind }))); }); // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together - return flatten(choicesForEachExportingModule.sort((a, b) => first(a).moduleSpecifier.length - first(b).moduleSpecifier.length)); + return flatten(choicesForEachExportingModule.sort((a, b) => first(a).moduleSpecifier.length - first(b).moduleSpecifier.length)); } - function getCodeActionsForAddImport( + function getFixesForAddImport( exportInfos: ReadonlyArray, - ctx: ImportCodeFixContext, - existingImports: ReadonlyArray, - addNew: Push, - ): void { + existingImports: ReadonlyArray, + program: Program, + sourceFile: SourceFile, + host: LanguageServiceHost, + preferences: UserPreferences, + ): ReadonlyArray { const existingDeclaration = firstDefined(existingImports, newImportInfoFromExistingSpecifier); - const newImportInfos = existingDeclaration - ? [existingDeclaration] - : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.host, ctx.preferences); - for (const info of newImportInfos) { - addNew.push(getCodeActionForNewImport(ctx, info)); - } + return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, exportInfos, host, preferences); } - function newImportInfoFromExistingSpecifier({ declaration, importKind }: ExistingImportInfo): NewImportInfo | undefined { + function newImportInfoFromExistingSpecifier({ declaration, importKind }: FixAddToExistingImportInfo): FixAddNewImport | undefined { const expression = declaration.kind === SyntaxKind.ImportDeclaration ? declaration.moduleSpecifier : declaration.moduleReference.kind === SyntaxKind.ExternalModuleReference ? declaration.moduleReference.expression : undefined; - return expression && isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind } : undefined; - } - - function tryUpdateExistingImport(context: SymbolContext, importClause: ImportClause | ImportEqualsDeclaration, importKind: ImportKind): FileTextChanges[] | undefined { - const { symbolName, sourceFile } = context; - const { name } = importClause; - const { namedBindings } = (importClause.kind !== SyntaxKind.ImportEqualsDeclaration && importClause) as ImportClause; // TODO: GH#18217 - switch (importKind) { - case ImportKind.Default: - return name ? undefined : ChangeTracker.with(context, t => - t.replaceNode(sourceFile, importClause, createImportClause(createIdentifier(symbolName), namedBindings))); - - case ImportKind.Named: { - const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(symbolName)); - if (namedBindings && namedBindings.kind === SyntaxKind.NamedImports && namedBindings.elements.length !== 0) { - // There are already named imports; add another. - return ChangeTracker.with(context, t => t.insertNodeInListAfter( - sourceFile, - namedBindings.elements[namedBindings.elements.length - 1], - newImportSpecifier)); - } - if (!namedBindings || namedBindings.kind === SyntaxKind.NamedImports && namedBindings.elements.length === 0) { - return ChangeTracker.with(context, t => - t.replaceNode(sourceFile, importClause, createImportClause(name, createNamedImports([newImportSpecifier])))); - } - return undefined; - } - - case ImportKind.Namespace: - return namedBindings ? undefined : ChangeTracker.with(context, t => - t.replaceNode(sourceFile, importClause, createImportClause(name, createNamespaceImport(createIdentifier(symbolName))))); - - case ImportKind.Equals: - return undefined; - - default: - Debug.assertNever(importKind); - } + return expression && isStringLiteral(expression) ? { kind: ImportFixKind.AddNew, moduleSpecifier: expression.text, importKind } : undefined; } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix: string, context: SymbolContext, symbolToken: Identifier): CodeFixAction { - const { symbolName, sourceFile } = context; - - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - const changes = ChangeTracker.with(context, tracker => - tracker.replaceNode(sourceFile, symbolToken, createPropertyAccess(createIdentifier(namespacePrefix), symbolToken))); - return createCodeAction(Diagnostics.Change_0_to_1, [symbolName, `${namespacePrefix}.${symbolName}`], changes); - } - - function getActionsForUMDImport(context: CodeFixContext): CodeFixAction[] | undefined { - const token = getTokenAtPosition(context.sourceFile, context.span.start); - const checker = context.program.getTypeChecker(); - - let umdSymbol: Symbol | undefined; - - if (isIdentifier(token)) { - // try the identifier to see if it is the umd symbol - umdSymbol = checker.getSymbolAtLocation(token); - } - - if (!isUMDExportSymbol(umdSymbol)) { - // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. - const parent = token.parent; - const isNodeOpeningLikeElement = isJsxOpeningLikeElement(parent); - if ((isJsxOpeningLikeElement && (parent).tagName === token) || parent.kind === SyntaxKind.JsxOpeningFragment) { - umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), - isNodeOpeningLikeElement ? (parent).tagName : parent, SymbolFlags.Value, /*excludeGlobals*/ false); - } - } - - if (isUMDExportSymbol(umdSymbol)) { - const symbol = checker.getAliasedSymbol(umdSymbol!); - if (symbol) { - return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(context.program.getCompilerOptions()) }], - convertToImportCodeFixContext(context, token, umdSymbol!.name)); - } - } - - return undefined; + interface FixesInfo { readonly fixes: ReadonlyArray; readonly symbolName: string; } + function getFixesInfo(context: CodeFixContextBase, errorCode: number, pos: number): FixesInfo | undefined { + const symbolToken = getTokenAtPosition(context.sourceFile, pos); + const info = errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getFixesInfoForUMDImport(context, symbolToken) + : getFixesInfoForNonUMDImport(context, symbolToken); + return info && { ...info, fixes: sort(info.fixes, (a, b) => a.kind - b.kind) }; } - function getUmdImportKind(compilerOptions: CompilerOptions) { + function getFixesInfoForUMDImport({ sourceFile, program, host, preferences }: CodeFixContextBase, token: Node): FixesInfo | undefined { + const checker = program.getTypeChecker(); + const umdSymbol = getUmdSymbol(token, checker); + if (!umdSymbol) return undefined; + const symbol = checker.getAliasedSymbol(umdSymbol); + const symbolName = umdSymbol.name; + const exportInfos: ReadonlyArray = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()) }]; + const fixes = getFixForImport(exportInfos, symbolName, token, program, sourceFile, host, preferences); + return { fixes, symbolName }; + } + function getUmdSymbol(token: Node, checker: TypeChecker): Symbol | undefined { + // try the identifier to see if it is the umd symbol + const umdSymbol = isIdentifier(token) ? checker.getSymbolAtLocation(token) : undefined; + if (isUMDExportSymbol(umdSymbol)) return umdSymbol; + + // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. + const { parent } = token; + return (isJsxOpeningLikeElement(parent) && parent.tagName === token) || isJsxOpeningFragment(parent) + ? tryCast(checker.resolveName(checker.getJsxNamespace(parent), isJsxOpeningLikeElement(parent) ? token : parent, SymbolFlags.Value, /*excludeGlobals*/ false), isUMDExportSymbol) + : undefined; + } + + function getUmdImportKind(compilerOptions: CompilerOptions): ImportKind { // Import a synthetic `default` if enabled. if (getAllowSyntheticDefaultImports(compilerOptions)) { return ImportKind.Default; @@ -381,11 +339,9 @@ namespace ts.codefix { } } - function getActionsForNonUMDImport(context: CodeFixContext): CodeFixAction[] | undefined { + function getFixesInfoForNonUMDImport({ sourceFile, program, cancellationToken, host, preferences }: CodeFixContextBase, symbolToken: Node): FixesInfo | undefined { // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. - const { sourceFile, span, program, cancellationToken } = context; const checker = program.getTypeChecker(); - const symbolToken = getTokenAtPosition(sourceFile, span.start); // If we're at ``, we must check if `Foo` is already in scope, and if so, get an import for `React` instead. const symbolName = isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken @@ -394,17 +350,22 @@ namespace ts.codefix { : isIdentifier(symbolToken) ? symbolToken.text : undefined; if (!symbolName) return undefined; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - Debug.assert(symbolName !== "default"); + Debug.assert(symbolName !== InternalSymbolName.Default); - const addToExistingDeclaration: CodeFixAction[] = []; - const addNewDeclaration: CodeFixAction[] = []; - getExportInfos(symbolName, getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).forEach(exportInfos => { - getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); - }); - return [...addToExistingDeclaration, ...addNewDeclaration]; + const fixes = arrayFrom(flatMapIterator(getExportInfos(symbolName, getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), ([_, exportInfos]) => + getFixForImport(exportInfos, symbolName, symbolToken, program, sourceFile, host, preferences))); + return { fixes, symbolName }; } - function getExportInfos(symbolName: string, currentTokenMeaning: SemanticMeaning, cancellationToken: CancellationToken, sourceFile: SourceFile, checker: TypeChecker, program: Program): ReadonlyMap> { + // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. + function getExportInfos( + symbolName: string, + currentTokenMeaning: SemanticMeaning, + cancellationToken: CancellationToken, + sourceFile: SourceFile, + checker: TypeChecker, + program: Program, + ): ReadonlyMap> { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). const originalSymbolToExportInfos = createMultiMap(); @@ -417,40 +378,136 @@ namespace ts.codefix { // check the default export const defaultExport = checker.tryGetMemberInModuleExports(InternalSymbolName.Default, moduleSymbol); if (defaultExport) { - const localSymbol = getLocalSymbolForExportDefault(defaultExport); - if (( - localSymbol && localSymbol.escapedName === symbolName || - getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target!) === symbolName - ) && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { - addSymbol(moduleSymbol, localSymbol || defaultExport, ImportKind.Default); + const info = getDefaultExportInfo(defaultExport, moduleSymbol, program); + if (info && info.name === symbolName && symbolHasMeaning(info.symbolForMeaning, currentTokenMeaning)) { + addSymbol(moduleSymbol, defaultExport, ImportKind.Default); } } // check exports with the same name const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { addSymbol(moduleSymbol, exportSymbolWithIdenticalName, ImportKind.Named); } + }); + return originalSymbolToExportInfos; + } - function getEscapedNameForExportDefault(symbol: Symbol): __String | undefined { - return symbol.declarations && firstDefined(symbol.declarations, declaration => { - if (isExportAssignment(declaration)) { - if (isIdentifier(declaration.expression)) { - return declaration.expression.escapedText; - } + function getDefaultExportInfo(defaultExport: Symbol, moduleSymbol: Symbol, program: Program): { readonly symbolForMeaning: Symbol, readonly name: string } | undefined { + const checker = program.getTypeChecker(); + + const localSymbol = getLocalSymbolForExportDefault(defaultExport); + if (localSymbol) return { symbolForMeaning: localSymbol, name: localSymbol.name }; + + const name = getNameForExportDefault(defaultExport); + if (name !== undefined) return { symbolForMeaning: defaultExport, name }; + + if (defaultExport.flags & SymbolFlags.Alias) { + const aliased = checker.getAliasedSymbol(defaultExport); + return getDefaultExportInfo(aliased, Debug.assertDefined(aliased.parent), program); + } + else { + const moduleName = moduleSymbolToValidIdentifier(moduleSymbol, program.getCompilerOptions().target!); + return moduleName === undefined ? undefined : { symbolForMeaning: defaultExport, name: moduleName }; + } + } + + function getNameForExportDefault(symbol: Symbol): string | undefined { + return symbol.declarations && firstDefined(symbol.declarations, declaration => { + if (isExportAssignment(declaration)) { + if (isIdentifier(declaration.expression)) { + return declaration.expression.text; + } + } + else if (isExportSpecifier(declaration)) { + Debug.assert(declaration.name.text === InternalSymbolName.Default); + return declaration.propertyName && declaration.propertyName.text; + } + }); + } + + function codeActionForFix(context: textChanges.TextChangesContext, sourceFile: SourceFile, symbolName: string, fix: ImportFix, quotePreference: QuotePreference): CodeFixAction { + let diag!: DiagnosticAndArguments; + const changes = textChanges.ChangeTracker.with(context, tracker => { + diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference); + }); + return createCodeFixAction("import", changes, diag, importFixId, Diagnostics.Add_all_missing_imports); + } + function codeActionForFixWorker(changes: textChanges.ChangeTracker, sourceFile: SourceFile, symbolName: string, fix: ImportFix, quotePreference: QuotePreference): DiagnosticAndArguments { + switch (fix.kind) { + case ImportFixKind.UseNamespace: + addNamespaceQualifier(changes, sourceFile, fix); + return [Diagnostics.Change_0_to_1, symbolName, `${fix.namespacePrefix}.${symbolName}`]; + case ImportFixKind.AddToExisting: { + const { importClause, importKind } = fix; + doAddExistingFix(changes, sourceFile, importClause, importKind === ImportKind.Default ? symbolName : undefined, importKind === ImportKind.Named ? [symbolName] : emptyArray); + const moduleSpecifierWithoutQuotes = stripQuotes(importClause.parent.moduleSpecifier.getText()); + return [Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; + } + case ImportFixKind.AddNew: { + const { importKind, moduleSpecifier } = fix; + addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === ImportKind.Default ? { defaultImport: symbolName, namedImports: emptyArray, namespaceLikeImport: undefined } + : importKind === ImportKind.Named ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined } + : { defaultImport: undefined, namedImports: emptyArray, namespaceLikeImport: { importKind, name: symbolName } }); + return [Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; + } + default: + return Debug.assertNever(fix); + } + } + + function doAddExistingFix(changes: textChanges.ChangeTracker, sourceFile: SourceFile, clause: ImportClause, defaultImport: string | undefined, namedImports: ReadonlyArray): void { + if (defaultImport) { + Debug.assert(!clause.name); + changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), createIdentifier(defaultImport), { suffix: ", " }); + } + + if (namedImports.length) { + const specifiers = namedImports.map(name => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))); + if (clause.namedBindings && cast(clause.namedBindings, isNamedImports).elements.length) { + for (const spec of specifiers) { + changes.insertNodeInListAfter(sourceFile, last(cast(clause.namedBindings, isNamedImports).elements), spec); + } + } + else { + if (specifiers.length) { + const namedImports = createNamedImports(specifiers); + if (clause.namedBindings) { + changes.replaceNode(sourceFile, clause.namedBindings, namedImports); } - else if (isExportSpecifier(declaration)) { - Debug.assert(declaration.name.escapedText === InternalSymbolName.Default); - return declaration.propertyName && declaration.propertyName.escapedText; + else { + changes.insertNodeAfter(sourceFile, Debug.assertDefined(clause.name), namedImports); } - }); + } } - }); - return originalSymbolToExportInfos; + } + } + + function addNamespaceQualifier(changes: textChanges.ChangeTracker, sourceFile: SourceFile, { namespacePrefix, symbolToken }: FixUseNamespaceImport): void { + changes.replaceNode(sourceFile, symbolToken, createPropertyAccess(createIdentifier(namespacePrefix), createIdentifier(symbolToken.text))); + } + + interface ImportsCollection { + readonly defaultImport: string | undefined; + readonly namedImports: string[]; + readonly namespaceLikeImport: { readonly importKind: ImportKind.Equals | ImportKind.Namespace, readonly name: string } | undefined; + } + function addNewImports(changes: textChanges.ChangeTracker, sourceFile: SourceFile, moduleSpecifier: string, quotePreference: QuotePreference, { defaultImport, namedImports, namespaceLikeImport }: ImportsCollection): void { + const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference); + if (defaultImport !== undefined || namedImports.length) { + insertImport(changes, sourceFile, + makeImport( + defaultImport === undefined ? undefined : createIdentifier(defaultImport), + namedImports.map(n => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(n))), moduleSpecifier, quotePreference)); + } + if (namespaceLikeImport) { + insertImport(changes, sourceFile, namespaceLikeImport.importKind === ImportKind.Equals + ? createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createIdentifier(namespaceLikeImport.name), createExternalModuleReference(quotedModuleSpecifier)) + : createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + } } - function checkSymbolHasMeaning({ declarations }: Symbol, meaning: SemanticMeaning): boolean { + function symbolHasMeaning({ declarations }: Symbol, meaning: SemanticMeaning): boolean { return some(declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)); } diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index cadb6d232d8be..292b92dbd3250 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -33,7 +33,7 @@ namespace ts.codefix { const token = getTokenAtPosition(sourceFile, start); let declaration!: Declaration | undefined; const changes = textChanges.ChangeTracker.with(context, changes => { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeenseen*/ returnTrue); }); - const name = getNameOfDeclaration(declaration!); + const name = declaration && getNameOfDeclaration(declaration); return !name || changes.length === 0 ? undefined : [createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, Diagnostics.Infer_all_types_from_usage)]; }, @@ -401,7 +401,7 @@ namespace ts.codefix { case SyntaxKind.LessThanEqualsToken: case SyntaxKind.GreaterThanToken: case SyntaxKind.GreaterThanEqualsToken: - const operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)!; + const operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & TypeFlags.EnumLike) { addCandidateType(usageContext, operandType); } @@ -412,7 +412,7 @@ namespace ts.codefix { case SyntaxKind.PlusEqualsToken: case SyntaxKind.PlusToken: - const otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)!; + const otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & TypeFlags.EnumLike) { addCandidateType(usageContext, otherOperandType); } @@ -472,7 +472,7 @@ namespace ts.codefix { if (parent.arguments) { for (const argument of parent.arguments) { - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)!); + callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); } } @@ -501,7 +501,7 @@ namespace ts.codefix { return; } else { - const indexType = checker.getTypeAtLocation(parent)!; + const indexType = checker.getTypeAtLocation(parent); const indexUsageContext = {}; inferTypeFromContext(parent, checker, indexUsageContext); if (indexType.flags & TypeFlags.NumberLike) { diff --git a/src/services/completions.ts b/src/services/completions.ts index 4160ac80369b1..2c0bb0a877556 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -2,12 +2,20 @@ namespace ts.Completions { export type Log = (message: string) => void; - type SymbolOriginInfo = { type: "this-type" } | { type: "symbol-member" } | SymbolOriginInfoExport; + const enum SymbolOriginInfoKind { ThisType, SymbolMemberNoExport, SymbolMemberExport, Export } + type SymbolOriginInfo = { kind: SymbolOriginInfoKind.ThisType } | { kind: SymbolOriginInfoKind.SymbolMemberNoExport } | SymbolOriginInfoExport; interface SymbolOriginInfoExport { - type: "export"; + kind: SymbolOriginInfoKind.SymbolMemberExport | SymbolOriginInfoKind.Export; moduleSymbol: Symbol; isDefaultExport: boolean; } + function originIsSymbolMember(origin: SymbolOriginInfo): boolean { + return origin.kind === SymbolOriginInfoKind.SymbolMemberExport || origin.kind === SymbolOriginInfoKind.SymbolMemberNoExport; + } + function originIsExport(origin: SymbolOriginInfo): origin is SymbolOriginInfoExport { + return origin.kind === SymbolOriginInfoKind.SymbolMemberExport || origin.kind === SymbolOriginInfoKind.Export; + } + /** * Map from symbol id -> SymbolOriginInfo. * Only populated for symbols that come from other modules. @@ -103,20 +111,22 @@ namespace ts.Completions { function completionInfoFromData(sourceFile: SourceFile, typeChecker: TypeChecker, compilerOptions: CompilerOptions, log: Log, completionData: CompletionData, preferences: UserPreferences): CompletionInfo | undefined { const { symbols, completionKind, isInSnippetScope, isNewIdentifierLocation, location, propertyAccessToConvert, keywordFilters, literals, symbolToOriginInfoMap, recommendedCompletion, isJsxInitializer } = completionData; - if (sourceFile.languageVariant === LanguageVariant.JSX && location && location.parent && isJsxClosingElement(location.parent)) { + if (location && location.parent && isJsxClosingElement(location.parent)) { // 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: - // var x =
- // The completion list at "1" will contain "div" with type any + // var x =
" with type any + // And at `
` (with a closing `>`), the completion list will contain "div". const tagName = location.parent.parent.openingElement.tagName; - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, - entries: [{ - name: tagName.getFullText(), - kind: ScriptElementKind.classElement, - kindModifiers: undefined, - sortText: "0", - }]}; + const hasClosingAngleBracket = !!findChildOfKind(location.parent, SyntaxKind.GreaterThanToken, sourceFile); + const entry: CompletionEntry = { + name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), + kind: ScriptElementKind.classElement, + kindModifiers: undefined, + sortText: "0", + }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [entry] }; } const entries: CompletionEntry[] = []; @@ -214,12 +224,12 @@ namespace ts.Completions { let insertText: string | undefined; let replacementSpan: TextSpan | undefined; - if (origin && origin.type === "this-type") { + if (origin && origin.kind === SymbolOriginInfoKind.ThisType) { insertText = needsConvertPropertyAccess ? `this[${quote(name, preferences)}]` : `this.${name}`; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. - else if ((origin && origin.type === "symbol-member" || needsConvertPropertyAccess) && propertyAccessToConvert) { + else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { insertText = needsConvertPropertyAccess ? `[${quote(name, preferences)}]` : `[${name}]`; const dot = findChildOfKind(propertyAccessToConvert, SyntaxKind.DotToken, sourceFile)!; // If the text after the '.' starts with this name, write over it. Else, add new text. @@ -253,7 +263,7 @@ namespace ts.Completions { kindModifiers: SymbolDisplay.getSymbolModifiers(symbol), sortText: "0", source: getSourceFromOrigin(origin), - hasAction: trueOrUndefined(!!origin && origin.type === "export"), + hasAction: trueOrUndefined(!!origin && originIsExport(origin)), isRecommended: trueOrUndefined(isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker)), insertText, replacementSpan, @@ -283,7 +293,7 @@ namespace ts.Completions { } function getSourceFromOrigin(origin: SymbolOriginInfo | undefined): string | undefined { - return origin && origin.type === "export" ? stripQuotes(origin.moduleSymbol.name) : undefined; + return origin && originIsExport(origin) ? stripQuotes(origin.moduleSymbol.name) : undefined; } function getCompletionEntriesFromSymbols( @@ -529,7 +539,7 @@ namespace ts.Completions { } function getSymbolName(symbol: Symbol, origin: SymbolOriginInfo | undefined, target: ScriptTarget): string { - return origin && origin.type === "export" && origin.isDefaultExport && symbol.escapedName === InternalSymbolName.Default + return origin && originIsExport(origin) && origin.isDefaultExport && symbol.escapedName === InternalSymbolName.Default // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. ? firstDefined(symbol.declarations, d => isExportAssignment(d) && isIdentifier(d.expression) ? d.expression.text : undefined) || codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) @@ -549,7 +559,6 @@ namespace ts.Completions { entryId: CompletionEntryIdentifier, host: LanguageServiceHost, formatContext: formatting.FormatContext, - getCanonicalFileName: GetCanonicalFileName, preferences: UserPreferences, cancellationToken: CancellationToken, ): CompletionEntryDetails | undefined { @@ -583,7 +592,7 @@ namespace ts.Completions { } case "symbol": { const { symbol, location, symbolToOriginInfoMap, previousToken } = symbolCompletion; - const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, getCanonicalFileName, program.getSourceFiles(), preferences); + const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, previousToken, formatContext, program.getSourceFiles(), preferences); return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location!, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -645,12 +654,11 @@ namespace ts.Completions { sourceFile: SourceFile, previousToken: Node | undefined, formatContext: formatting.FormatContext, - getCanonicalFileName: GetCanonicalFileName, allSourceFiles: ReadonlyArray, preferences: UserPreferences, ): CodeActionsAndSourceDisplay { const symbolOriginInfo = symbolToOriginInfoMap[getSymbolId(symbol)]; - if (!symbolOriginInfo || symbolOriginInfo.type !== "export") { + if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { return { codeActions: undefined, sourceDisplay: undefined }; } @@ -664,10 +672,8 @@ namespace ts.Completions { host, program, checker, - compilerOptions, allSourceFiles, formatContext, - getCanonicalFileName, previousToken, preferences); return { sourceDisplay: [textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -871,7 +877,7 @@ namespace ts.Completions { } start = timestamp(); - const previousToken = findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression)!; // TODO: GH#18217 + const previousToken = findPrecedingToken(position, sourceFile, /*startNode*/ undefined)!; // TODO: GH#18217 log("getCompletionData: Get previous token 1: " + (timestamp() - start)); // The decision to provide completion depends on the contextToken, which is determined through the previousToken. @@ -882,7 +888,7 @@ namespace ts.Completions { // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (isIdentifier(contextToken) || isKeyword(contextToken.kind))) { const start = timestamp(); - contextToken = findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression)!; // TODO: GH#18217 + contextToken = findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined)!; // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (timestamp() - start)); } @@ -915,6 +921,9 @@ namespace ts.Completions { case SyntaxKind.QualifiedName: node = (parent as QualifiedName).left; break; + case SyntaxKind.ModuleDeclaration: + node = (parent as ModuleDeclaration).name; + break; case SyntaxKind.ImportType: case SyntaxKind.MetaProperty: node = parent; @@ -1054,8 +1063,10 @@ namespace ts.Completions { const isImportType = isLiteralImportTypeNode(node); const isTypeLocation = insideJsDocTagTypeExpression || (isImportType && !(node as ImportTypeNode).isTypeOf) || isPartOfTypeNode(node.parent); const isRhsOfImportDeclaration = isInRightSideOfInternalImportEqualsDeclaration(node); - const allowTypeOrValue = isRhsOfImportDeclaration || (!isTypeLocation && isPossiblyTypeArgumentPosition(contextToken, sourceFile)); + const allowTypeOrValue = isRhsOfImportDeclaration || (!isTypeLocation && isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)); if (isEntityName(node) || isImportType) { + const isNamespaceName = isModuleDeclaration(node.parent); + if (isNamespaceName) isNewIdentifierLocation = true; let symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = skipAlias(symbol, typeChecker); @@ -1065,13 +1076,17 @@ namespace ts.Completions { const exportedSymbols = Debug.assertEachDefined(typeChecker.getExportsOfModule(symbol), "getExportsOfModule() should all be defined"); const isValidValueAccess = (symbol: Symbol) => typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); const isValidTypeAccess = (symbol: Symbol) => symbolCanBeReferencedAtTypeLocation(symbol); - const isValidAccess = allowTypeOrValue ? - // Any kind is allowed when dotting off namespace in internal import equals declaration - (symbol: Symbol) => isValidTypeAccess(symbol) || isValidValueAccess(symbol) : - isTypeLocation ? isValidTypeAccess : isValidValueAccess; - for (const symbol of exportedSymbols) { - if (isValidAccess(symbol)) { - symbols.push(symbol); + const isValidAccess: (symbol: Symbol) => boolean = + isNamespaceName + // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. + ? symbol => !!(symbol.flags & SymbolFlags.Namespace) && !symbol.declarations.every(d => d.parent === node.parent) + : allowTypeOrValue ? + // Any kind is allowed when dotting off namespace in internal import equals declaration + symbol => isValidTypeAccess(symbol) || isValidValueAccess(symbol) : + isTypeLocation ? isValidTypeAccess : isValidValueAccess; + for (const exportedSymbol of exportedSymbols) { + if (isValidAccess(exportedSymbol)) { + symbols.push(exportedSymbol); } } @@ -1092,7 +1107,7 @@ namespace ts.Completions { } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)!); + addTypeProperties(typeChecker.getTypeAtLocation(node)); } } @@ -1105,7 +1120,7 @@ namespace ts.Completions { // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part // of the individual types to a higher status since we know what they are. - symbols.push(...getPropertiesForCompletion(type, typeChecker, /*isForAccess*/ true)); + symbols.push(...getPropertiesForCompletion(type, typeChecker)); } else { for (const symbol of type.getApparentProperties()) { @@ -1128,7 +1143,9 @@ namespace ts.Completions { const firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); if (firstAccessibleSymbol && !symbolToOriginInfoMap[getSymbolId(firstAccessibleSymbol)]) { symbols.push(firstAccessibleSymbol); - symbolToOriginInfoMap[getSymbolId(firstAccessibleSymbol)] = { type: "symbol-member" }; + const moduleSymbol = firstAccessibleSymbol.parent; + symbolToOriginInfoMap[getSymbolId(firstAccessibleSymbol)] = + !moduleSymbol || !isExternalModuleSymbol(moduleSymbol) ? { kind: SymbolOriginInfoKind.SymbolMemberNoExport } : { kind: SymbolOriginInfoKind.SymbolMemberExport, moduleSymbol, isDefaultExport: false }; } } else { @@ -1225,8 +1242,8 @@ namespace ts.Completions { if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== SyntaxKind.SourceFile) { const thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { - for (const symbol of getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true)) { - symbolToOriginInfoMap[getSymbolId(symbol)] = { type: "this-type" }; + for (const symbol of getPropertiesForCompletion(thisType, typeChecker)) { + symbolToOriginInfoMap[getSymbolId(symbol)] = { kind: SymbolOriginInfoKind.ThisType }; symbols.push(symbol); } } @@ -1267,7 +1284,7 @@ namespace ts.Completions { function filterGlobalCompletion(symbols: Symbol[]): void { const isTypeOnlyCompletion = insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && (isPartOfTypeNode(location) || isContextTokenTypeLocation(contextToken)); - const allowTypes = isTypeOnlyCompletion || !isContextTokenValueLocation(contextToken) && isPossiblyTypeArgumentPosition(contextToken, sourceFile); + const allowTypes = isTypeOnlyCompletion || !isContextTokenValueLocation(contextToken) && isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker); if (isTypeOnlyCompletion) keywordFilters = KeywordCompletionFilters.TypeKeywords; filterMutate(symbols, symbol => { @@ -1378,7 +1395,7 @@ namespace ts.Completions { symbol = getLocalSymbolForExportDefault(symbol) || symbol; } - const origin: SymbolOriginInfo = { type: "export", moduleSymbol, isDefaultExport }; + const origin: SymbolOriginInfoExport = { kind: SymbolOriginInfoKind.Export, moduleSymbol, isDefaultExport }; if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { symbols.push(symbol); symbolToOriginInfoMap[getSymbolId(symbol)] = origin; @@ -1453,7 +1470,8 @@ namespace ts.Completions { function isNewIdentifierDefinitionLocation(previousToken: Node | undefined): boolean { if (previousToken) { const containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { + // Previous token may have been a keyword that was converted to an identifier. + switch (keywordForNode(previousToken)) { case SyntaxKind.CommaToken: return containingNodeKind === SyntaxKind.CallExpression // func( a, | || containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ @@ -1499,14 +1517,6 @@ namespace ts.Completions { case SyntaxKind.ProtectedKeyword: return containingNodeKind === SyntaxKind.PropertyDeclaration; // class A{ public | } - - // Previous token may have been a keyword that was converted to an identifier. - switch (keywordForNode(previousToken)) { - case SyntaxKind.PublicKeyword: - case SyntaxKind.ProtectedKeyword: - case SyntaxKind.PrivateKeyword: - return true; - } } return false; @@ -1542,7 +1552,7 @@ namespace ts.Completions { const typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return GlobalsSearch.Fail; isNewIdentifierLocation = hasIndexSignature(typeForObject); - typeMembers = getPropertiesForCompletion(typeForObject, typeChecker, /*isForAccess*/ false); + typeMembers = getPropertiesForObjectExpression(typeForObject, objectLikeContainer, typeChecker); existingMembers = objectLikeContainer.properties; } else { @@ -1653,8 +1663,8 @@ namespace ts.Completions { if (!(classElementModifierFlags & ModifierFlags.Private)) { // List of property symbols of base type that are not private and already implemented const baseSymbols = flatMap(getAllSuperTypeNodes(decl), baseTypeNode => { - const type = typeChecker.getTypeAtLocation(baseTypeNode)!; // TODO: GH#18217 - return typeChecker.getPropertiesOfType(classElementModifierFlags & ModifierFlags.Static ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); + const type = typeChecker.getTypeAtLocation(baseTypeNode); + return type && typeChecker.getPropertiesOfType(classElementModifierFlags & ModifierFlags.Static ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); } @@ -2115,7 +2125,7 @@ namespace ts.Completions { case KeywordCompletionFilters.ConstructorParameterKeywords: return isParameterPropertyModifier(kind); case KeywordCompletionFilters.FunctionLikeBodyKeywords: - return !isClassMemberCompletionKeyword(kind); + return isFunctionLikeBodyKeyword(kind); case KeywordCompletionFilters.TypeKeywords: return isTypeKeyword(kind); default: @@ -2141,6 +2151,10 @@ namespace ts.Completions { } } + function isFunctionLikeBodyKeyword(kind: SyntaxKind) { + return kind === SyntaxKind.AsyncKeyword || !isClassMemberCompletionKeyword(kind); + } + function keywordForNode(node: Node): SyntaxKind { return isIdentifier(node) ? node.originalKeywordKind || SyntaxKind.Unknown : node.kind; } @@ -2163,19 +2177,25 @@ namespace ts.Completions { return jsdoc && jsdoc.tags && (rangeContainsPosition(jsdoc, position) ? findLast(jsdoc.tags, tag => tag.pos < position) : undefined); } + function getPropertiesForObjectExpression(contextualType: Type, obj: ObjectLiteralExpression, checker: TypeChecker): Symbol[] { + return contextualType.isUnion() + ? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(memberType => + // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. + !(memberType.flags & TypeFlags.Primitive || + checker.isArrayLikeType(memberType) || + typeHasCallOrConstructSignatures(memberType, checker) || + checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)))) + : contextualType.getApparentProperties(); + } + /** * Gets all properties on a type, but if that type is a union of several types, * excludes array-like types or callable/constructable types. */ - function getPropertiesForCompletion(type: Type, checker: TypeChecker, isForAccess: boolean): Symbol[] { - if (!(type.isUnion())) { - return Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); - } - - // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - const filteredTypes = isForAccess ? type.types : type.types.filter(memberType => - !(memberType.flags & TypeFlags.Primitive || checker.isArrayLikeType(memberType) || typeHasCallOrConstructSignatures(memberType, checker))); - return Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); + function getPropertiesForCompletion(type: Type, checker: TypeChecker): Symbol[] { + return type.isUnion() + ? Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") + : Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } /** diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 53d7a4f7ad17f..a24012cd4e3c1 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -234,7 +234,8 @@ namespace ts.FindAllReferences.Core { export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap = arrayToSet(sourceFiles, f => f.fileName)): SymbolAndEntries[] | undefined { if (isSourceFile(node)) { const reference = GoToDefinition.getReferenceAtPosition(node, position, program); - return reference && getReferencedSymbolsForModule(program, program.getTypeChecker().getMergedSymbol(reference.file.symbol), /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); + const moduleSymbol = reference && program.getTypeChecker().getMergedSymbol(reference.file.symbol); + return moduleSymbol && getReferencedSymbolsForModule(program, moduleSymbol, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } if (!options.implementations) { @@ -498,7 +499,7 @@ namespace ts.FindAllReferences.Core { return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); } - /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ + /** @param allSearchSymbols set of additional symbols for use by `includes`. */ createSearch(location: Node | undefined, symbol: Symbol, comingFrom: ImportExport | undefined, searchOptions: { text?: string, allSearchSymbols?: Symbol[] } = {}): Search { // Note: if this is an external module symbol, the name doesn't include quotes. // Note: getLocalSymbolForExportDefault handles `export default class C {}`, but not `export default C` or `export { C as default }`. @@ -703,7 +704,7 @@ namespace ts.FindAllReferences.Core { - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ const exposedByParent = parent && !(symbol.flags & SymbolFlags.TypeParameter); - if (exposedByParent && !((parent!.flags & SymbolFlags.Module) && isExternalModuleSymbol(parent!) && !parent!.globalExports)) { + if (exposedByParent && !(isExternalModuleSymbol(parent!) && !parent!.globalExports)) { return undefined; } @@ -1023,7 +1024,7 @@ namespace ts.FindAllReferences.Core { function getReferenceForShorthandProperty({ flags, valueDeclaration }: Symbol, search: Search, state: State): void { const shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration)!; - const name = getNameOfDeclaration(valueDeclaration); + const name = valueDeclaration && getNameOfDeclaration(valueDeclaration); /* * 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 @@ -1462,12 +1463,14 @@ namespace ts.FindAllReferences.Core { } /** Gets all symbols for one property. Does not get symbols for every property. */ - function getPropertySymbolsFromContextualType(node: ObjectLiteralElement, checker: TypeChecker): ReadonlyArray { + function getPropertySymbolsFromContextualType(node: ObjectLiteralElementWithName, checker: TypeChecker): ReadonlyArray { const contextualType = checker.getContextualType(node.parent); - const name = getNameFromPropertyName(node.name!); - const symbol = contextualType && name && contextualType.getProperty(name); + if (!contextualType) return emptyArray; + const name = getNameFromPropertyName(node.name); + if (!name) return emptyArray; + const symbol = contextualType.getProperty(name); return symbol ? [symbol] : - contextualType && contextualType.isUnion() ? mapDefined(contextualType.types, t => t.getProperty(name!)) : emptyArray; // TODO: GH#18217 + contextualType.isUnion() ? mapDefined(contextualType.types, t => t.getProperty(name)) : emptyArray; } /** diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 0e37672f66da2..c1de1574e88c8 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -717,7 +717,6 @@ namespace ts.formatting { Debug.assert(isNodeArray(nodes)); const listStartToken = getOpenTokenForList(parent, nodes); - const listEndToken = getCloseTokenForOpenToken(listStartToken); let listDynamicIndentation = parentDynamicIndentation; let startLine = parentStartLine; @@ -752,17 +751,21 @@ namespace ts.formatting { inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } - if (listEndToken !== SyntaxKind.Unknown) { - if (formattingScanner.isOnToken()) { - const tokenInfo = formattingScanner.readTokenInfo(parent); - // consume the list end token only if it is still belong to the parent - // there might be the case when current token matches end token but does not considered as one - // function (x: function) <-- - // without this check close paren will be interpreted as list end token for function expression which is wrong - if (tokenInfo.token.kind === listEndToken && rangeContainsRange(parent, tokenInfo.token)) { - // consume list end token - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); - } + const listEndToken = getCloseTokenForOpenToken(listStartToken); + if (listEndToken !== SyntaxKind.Unknown && formattingScanner.isOnToken()) { + let tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.kind === SyntaxKind.CommaToken && isCallLikeExpression(parent)) { + formattingScanner.advance(); + tokenInfo = formattingScanner.readTokenInfo(parent); + } + + // consume the list end token only if it is still belong to the parent + // there might be the case when current token matches end token but does not considered as one + // function (x: function) <-- + // without this check close paren will be interpreted as list end token for function expression which is wrong + if (tokenInfo.token.kind === listEndToken && rangeContainsRange(parent, tokenInfo.token)) { + // consume list end token + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); } } } @@ -975,7 +978,6 @@ namespace ts.formatting { // split comment in lines let startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; const endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; - let parts: TextRange[]; if (startLine === endLine) { if (!firstLineIsIndented) { // treat as single line comment @@ -983,20 +985,21 @@ namespace ts.formatting { } return; } - else { - parts = []; - let startPos = commentRange.pos; - for (let line = startLine; line < endLine; line++) { - const endOfLine = getEndLinePosition(line, sourceFile); - parts.push({ pos: startPos, end: endOfLine }); - startPos = getStartPositionOfLine(line + 1, sourceFile); - } - if (indentFinalLine) { - parts.push({ pos: startPos, end: commentRange.end }); - } + const parts: TextRange[] = []; + let startPos = commentRange.pos; + for (let line = startLine; line < endLine; line++) { + const endOfLine = getEndLinePosition(line, sourceFile); + parts.push({ pos: startPos, end: endOfLine }); + startPos = getStartPositionOfLine(line + 1, sourceFile); + } + + if (indentFinalLine) { + parts.push({ pos: startPos, end: commentRange.end }); } + if (parts.length === 0) return; + const startLinePos = getStartPositionOfLine(startLine, sourceFile); const nonWhitespaceColumnInFirstPart = @@ -1146,10 +1149,9 @@ namespace ts.formatting { export function getRangeOfEnclosingComment( sourceFile: SourceFile, position: number, - onlyMultiLine: boolean, precedingToken?: Node | null, // tslint:disable-line:no-null-keyword tokenAtPosition = getTokenAtPosition(sourceFile, position), - predicate?: (c: CommentRange) => boolean): CommentRange | undefined { + ): CommentRange | undefined { const jsdoc = findAncestor(tokenAtPosition, isJSDoc); if (jsdoc) tokenAtPosition = jsdoc.parent; const tokenStart = tokenAtPosition.getStart(sourceFile); @@ -1157,39 +1159,28 @@ namespace ts.formatting { return undefined; } - if (precedingToken === undefined) { - precedingToken = findPrecedingToken(position, sourceFile); - } + precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). const trailingRangesOfPreviousToken = precedingToken && getTrailingCommentRanges(sourceFile.text, precedingToken.end); const leadingCommentRangesOfNextToken = getLeadingCommentRangesOfNode(tokenAtPosition, sourceFile); - const commentRanges = trailingRangesOfPreviousToken && leadingCommentRangesOfNextToken ? - trailingRangesOfPreviousToken.concat(leadingCommentRangesOfNextToken) : - trailingRangesOfPreviousToken || leadingCommentRangesOfNextToken; - if (commentRanges) { - for (const range of commentRanges) { - // The end marker of a single-line comment does not include the newline character. - // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): - // - // // asdf ^\n - // - // But for closed multi-line comments, we don't want to be inside the comment in the following case: - // - // /* asdf */^ - // - // However, unterminated multi-line comments *do* contain their end. - // - // Internally, we represent the end of the comment at the newline and closing '/', respectively. - // - if ((range.pos < position && position < range.end || - position === range.end && (range.kind === SyntaxKind.SingleLineCommentTrivia || position === sourceFile.getFullWidth()))) { - return (range.kind === SyntaxKind.MultiLineCommentTrivia || !onlyMultiLine) && (!predicate || predicate(range)) ? range : undefined; - } - } - } - return undefined; + const commentRanges = concatenate(trailingRangesOfPreviousToken, leadingCommentRangesOfNextToken); + return commentRanges && find(commentRanges, range => rangeContainsPositionExclusive(range, position) || + // The end marker of a single-line comment does not include the newline character. + // With caret at `^`, in the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for closed multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // However, unterminated multi-line comments *do* contain their end. + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + // + position === range.end && (range.kind === SyntaxKind.SingleLineCommentTrivia || position === sourceFile.getFullWidth())); } function getOpenTokenForList(node: Node, list: ReadonlyArray) { diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 8602347244fbf..b506dd5269ff9 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -32,10 +32,10 @@ namespace ts.formatting { return 0; } - const precedingToken = findPrecedingToken(position, sourceFile); + const precedingToken = findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword - if (enclosingCommentRange) { + const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + if (enclosingCommentRange && enclosingCommentRange.kind === SyntaxKind.MultiLineCommentTrivia) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -351,7 +351,10 @@ namespace ts.formatting { getListIfStartEndIsInListRange((node.parent).parameters, start, end); } case SyntaxKind.ClassDeclaration: - return getListIfStartEndIsInListRange((node.parent).typeParameters, node.getStart(sourceFile), end); + case SyntaxKind.ClassExpression: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.TypeAliasDeclaration: + return getListIfStartEndIsInListRange((node.parent).typeParameters, node.getStart(sourceFile), end); case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: { const start = node.getStart(sourceFile); @@ -576,17 +579,10 @@ namespace ts.formatting { function isControlFlowEndingStatement(kind: SyntaxKind, parent: TextRangeWithKind): boolean { switch (kind) { case SyntaxKind.ReturnStatement: - case SyntaxKind.ThrowStatement: { - if (parent.kind !== SyntaxKind.Block) { - return true; - } - const grandParent = (parent as Node).parent; - // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === SyntaxKind.FunctionExpression || grandParent.kind === SyntaxKind.FunctionDeclaration); - } + case SyntaxKind.ThrowStatement: case SyntaxKind.ContinueStatement: case SyntaxKind.BreakStatement: - return true; + return parent.kind !== SyntaxKind.Block; default: return false; } diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index 43a0589536ca3..75dd608e6c475 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -1,10 +1,18 @@ /* @internal */ namespace ts { - export function getEditsForFileRename(program: Program, oldFileOrDirPath: string, newFileOrDirPath: string, host: LanguageServiceHost, formatContext: formatting.FormatContext, preferences: UserPreferences): ReadonlyArray { + export function getEditsForFileRename( + program: Program, + oldFileOrDirPath: string, + newFileOrDirPath: string, + host: LanguageServiceHost, + formatContext: formatting.FormatContext, + preferences: UserPreferences, + sourceMapper: SourceMapper, + ): ReadonlyArray { const useCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames(host); const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); - const oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName); - const newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName); + const oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); + const newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); return textChanges.ChangeTracker.with({ host, formatContext }, changeTracker => { updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences); @@ -14,13 +22,27 @@ namespace ts { /** If 'path' refers to an old directory, returns path in the new directory. */ type PathUpdater = (path: string) => string | undefined; // exported for tests - export function getPathUpdater(oldFileOrDirPath: string, newFileOrDirPath: string, getCanonicalFileName: GetCanonicalFileName): PathUpdater { + export function getPathUpdater(oldFileOrDirPath: string, newFileOrDirPath: string, getCanonicalFileName: GetCanonicalFileName, sourceMapper: SourceMapper | undefined): PathUpdater { const canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); return path => { - if (getCanonicalFileName(path) === canonicalOldPath) return newFileOrDirPath; - const suffix = tryRemoveDirectoryPrefix(path, canonicalOldPath, getCanonicalFileName); - return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; + const originalPath = sourceMapper && sourceMapper.tryGetOriginalLocation({ fileName: path, position: 0 }); + const updatedPath = getUpdatedPath(originalPath ? originalPath.fileName : path); + return originalPath + ? updatedPath === undefined ? undefined : makeCorrespondingRelativeChange(originalPath.fileName, updatedPath, path, getCanonicalFileName) + : updatedPath; }; + + function getUpdatedPath(pathToUpdate: string): string | undefined { + if (getCanonicalFileName(pathToUpdate) === canonicalOldPath) return newFileOrDirPath; + const suffix = tryRemoveDirectoryPrefix(pathToUpdate, canonicalOldPath, getCanonicalFileName); + return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; + } + } + + // Relative path from a0 to b0 should be same as relative path from a1 to b1. Returns b1. + function makeCorrespondingRelativeChange(a0: string, b0: string, a1: string, getCanonicalFileName: GetCanonicalFileName): string { + const rel = getRelativePathFromFile(a0, b0, getCanonicalFileName); + return combinePathsSafe(getDirectoryPath(a1), rel); } function updateTsconfigFiles(program: Program, changeTracker: textChanges.ChangeTracker, oldToNew: PathUpdater, newFileOrDirPath: string, currentDirectory: string, useCaseSensitiveFileNames: boolean): void { @@ -104,8 +126,8 @@ namespace ts { ): void { const allFiles = program.getSourceFiles(); for (const sourceFile of allFiles) { - const newFromOld = oldToNew(sourceFile.fileName); - const newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.fileName; + const newFromOld = oldToNew(sourceFile.path) as Path; + const newImportFromPath = newFromOld !== undefined ? newFromOld : sourceFile.path; const newImportFromDirectory = getDirectoryPath(newImportFromPath); const oldFromNew: string | undefined = newToOld(sourceFile.fileName); @@ -129,7 +151,7 @@ namespace ts { const toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. // TODO:GH#18217 - ? getSourceFileToImportFromResolved(resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host as ModuleResolutionHost), oldToNew, program) + ? getSourceFileToImportFromResolved(resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host as ModuleResolutionHost), oldToNew, host) : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew); // Need an update if the imported file moved, or the importing file moved and was using a relative path. @@ -170,18 +192,18 @@ namespace ts { const resolved = host.resolveModuleNames ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName) : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName); - return getSourceFileToImportFromResolved(resolved, oldToNew, program); + return getSourceFileToImportFromResolved(resolved, oldToNew, host); } } - function getSourceFileToImportFromResolved(resolved: ResolvedModuleWithFailedLookupLocations | undefined, oldToNew: PathUpdater, program: Program): ToImport | undefined { + function getSourceFileToImportFromResolved(resolved: ResolvedModuleWithFailedLookupLocations | undefined, oldToNew: PathUpdater, host: LanguageServiceHost): ToImport | undefined { return resolved && ( - (resolved.resolvedModule && getIfInProgram(resolved.resolvedModule.resolvedFileName)) || firstDefined(resolved.failedLookupLocations, getIfInProgram)); + (resolved.resolvedModule && getIfExists(resolved.resolvedModule.resolvedFileName)) || firstDefined(resolved.failedLookupLocations, getIfExists)); - function getIfInProgram(oldLocation: string): ToImport | undefined { + function getIfExists(oldLocation: string): ToImport | undefined { const newLocation = oldToNew(oldLocation); - return program.getSourceFile(oldLocation) || newLocation !== undefined && program.getSourceFile(newLocation) + return host.fileExists!(oldLocation) || newLocation !== undefined && host.fileExists!(newLocation) // TODO: GH#18217 ? newLocation !== undefined ? { newFileName: newLocation, updated: true } : { newFileName: oldLocation, updated: false } : undefined; } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 7060ffad6121e..1d0112630108a 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -28,7 +28,8 @@ namespace ts.GoToDefinition { } const calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); - if (calledDeclaration) { + // Don't go to the component constructor definition for a JSX element, just go to the component definition. + if (calledDeclaration && !(isJsxOpeningLikeElement(node.parent) && isConstructorDeclaration(calledDeclaration))) { const sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); // For a function, if this is the original function definition, return just sigInfo. // If this is the original constructor definition, parent is the class. @@ -170,7 +171,7 @@ namespace ts.GoToDefinition { // At 'x.foo', see if the type of 'x' has an index signature, and if so find its declarations. function getDefinitionInfoForIndexSignatures(node: Node, checker: TypeChecker): DefinitionInfo[] | undefined { if (!isPropertyAccessExpression(node.parent) || node.parent.name !== node) return; - const type = checker.getTypeAtLocation(node.parent.expression)!; + const type = checker.getTypeAtLocation(node.parent.expression); return mapDefined(type.isUnionOrIntersection() ? type.types : [type], nonUnionType => { const info = checker.getIndexInfoOfType(nonUnionType, IndexKind.String); return info && info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration); @@ -271,7 +272,7 @@ namespace ts.GoToDefinition { } export function findReferenceInPosition(refs: ReadonlyArray, pos: number): FileReference | undefined { - return find(refs, ref => ref.pos <= pos && pos <= ref.end); + return find(refs, ref => textRangeContainsPositionInclusive(ref, pos)); } function getDefinitionInfoForFileReference(name: string, targetFileName: string): DefinitionInfo { diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 1b6f21ac64097..23fe3e63a9db9 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -1,48 +1,83 @@ /* @internal */ namespace ts.JsDoc { const jsDocTagNames = [ + "abstract", + "access", + "alias", + "argument", + "async", "augments", "author", - "argument", "borrows", "callback", "class", + "classdesc", "constant", "constructor", "constructs", + "copyright", "default", "deprecated", "description", + "emits", + "enum", "event", "example", + "exports", "extends", + "external", "field", - "fileOverview", + "file", + "fileoverview", + "fires", "function", + "generator", + "global", + "hideconstructor", + "host", "ignore", - "inheritDoc", + "implements", + "inheritdoc", "inner", + "instance", + "interface", + "kind", "lends", - "link", - "memberOf", + "license", + "listens", + "member", + "memberof", "method", + "mixes", + "module", "name", "namespace", + "override", + "package", "param", "private", - "prop", "property", + "protected", "public", + "readonly", "requires", "returns", "see", "since", "static", + "summary", "template", + "this", "throws", + "todo", + "tutorial", "type", "typedef", - "version" + "var", + "variation", + "version", + "virtual", + "yields" ]; let jsDocTagNameCompletionEntries: CompletionEntry[]; let jsDocTagCompletionEntries: CompletionEntry[]; @@ -303,50 +338,54 @@ namespace ts.JsDoc { readonly parameters?: ReadonlyArray; } function getCommentOwnerInfo(tokenAtPos: Node): CommentOwnerInfo | undefined { - for (let commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.FunctionExpression: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.Constructor: - case SyntaxKind.MethodSignature: - const { parameters } = commentOwner as FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature; - return { commentOwner, parameters }; - - case SyntaxKind.ClassDeclaration: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.EnumDeclaration: - case SyntaxKind.EnumMember: - case SyntaxKind.TypeAliasDeclaration: - return { commentOwner }; - - case SyntaxKind.VariableStatement: { - const varStatement = commentOwner; - const varDeclarations = varStatement.declarationList.declarations; - const parameters = varDeclarations.length === 1 && varDeclarations[0].initializer - ? getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer!) - : undefined; - return { commentOwner, parameters }; - } + return forEachAncestor(tokenAtPos, getCommentOwnerInfoWorker); + } + function getCommentOwnerInfoWorker(commentOwner: Node): CommentOwnerInfo | undefined | "quit" { + switch (commentOwner.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.Constructor: + case SyntaxKind.MethodSignature: + const { parameters } = commentOwner as FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature; + return { commentOwner, parameters }; + + case SyntaxKind.PropertyAssignment: + return getCommentOwnerInfoWorker((commentOwner as PropertyAssignment).initializer); + + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.EnumMember: + case SyntaxKind.TypeAliasDeclaration: + return { commentOwner }; + + case SyntaxKind.VariableStatement: { + const varStatement = commentOwner; + const varDeclarations = varStatement.declarationList.declarations; + const parameters = varDeclarations.length === 1 && varDeclarations[0].initializer + ? getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer!) + : undefined; + return { commentOwner, parameters }; + } - case SyntaxKind.SourceFile: - return undefined; + case SyntaxKind.SourceFile: + return "quit"; - case SyntaxKind.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 { }'. - return commentOwner.parent.kind === SyntaxKind.ModuleDeclaration ? undefined : { commentOwner }; + case SyntaxKind.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 { }'. + return commentOwner.parent.kind === SyntaxKind.ModuleDeclaration ? undefined : { commentOwner }; - case SyntaxKind.BinaryExpression: { - const be = commentOwner as BinaryExpression; - if (getSpecialPropertyAssignmentKind(be) === SpecialPropertyAssignmentKind.None) { - return undefined; - } - const parameters = isFunctionLike(be.right) ? be.right.parameters : emptyArray; - return { commentOwner, parameters }; + case SyntaxKind.BinaryExpression: { + const be = commentOwner as BinaryExpression; + if (getSpecialPropertyAssignmentKind(be) === SpecialPropertyAssignmentKind.None) { + return "quit"; } + const parameters = isFunctionLike(be.right) ? be.right.parameters : emptyArray; + return { commentOwner, parameters }; } } } diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index dc03c736f3c23..00a9a9d4f3b9d 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -1,23 +1,23 @@ /* @internal */ namespace ts.NavigateTo { interface RawNavigateToItem { - name: string; - fileName: string; - matchKind: PatternMatchKind; - isCaseSensitive: boolean; - declaration: Declaration; + readonly name: string; + readonly fileName: string; + readonly matchKind: PatternMatchKind; + readonly isCaseSensitive: boolean; + readonly declaration: Declaration; } export function getNavigateToItems(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number | undefined, excludeDtsFiles: boolean): NavigateToItem[] { const patternMatcher = createPatternMatcher(searchValue); if (!patternMatcher) return emptyArray; - let rawItems: RawNavigateToItem[] = []; + const rawItems: RawNavigateToItem[] = []; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - if (excludeDtsFiles && fileExtensionIs(sourceFile.fileName, Extension.Dts)) { + if (excludeDtsFiles && sourceFile.isDeclarationFile) { continue; } @@ -27,10 +27,7 @@ namespace ts.NavigateTo { } rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - return rawItems.map(createNavigateToItem); + return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: ReadonlyArray, checker: TypeChecker, fileName: string, rawItems: Push): void { @@ -45,13 +42,13 @@ namespace ts.NavigateTo { if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - const fullMatch = patternMatcher.getFullMatch(getContainers(declaration)!, name); // TODO: GH#18217 + // If the pattern has dots in it, then also see if the declaration container matches as well. + const fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); if (fullMatch) { rawItems.push({ name, fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration }); } } else { - // If the pattern has dots in it, then also see if the declaration container matches as well. rawItems.push({ name, fileName, matchKind: match.kind, isCaseSensitive: match.isCaseSensitive, declaration }); } } @@ -62,7 +59,7 @@ namespace ts.NavigateTo { case SyntaxKind.ImportClause: case SyntaxKind.ImportSpecifier: case SyntaxKind.ImportEqualsDeclaration: - const importer = checker.getSymbolAtLocation((declaration as ImportClause | ImportSpecifier | ImportEqualsDeclaration).name!)!; + const importer = checker.getSymbolAtLocation((declaration as ImportClause | ImportSpecifier | ImportEqualsDeclaration).name!)!; // TODO: GH#18217 const imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; default: @@ -107,14 +104,14 @@ namespace ts.NavigateTo { return false; } - function getContainers(declaration: Declaration): string[] | undefined { + function getContainers(declaration: Declaration): ReadonlyArray { const containers: string[] = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. const name = getNameOfDeclaration(declaration); if (name && name.kind === SyntaxKind.ComputedPropertyName && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; + return emptyArray; } // Now, walk up our containers, adding all their names to the container array. @@ -122,7 +119,7 @@ namespace ts.NavigateTo { while (container) { if (!tryAddSingleDeclarationName(container, containers)) { - return undefined; + return emptyArray; } container = getContainerNode(container); @@ -145,13 +142,13 @@ namespace ts.NavigateTo { name: rawItem.name, kind: getNodeKind(declaration), kindModifiers: getNodeModifiers(declaration), - matchKind: PatternMatchKind[rawItem.matchKind], + matchKind: PatternMatchKind[rawItem.matchKind] as keyof typeof PatternMatchKind, isCaseSensitive: rawItem.isCaseSensitive, fileName: rawItem.fileName, textSpan: createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? (containerName).text : "", - containerKind: containerName ? getNodeKind(container!) : ScriptElementKind.unknown // TODO: GH#18217 Just use `container ? ...` + containerKind: containerName ? getNodeKind(container!) : ScriptElementKind.unknown, // TODO: GH#18217 Just use `container ? ...` }; } } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index d97004b80c572..b4c7c5a2c24c1 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -133,7 +133,7 @@ namespace ts.NavigationBar { /** Call after calling `startNode` and adding children to it. */ function endNode(): void { if (parent.children) { - mergeChildren(parent.children); + mergeChildren(parent.children, parent); sortChildren(parent.children); } parent = parentsStack.pop()!; @@ -188,7 +188,7 @@ namespace ts.NavigationBar { // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addLeafNode(importClause); + addLeafNode(importClause.name); } // Handle named bindings in imports e.g.: @@ -304,7 +304,7 @@ namespace ts.NavigationBar { } /** Merge declarations of the same kind. */ - function mergeChildren(children: NavigationBarNode[]): void { + function mergeChildren(children: NavigationBarNode[], node: NavigationBarNode): void { const nameToItems = createMap(); filterMutate(children, child => { const declName = getNameOfDeclaration(child.node); @@ -322,7 +322,7 @@ namespace ts.NavigationBar { if (itemsWithSameName instanceof Array) { for (const itemWithSameName of itemsWithSameName) { - if (tryMerge(itemWithSameName, child)) { + if (tryMerge(itemWithSameName, child, node)) { return false; } } @@ -331,7 +331,7 @@ namespace ts.NavigationBar { } else { const itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child)) { + if (tryMerge(itemWithSameName, child, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -340,8 +340,8 @@ namespace ts.NavigationBar { }); } - function tryMerge(a: NavigationBarNode, b: NavigationBarNode): boolean { - if (shouldReallyMerge(a.node, b.node)) { + function tryMerge(a: NavigationBarNode, b: NavigationBarNode, parent: NavigationBarNode): boolean { + if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; } @@ -349,8 +349,8 @@ namespace ts.NavigationBar { } /** a and b have the same name, but they may not be mergeable. */ - function shouldReallyMerge(a: Node, b: Node): boolean { - if (a.kind !== b.kind) { + function shouldReallyMerge(a: Node, b: Node, parent: NavigationBarNode): boolean { + if (a.kind !== b.kind || a.parent !== b.parent && !(isOwnChild(a, parent) && isOwnChild(b, parent))) { return false; } switch (a.kind) { @@ -366,6 +366,13 @@ namespace ts.NavigationBar { } } + // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` + // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` + function isOwnChild(n: Node, parent: NavigationBarNode): boolean { + const par = isModuleBlock(n.parent) ? n.parent.parent : n.parent; + return par === parent.node || contains(parent.additionalNodes, par); + } + // 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: ModuleDeclaration, b: ModuleDeclaration): boolean { @@ -383,7 +390,7 @@ namespace ts.NavigationBar { target.children = concatenate(target.children, source.children); if (target.children) { - mergeChildren(target.children); + mergeChildren(target.children, target); sortChildren(target.children); } } diff --git a/src/services/organizeImports.ts b/src/services/organizeImports.ts index 7e4affb14aa6b..460cb3dd5a282 100644 --- a/src/services/organizeImports.ts +++ b/src/services/organizeImports.ts @@ -63,10 +63,7 @@ namespace ts.OrganizeImports { // Delete or replace the first import. if (newImportDecls.length === 0) { - changeTracker.deleteNode(sourceFile, oldImportDecls[0], { - useNonAdjustedStartPosition: true, // Leave header comment in place - useNonAdjustedEndPosition: false, - }); + changeTracker.delete(sourceFile, oldImportDecls[0]); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. @@ -79,7 +76,7 @@ namespace ts.OrganizeImports { // Delete any subsequent imports. for (let i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + changeTracker.delete(sourceFile, oldImportDecls[i]); } } } diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 91754e2ac769b..9d2c61a1a7d2c 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -63,7 +63,7 @@ namespace ts.OutliningElementsCollector { const currentLineStart = lineStarts[i]; const lineEnd = i + 1 === lineStarts.length ? sourceFile.getEnd() : lineStarts[i + 1] - 1; const lineText = sourceFile.text.substring(currentLineStart, lineEnd); - const result = lineText.match(/^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/); + const result = isRegionDelimiter(lineText); if (!result || isInComment(sourceFile, currentLineStart)) { continue; } @@ -83,16 +83,30 @@ namespace ts.OutliningElementsCollector { } } + const regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + function isRegionDelimiter(lineText: string) { + return regionDelimiterRegExp.exec(lineText); + } + function addOutliningForLeadingCommentsForNode(n: Node, sourceFile: SourceFile, cancellationToken: CancellationToken, out: Push): void { const comments = getLeadingCommentRangesOfNode(n, sourceFile); if (!comments) return; let firstSingleLineCommentStart = -1; let lastSingleLineCommentEnd = -1; let singleLineCommentCount = 0; + const sourceText = sourceFile.getFullText(); for (const { kind, pos, end } of comments) { cancellationToken.throwIfCancellationRequested(); switch (kind) { case SyntaxKind.SingleLineCommentTrivia: + // never fold region delimiters into single-line comment regions + const commentText = sourceText.slice(pos, end); + if (isRegionDelimiter(commentText)) { + combineAndAddMultipleSingleLineComments(); + singleLineCommentCount = 0; + break; + } + // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (singleLineCommentCount === 0) { @@ -169,6 +183,26 @@ namespace ts.OutliningElementsCollector { return spanForObjectOrArrayLiteral(n); case SyntaxKind.ArrayLiteralExpression: return spanForObjectOrArrayLiteral(n, SyntaxKind.OpenBracketToken); + case SyntaxKind.JsxElement: + return spanForJSXElement(n); + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.JsxOpeningElement: + return spanForJSXAttributes((n).attributes); + } + + function spanForJSXElement(node: JsxElement): OutliningSpan | undefined { + const textSpan = createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); + const tagName = node.openingElement.tagName.getText(sourceFile); + const bannerText = "<" + tagName + ">..."; + return createOutliningSpan(textSpan, OutliningSpanKind.Code, textSpan, /*autoCollapse*/ false, bannerText); + } + + function spanForJSXAttributes(node: JsxAttributes): OutliningSpan | undefined { + if (node.properties.length === 0) { + return undefined; + } + + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), OutliningSpanKind.Code); } function spanForObjectOrArrayLiteral(node: Node, open: SyntaxKind.OpenBraceToken | SyntaxKind.OpenBracketToken = SyntaxKind.OpenBraceToken): OutliningSpan | undefined { diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index 1b71eee0eaf25..f81900e28e75e 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -124,8 +124,6 @@ namespace ts { return undefined; } - candidateContainers = candidateContainers || []; - // -1 because the last part was checked against the name, and only the rest // of the parts are checked against the container. if (dotSeparatedSegments.length - 1 > candidateContainers.length) { diff --git a/src/services/refactors/convertExport.ts b/src/services/refactors/convertExport.ts index 9ce9fcf264b47..ca31ef5810044 100644 --- a/src/services/refactors/convertExport.ts +++ b/src/services/refactors/convertExport.ts @@ -78,7 +78,7 @@ namespace ts.refactor { function changeExport(exportingSourceFile: SourceFile, { wasDefault, exportNode, exportName }: Info, changes: textChanges.ChangeTracker, checker: TypeChecker): void { if (wasDefault) { - changes.deleteNode(exportingSourceFile, Debug.assertDefined(findModifier(exportNode, SyntaxKind.DefaultKeyword))); + changes.delete(exportingSourceFile, Debug.assertDefined(findModifier(exportNode, SyntaxKind.DefaultKeyword))); } else { const exportKeyword = Debug.assertDefined(findModifier(exportNode, SyntaxKind.ExportKeyword)); @@ -155,7 +155,7 @@ namespace ts.refactor { } else { // `import foo, { bar } from "./a"` --> `import { bar, foo } from "./a";` - changes.deleteNode(importingSourceFile, ref); + changes.delete(importingSourceFile, ref); changes.insertNodeAtEndOfList(importingSourceFile, namedBindings.elements, spec); } break; @@ -183,7 +183,7 @@ namespace ts.refactor { changes.replaceNode(importingSourceFile, spec.parent, defaultImport); } else { - changes.deleteNodeInList(importingSourceFile, spec); + changes.delete(importingSourceFile, spec); changes.insertNodeBefore(importingSourceFile, spec.parent, defaultImport); } } diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index ade704e36404b..653d9d0c59edf 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -866,7 +866,7 @@ namespace ts.refactor.extractSymbol { // Being returned through an object literal will have widened the type. const variableType: TypeNode | undefined = checker.typeToTypeNode( - checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)!), // TODO: GH#18217 + checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, NodeBuilderFlags.NoTruncation); @@ -1090,7 +1090,7 @@ namespace ts.refactor.extractSymbol { // Consume if (node.parent.kind === SyntaxKind.ExpressionStatement) { // If the parent is an expression statement, delete it. - changeTracker.deleteNode(context.file, node.parent, textChanges.useNonAdjustedPositions); + changeTracker.delete(context.file, node.parent); } else { const localReference = createIdentifier(localNameText); @@ -1406,7 +1406,7 @@ namespace ts.refactor.extractSymbol { const end = last(statements).end; expressionDiagnostic = createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression)!.flags & (TypeFlags.Void | TypeFlags.Never)) { // TODO: GH#18217 + else if (checker.getTypeAtLocation(expression).flags & (TypeFlags.Void | TypeFlags.Never)) { expressionDiagnostic = createDiagnosticForNode(expression, Messages.uselessConstantType); } @@ -1555,7 +1555,7 @@ namespace ts.refactor.extractSymbol { function collectUsages(node: Node, valueUsage = Usage.Read) { if (inGenericContext) { - const type = checker.getTypeAtLocation(node)!; // TODO: GH#18217 + const type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); } diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts index f050e8fb174f7..b10f2969906cb 100644 --- a/src/services/refactors/moveToNewFile.ts +++ b/src/services/refactors/moveToNewFile.ts @@ -325,7 +325,7 @@ namespace ts.refactor { break; case SyntaxKind.ImportEqualsDeclaration: if (isUnused(importDecl.name)) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } break; case SyntaxKind.VariableDeclaration: @@ -342,19 +342,19 @@ namespace ts.refactor { const namedBindingsUnused = !namedBindings || (namedBindings.kind === SyntaxKind.NamespaceImport ? isUnused(namedBindings.name) : namedBindings.elements.every(e => isUnused(e.name))); if (defaultUnused && namedBindingsUnused) { - changes.deleteNode(sourceFile, importDecl); + changes.delete(sourceFile, importDecl); } else { if (name && defaultUnused) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } if (namedBindings) { if (namedBindingsUnused) { - changes.deleteNode(sourceFile, namedBindings); + changes.delete(sourceFile, namedBindings); } else if (namedBindings.kind === SyntaxKind.NamedImports) { for (const element of namedBindings.elements) { - if (isUnused(element.name)) changes.deleteNodeInList(sourceFile, element); + if (isUnused(element.name)) changes.delete(sourceFile, element); } } } @@ -365,20 +365,20 @@ namespace ts.refactor { switch (name.kind) { case SyntaxKind.Identifier: if (isUnused(name)) { - changes.deleteNode(sourceFile, name); + changes.delete(sourceFile, name); } break; case SyntaxKind.ArrayBindingPattern: break; case SyntaxKind.ObjectBindingPattern: if (name.elements.every(e => isIdentifier(e.name) && isUnused(e.name))) { - changes.deleteNode(sourceFile, + changes.delete(sourceFile, isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } else { for (const element of name.elements) { if (isIdentifier(element.name) && isUnused(element.name)) { - changes.deleteNode(sourceFile, element.name); + changes.delete(sourceFile, element.name); } } } diff --git a/src/services/rename.ts b/src/services/rename.ts index cd557f5aaa47e..1f498d9771653 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -1,22 +1,11 @@ /* @internal */ namespace ts.Rename { - export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: GetCanonicalFileName, sourceFile: SourceFile, position: number): RenameInfo { - const getCanonicalDefaultLibName = memoize(() => getCanonicalFileName(normalizePath(defaultLibFileName))); + export function getRenameInfo(program: Program, sourceFile: SourceFile, position: number): RenameInfo { const node = getTouchingPropertyName(sourceFile, position); const renameInfo = node && nodeIsEligibleForRename(node) - ? getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) + ? getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, declaration => program.isSourceFileDefaultLibrary(declaration.getSourceFile())) : undefined; return renameInfo || getRenameInfoError(Diagnostics.You_cannot_rename_this_element); - - function isDefinedInLibraryFile(declaration: Node) { - if (!defaultLibFileName) { - return false; - } - - const sourceFile = declaration.getSourceFile(); - const canonicalName = getCanonicalFileName(normalizePath(sourceFile.fileName)); - return canonicalName === getCanonicalDefaultLibName(); - } } function getRenameInfoForNode(node: Node, typeChecker: TypeChecker, sourceFile: SourceFile, isDefinedInLibraryFile: (declaration: Node) => boolean): RenameInfo | undefined { diff --git a/src/services/services.ts b/src/services/services.ts index 9e23d29f6d7df..ad39eb84a3445 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -633,7 +633,7 @@ namespace ts { private computeNamedDeclarations(): Map { const result = createMultiMap(); - forEachChild(this, visit); + this.forEachChild(visit); return result; @@ -653,7 +653,7 @@ namespace ts { } function getDeclarationName(declaration: Declaration) { - const name = getNameOfDeclaration(declaration); + const name = getNonAssignedNameOfDeclaration(declaration); return name && (isComputedPropertyName(name) && isPropertyAccessExpression(name.expression) ? name.expression.name.text : isPropertyName(name) ? getNameFromPropertyName(name) : undefined); } @@ -742,7 +742,7 @@ namespace ts { // Handle default import case e.g.: // import d from "mod"; if (importClause.name) { - addDeclaration(importClause); + addDeclaration(importClause.name); } // Handle named bindings in imports e.g.: @@ -1129,8 +1129,6 @@ namespace ts { localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } - let sourcemappedFileCache: SourceFileLikeCache; - function log(message: string) { if (host.log) { host.log(message); @@ -1140,6 +1138,8 @@ namespace ts { const useCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames(host); const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); + const sourceMapper = getSourceMapper(getCanonicalFileName, currentDirectory, log, host, () => program); + function getValidSourceFile(fileName: string): SourceFile { const sourceFile = program.getSourceFile(fileName); if (!sourceFile) { @@ -1251,7 +1251,7 @@ namespace ts { // We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above, // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during // the course of whatever called `synchronizeHostData` - sourcemappedFileCache = createSourceFileLikeCache(host); + sourceMapper.clearCache(); // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. @@ -1396,7 +1396,7 @@ namespace ts { return [...program.getOptionsDiagnostics(cancellationToken), ...program.getGlobalDiagnostics(cancellationToken)]; } - function getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions = defaultPreferences): CompletionInfo | undefined { + function getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions = emptyOptions): CompletionInfo | undefined { // Convert from deprecated options names to new names const fullPreferences: UserPreferences = { ...identity(options), // avoid excess property check @@ -1414,7 +1414,7 @@ namespace ts { options.triggerCharacter); } - function getCompletionEntryDetails(fileName: string, position: number, name: string, formattingOptions: FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences = defaultPreferences): CompletionEntryDetails | undefined { + function getCompletionEntryDetails(fileName: string, position: number, name: string, formattingOptions: FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences = emptyOptions): CompletionEntryDetails | undefined { synchronizeHostData(); return Completions.getCompletionEntryDetails( program, @@ -1424,7 +1424,6 @@ namespace ts { { name, source }, host, (formattingOptions && formatting.getFormatContext(formattingOptions))!, // TODO: GH#18217 - getCanonicalFileName, preferences, cancellationToken, ); @@ -1449,32 +1448,15 @@ namespace ts { const symbol = getSymbolAtLocationForQuickInfo(node, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { - // Try getting just type at this position and show - switch (node.kind) { - case SyntaxKind.Identifier: - if (isLabelName(node)) { - // Type here will be 'any', avoid displaying this. - return undefined; - } - // falls through - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.QualifiedName: - case SyntaxKind.ThisKeyword: - case SyntaxKind.ThisType: - case SyntaxKind.SuperKeyword: - // For the identifiers/this/super etc get the type at position - const type = typeChecker.getTypeAtLocation(node); - return type && { - kind: ScriptElementKind.unknown, - kindModifiers: ScriptElementKindModifier.none, - textSpan: createTextSpanFromNode(node, sourceFile), - displayParts: typeChecker.runWithCancellationToken(cancellationToken, typeChecker => typeToDisplayParts(typeChecker, type, getContainerNode(node))), - documentation: type.symbol ? type.symbol.getDocumentationComment(typeChecker) : undefined, - tags: type.symbol ? type.symbol.getJsDocTags() : undefined - }; - } - - return undefined; + const type = shouldGetType(sourceFile, node, position) ? typeChecker.getTypeAtLocation(node) : undefined; + return type && { + kind: ScriptElementKind.unknown, + kindModifiers: ScriptElementKindModifier.none, + textSpan: createTextSpanFromNode(node, sourceFile), + displayParts: typeChecker.runWithCancellationToken(cancellationToken, typeChecker => typeToDisplayParts(typeChecker, type, getContainerNode(node))), + documentation: type.symbol ? type.symbol.getDocumentationComment(typeChecker) : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined + }; } const { symbolKind, displayParts, documentation, tags } = typeChecker.runWithCancellationToken(cancellationToken, typeChecker => @@ -1490,6 +1472,23 @@ namespace ts { }; } + function shouldGetType(sourceFile: SourceFile, node: Node, position: number): boolean { + switch (node.kind) { + case SyntaxKind.Identifier: + return !isLabelName(node); + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.QualifiedName: + // Don't return quickInfo if inside the comment in `a/**/.b` + return !isInComment(sourceFile, position); + case SyntaxKind.ThisKeyword: + case SyntaxKind.ThisType: + case SyntaxKind.SuperKeyword: + return true; + default: + return false; + } + } + function getSymbolAtLocationForQuickInfo(node: Node, checker: TypeChecker): Symbol | undefined { if ((isIdentifier(node) || isStringLiteral(node)) && isPropertyAssignment(node.parent) @@ -1503,178 +1502,27 @@ namespace ts { return checker.getSymbolAtLocation(node); } - function toLineColumnOffset(fileName: string, position: number) { - const path = toPath(fileName, currentDirectory, getCanonicalFileName); - const file = program.getSourceFile(path) || sourcemappedFileCache.get(path)!; // TODO: GH#18217 - return file.getLineAndCharacterOfPosition(position); - } - - // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm; - const base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; - function scanForSourcemapURL(fileName: string) { - const mappedFile = sourcemappedFileCache.get(toPath(fileName, currentDirectory, getCanonicalFileName)); - if (!mappedFile) { - return; - } - const starts = getLineStarts(mappedFile); - for (let index = starts.length - 1; index >= 0; index--) { - sourceMapCommentRegExp.lastIndex = starts[index]; - const comment = sourceMapCommentRegExp.exec(mappedFile.text); - if (comment) { - return comment[1]; - } - } - } - - function convertDocumentToSourceMapper(file: { sourceMapper?: sourcemaps.SourceMapper }, contents: string, mapFileName: string) { - let maps: sourcemaps.SourceMapData | undefined; - try { - maps = JSON.parse(contents); - } - catch { - // swallow error - } - if (!maps || !maps.sources || !maps.file || !maps.mappings) { - // obviously invalid map - return file.sourceMapper = sourcemaps.identitySourceMapper; - } - return file.sourceMapper = sourcemaps.decode({ - readFile: s => host.readFile!(s), // TODO: GH#18217 - fileExists: s => host.fileExists!(s), // TODO: GH#18217 - getCanonicalFileName, - log, - }, mapFileName, maps, program, sourcemappedFileCache); - } - - function getSourceMapper(fileName: string, file: { sourceMapper?: sourcemaps.SourceMapper }) { - if (!host.readFile || !host.fileExists) { - return file.sourceMapper = sourcemaps.identitySourceMapper; - } - if (file.sourceMapper) { - return file.sourceMapper; - } - let mapFileName = scanForSourcemapURL(fileName); - if (mapFileName) { - const match = base64UrlRegExp.exec(mapFileName); - if (match) { - if (match[1]) { - const base64Object = match[1]; - return convertDocumentToSourceMapper(file, base64decode(sys, base64Object), fileName); - } - // Not a data URL we can parse, skip it - mapFileName = undefined; - } - } - const possibleMapLocations: string[] = []; - if (mapFileName) { - possibleMapLocations.push(mapFileName); - } - possibleMapLocations.push(fileName + ".map"); - for (const location of possibleMapLocations) { - const mapPath = toPath(location, getDirectoryPath(fileName), getCanonicalFileName); - if (host.fileExists(mapPath)) { - return convertDocumentToSourceMapper(file, host.readFile(mapPath)!, mapPath); // TODO: GH#18217 - } - } - return file.sourceMapper = sourcemaps.identitySourceMapper; - } - - function makeGetTargetOfMappedPosition( - extract: (original: TIn) => sourcemaps.SourceMappableLocation, - create: (result: sourcemaps.SourceMappableLocation, unmapped: TIn, original: TIn) => TIn - ) { - return getTargetOfMappedPosition; - function getTargetOfMappedPosition(input: TIn, original = input): TIn { - const info = extract(input); - if (endsWith(info.fileName, Extension.Dts)) { - let file: SourceFileLike | undefined = program.getSourceFile(info.fileName); - if (!file) { - const path = toPath(info.fileName, currentDirectory, getCanonicalFileName); - file = sourcemappedFileCache.get(path); - } - if (!file) { - return input; - } - const mapper = getSourceMapper(info.fileName, file); - const newLoc = mapper.getOriginalPosition(info); - if (newLoc === info) return input; - return getTargetOfMappedPosition(create(newLoc, input, original), original); - } - return input; - } - } - - const getTargetOfMappedDeclarationInfo = makeGetTargetOfMappedPosition( - (info: DefinitionInfo) => ({ fileName: info.fileName, position: info.textSpan.start }), - (newLoc, info, original) => ({ - containerKind: info.containerKind, - containerName: info.containerName, - fileName: newLoc.fileName, - kind: info.kind, - name: info.name, - textSpan: { - start: newLoc.position, - length: info.textSpan.length - }, - originalFileName: original.fileName, - originalTextSpan: original.textSpan - }) - ); - - function getTargetOfMappedDeclarationFiles(infos: ReadonlyArray | undefined): DefinitionInfo[] | undefined { - return map(infos, d => getTargetOfMappedDeclarationInfo(d)); - } - /// Goto definition function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined { synchronizeHostData(); - return getTargetOfMappedDeclarationFiles(GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position)); + return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); } function getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined { synchronizeHostData(); - const result = GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position); - if (!result) return result; - const mappedDefs = getTargetOfMappedDeclarationFiles(result.definitions); - if (mappedDefs === result.definitions) { - return result; - } - return { - definitions: mappedDefs, - textSpan: result.textSpan - }; + return GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position); } function getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined { synchronizeHostData(); - return getTargetOfMappedDeclarationFiles(GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position)); + return GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); } /// Goto implementation - const getTargetOfMappedImplementationLocation = makeGetTargetOfMappedPosition( - (info: ImplementationLocation) => ({ fileName: info.fileName, position: info.textSpan.start }), - (newLoc, info) => ({ - fileName: newLoc.fileName, - kind: info.kind, - displayParts: info.displayParts, - textSpan: { - start: newLoc.position, - length: info.textSpan.length - }, - originalFileName: info.fileName, - originalTextSpan: info.textSpan - }) - ); - - function getTargetOfMappedImplementationLocations(infos: ReadonlyArray | undefined): ImplementationLocation[] | undefined { - return map(infos, d => getTargetOfMappedImplementationLocation(d)); - } - function getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] | undefined { synchronizeHostData(); - return getTargetOfMappedImplementationLocations(FindAllReferences.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position)); + return FindAllReferences.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } /// References and Occurrences @@ -1689,7 +1537,8 @@ namespace ts { } function getDocumentHighlights(fileName: string, position: number, filesToSearch: ReadonlyArray): DocumentHighlights[] | undefined { - Debug.assert(filesToSearch.some(f => normalizePath(f) === fileName)); + const normalizedFileName = normalizePath(fileName); + Debug.assert(filesToSearch.some(f => normalizePath(f) === normalizedFileName)); synchronizeHostData(); const sourceFilesToSearch = map(filesToSearch, f => Debug.assertDefined(program.getSourceFile(f))); const sourceFile = getValidSourceFile(fileName); @@ -1731,10 +1580,8 @@ namespace ts { return FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } - /// NavigateTo function getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles = false): NavigateToItem[] { synchronizeHostData(); - const sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } @@ -1751,12 +1598,12 @@ namespace ts { /** * This is a semantic operation. */ - function getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined { + function getSignatureHelpItems(fileName: string, position: number, { triggerReason }: SignatureHelpItemsOptions = emptyOptions): SignatureHelpItems | undefined { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); - return SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + return SignatureHelp.getSignatureHelpItems(program, sourceFile, position, triggerReason, cancellationToken); } /// Syntactic features @@ -1935,7 +1782,7 @@ namespace ts { return []; } - function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences = defaultPreferences): ReadonlyArray { + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): ReadonlyArray { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const span = createTextSpanFromBounds(start, end); @@ -1947,7 +1794,7 @@ namespace ts { }); } - function getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences = defaultPreferences): CombinedCodeActions { + function getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): CombinedCodeActions { synchronizeHostData(); Debug.assert(scope.type === "file"); const sourceFile = getValidSourceFile(scope.fileName); @@ -1956,7 +1803,7 @@ namespace ts { return codefix.getAllFixes({ fixId, sourceFile, program, host, cancellationToken, formatContext, preferences }); } - function organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences = defaultPreferences): ReadonlyArray { + function organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): ReadonlyArray { synchronizeHostData(); Debug.assert(scope.type === "file"); const sourceFile = getValidSourceFile(scope.fileName); @@ -1965,8 +1812,8 @@ namespace ts { return OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } - function getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences = defaultPreferences): ReadonlyArray { - return ts.getEditsForFileRename(getProgram()!, oldFilePath, newFilePath, host, formatting.getFormatContext(formatOptions), preferences); + function getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences = emptyOptions): ReadonlyArray { + return ts.getEditsForFileRename(getProgram()!, oldFilePath, newFilePath, host, formatting.getFormatContext(formatOptions), preferences, sourceMapper); } function applyCodeActionCommand(action: CodeActionCommand): Promise; @@ -2037,15 +1884,20 @@ namespace ts { if (!token) return undefined; const element = token.kind === SyntaxKind.GreaterThanToken && isJsxOpeningElement(token.parent) ? token.parent.parent : isJsxText(token) ? token.parent : undefined; - if (element && !tagNamesAreEquivalent(element.openingElement.tagName, element.closingElement.tagName)) { + if (element && isUnclosedTag(element)) { return { newText: `` }; } } + function isUnclosedTag({ openingElement, closingElement, parent }: JsxElement): boolean { + return !tagNamesAreEquivalent(openingElement.tagName, closingElement.tagName) || + isJsxElement(parent) && tagNamesAreEquivalent(openingElement.tagName, parent.openingElement.tagName) && isUnclosedTag(parent); + } + function getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined { const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - const range = formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); - return range && createTextSpanFromRange(range); + const range = formatting.getRangeOfEnclosingComment(sourceFile, position); + return range && (!onlyMultiLine || range.kind === SyntaxKind.MultiLineCommentTrivia) ? createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { @@ -2197,8 +2049,7 @@ namespace ts { function getRenameInfo(fileName: string, position: number): RenameInfo { synchronizeHostData(); - const defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - return Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); + return Rename.getRenameInfo(program, getValidSourceFile(fileName), position); } function getRefactorContext(file: SourceFile, positionOrRange: number | TextRange, preferences: UserPreferences, formatOptions?: FormatCodeSettings): RefactorContext { @@ -2215,7 +2066,7 @@ namespace ts { }; } - function getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences = defaultPreferences): ApplicableRefactorInfo[] { + function getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences = emptyOptions): ApplicableRefactorInfo[] { synchronizeHostData(); const file = getValidSourceFile(fileName); return refactor.getApplicableRefactors(getRefactorContext(file, positionOrRange, preferences)); @@ -2227,7 +2078,7 @@ namespace ts { positionOrRange: number | TextRange, refactorName: string, actionName: string, - preferences: UserPreferences = defaultPreferences, + preferences: UserPreferences = emptyOptions, ): RefactorEditInfo | undefined { synchronizeHostData(); const file = getValidSourceFile(fileName); @@ -2286,7 +2137,8 @@ namespace ts { getProgram, getApplicableRefactors, getEditsForRefactor, - toLineColumnOffset + toLineColumnOffset: sourceMapper.toLineColumnOffset, + getSourceMapper: () => sourceMapper, }; } @@ -2334,21 +2186,23 @@ namespace ts { * 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 | undefined { + export function getContainingObjectLiteralElement(node: Node): ObjectLiteralElementWithName | undefined { switch (node.kind) { case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: if (node.parent.kind === SyntaxKind.ComputedPropertyName) { - return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; + return isObjectLiteralElement(node.parent.parent) ? node.parent.parent as ObjectLiteralElementWithName : undefined; } // falls 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 : undefined; + node.parent.name === node ? node.parent as ObjectLiteralElementWithName : undefined; } return undefined; } + /* @internal */ + export type ObjectLiteralElementWithName = ObjectLiteralElement & { name: PropertyName }; /* @internal */ export function getPropertySymbolsFromContextualType(typeChecker: TypeChecker, node: ObjectLiteralElement): Symbol[] { diff --git a/src/services/shims.ts b/src/services/shims.ts index 0ea27b4151f79..a467414303321 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -102,7 +102,7 @@ namespace ts { readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; /** - * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules + * Read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules */ readFile(fileName: string): string | undefined; realpath?(path: string): string; @@ -158,7 +158,7 @@ namespace ts { getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string; getBreakpointStatementAtPosition(fileName: string, position: number): string; - getSignatureHelpItems(fileName: string, position: number): string; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): string; /** * Returns a JSON-encoded value of the type: @@ -769,10 +769,10 @@ namespace ts { /// SIGNATUREHELP - public getSignatureHelpItems(fileName: string, position: number): string { + public getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): string { return this.forwardJSONCall( `getSignatureHelpItems('${fileName}', ${position})`, - () => this.languageService.getSignatureHelpItems(fileName, position) + () => this.languageService.getSignatureHelpItems(fileName, position, options) ); } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index ac13a2c790447..ec5eddf9e166e 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -19,7 +19,7 @@ namespace ts.SignatureHelp { argumentCount: number; } - export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems | undefined { + export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, triggerReason: SignatureHelpTriggerReason | undefined, cancellationToken: CancellationToken): SignatureHelpItems | undefined { const typeChecker = program.getTypeChecker(); // Decide whether to show signature help @@ -29,13 +29,23 @@ namespace ts.SignatureHelp { return undefined; } + // Only need to be careful if the user typed a character and signature help wasn't showing. + const shouldCarefullyCheckContext = !!triggerReason && triggerReason.kind === "characterTyped"; + + // Bail out quickly in the middle of a string or comment, don't provide signature help unless the user explicitly requested it. + if (shouldCarefullyCheckContext) { + if (isInString(sourceFile, position, startingToken) || isInComment(sourceFile, position)) { + return undefined; + } + } + const argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); if (!argumentInfo) return undefined; cancellationToken.throwIfCancellationRequested(); - // Semantic filtering of signature help - const candidateInfo = getCandidateInfo(argumentInfo, typeChecker); + // Extra syntactic and semantic filtering of signature help + const candidateInfo = getCandidateInfo(argumentInfo, typeChecker, sourceFile, startingToken, shouldCarefullyCheckContext); cancellationToken.throwIfCancellationRequested(); if (!candidateInfo) { @@ -50,19 +60,55 @@ namespace ts.SignatureHelp { return typeChecker.runWithCancellationToken(cancellationToken, typeChecker => createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker)); } - function getCandidateInfo(argumentInfo: ArgumentListInfo, checker: TypeChecker): { readonly candidates: ReadonlyArray, readonly resolvedSignature: Signature } | undefined { + function getCandidateInfo( + argumentInfo: ArgumentListInfo, checker: TypeChecker, sourceFile: SourceFile, startingToken: Node, onlyUseSyntacticOwners: boolean): + { readonly candidates: ReadonlyArray, readonly resolvedSignature: Signature } | undefined { + const { invocation } = argumentInfo; if (invocation.kind === InvocationKind.Call) { + if (onlyUseSyntacticOwners) { + if (isCallOrNewExpression(invocation.node)) { + const invocationChildren = invocation.node.getChildren(sourceFile); + switch (startingToken.kind) { + case SyntaxKind.OpenParenToken: + if (!contains(invocationChildren, startingToken)) { + return undefined; + } + break; + case SyntaxKind.CommaToken: + const containingList = findContainingList(startingToken); + if (!containingList || !contains(invocationChildren, findContainingList(startingToken))) { + return undefined; + } + break; + case SyntaxKind.LessThanToken: + if (!lessThanFollowsCalledExpression(startingToken, sourceFile, invocation.node.expression)) { + return undefined; + } + break; + default: + return undefined; + } + } + else { + return undefined; + } + } + const candidates: Signature[] = []; const resolvedSignature = checker.getResolvedSignature(invocation.node, candidates, argumentInfo.argumentCount)!; // TODO: GH#18217 return candidates.length === 0 ? undefined : { candidates, resolvedSignature }; } - else { - const type = checker.getTypeAtLocation(invocation.called)!; // TODO: GH#18217 - const signatures = isNewExpression(invocation.called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); - const candidates = signatures.filter(candidate => !!candidate.typeParameters && candidate.typeParameters.length >= argumentInfo.argumentCount); + else if (invocation.kind === InvocationKind.TypeArgs) { + if (onlyUseSyntacticOwners && !lessThanFollowsCalledExpression(startingToken, sourceFile, invocation.called)) { + return undefined; + } + const candidates = getPossibleGenericSignatures(invocation.called, argumentInfo.argumentCount, checker); return candidates.length === 0 ? undefined : { candidates, resolvedSignature: first(candidates) }; } + else { + Debug.assertNever(invocation); + } } function createJavaScriptSignatureHelpItems(argumentInfo: ArgumentListInfo, program: Program, cancellationToken: CancellationToken): SignatureHelpItems | undefined { @@ -95,6 +141,14 @@ namespace ts.SignatureHelp { } } + function lessThanFollowsCalledExpression(startingToken: Node, sourceFile: SourceFile, calledExpression: Expression) { + const precedingToken = Debug.assertDefined( + findPrecedingToken(startingToken.getFullStart(), sourceFile, startingToken.parent, /*excludeJsdoc*/ true) + ); + + return rangeContainsRange(calledExpression, precedingToken); + } + export interface ArgumentInfoForCompletions { readonly invocation: CallLikeExpression; readonly argumentIndex: number; @@ -205,7 +259,7 @@ namespace ts.SignatureHelp { }; } else { - const typeArgInfo = isPossiblyTypeArgumentPosition(node, sourceFile); + const typeArgInfo = getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { const { called, nTypeArguments } = typeArgInfo; const invocation: Invocation = { kind: InvocationKind.TypeArgs, called }; diff --git a/src/services/sourcemaps.ts b/src/services/sourcemaps.ts new file mode 100644 index 0000000000000..1833c415be4d1 --- /dev/null +++ b/src/services/sourcemaps.ts @@ -0,0 +1,130 @@ +/* @internal */ +namespace ts { + // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) + const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + const whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; + const base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/; + + export interface SourceMapper { + toLineColumnOffset(fileName: string, position: number): LineAndCharacter; + tryGetOriginalLocation(info: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined; + tryGetGeneratedLocation(info: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined; + clearCache(): void; + } + + export function getSourceMapper( + getCanonicalFileName: GetCanonicalFileName, + currentDirectory: string, + log: (message: string) => void, + host: LanguageServiceHost, + getProgram: () => Program, + ): SourceMapper { + let sourcemappedFileCache: SourceFileLikeCache; + return { tryGetOriginalLocation, tryGetGeneratedLocation, toLineColumnOffset, clearCache }; + + function scanForSourcemapURL(fileName: string) { + const mappedFile = sourcemappedFileCache.get(toPath(fileName, currentDirectory, getCanonicalFileName)); + if (!mappedFile) { + return; + } + const starts = getLineStarts(mappedFile); + for (let index = starts.length - 1; index >= 0; index--) { + const lineText = mappedFile.text.substring(starts[index], starts[index + 1]); + const comment = sourceMapCommentRegExp.exec(lineText); + if (comment) { + return comment[1]; + } + // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file + else if (!lineText.match(whitespaceOrMapCommentRegExp)) { + break; + } + } + } + + function convertDocumentToSourceMapper(file: { sourceMapper?: sourcemaps.SourceMapper }, contents: string, mapFileName: string) { + let maps: sourcemaps.SourceMapData | undefined; + try { + maps = JSON.parse(contents); + } + catch { + // swallow error + } + if (!maps || !maps.sources || !maps.file || !maps.mappings) { + // obviously invalid map + return file.sourceMapper = sourcemaps.identitySourceMapper; + } + return file.sourceMapper = sourcemaps.decode({ + readFile: s => host.readFile!(s), // TODO: GH#18217 + fileExists: s => host.fileExists!(s), // TODO: GH#18217 + getCanonicalFileName, + log, + }, mapFileName, maps, getProgram(), sourcemappedFileCache); + } + + function getSourceMapper(fileName: string, file: SourceFileLike): sourcemaps.SourceMapper { + if (!host.readFile || !host.fileExists) { + return file.sourceMapper = sourcemaps.identitySourceMapper; + } + if (file.sourceMapper) { + return file.sourceMapper; + } + let mapFileName = scanForSourcemapURL(fileName); + if (mapFileName) { + const match = base64UrlRegExp.exec(mapFileName); + if (match) { + if (match[1]) { + const base64Object = match[1]; + return convertDocumentToSourceMapper(file, base64decode(sys, base64Object), fileName); + } + // Not a data URL we can parse, skip it + mapFileName = undefined; + } + } + const possibleMapLocations: string[] = []; + if (mapFileName) { + possibleMapLocations.push(mapFileName); + } + possibleMapLocations.push(fileName + ".map"); + for (const location of possibleMapLocations) { + const mapPath = toPath(location, getDirectoryPath(fileName), getCanonicalFileName); + if (host.fileExists(mapPath)) { + return convertDocumentToSourceMapper(file, host.readFile(mapPath)!, mapPath); // TODO: GH#18217 + } + } + return file.sourceMapper = sourcemaps.identitySourceMapper; + } + + function tryGetOriginalLocation(info: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined { + if (!isDeclarationFileName(info.fileName)) return undefined; + + const file = getFile(info.fileName); + if (!file) return undefined; + const newLoc = getSourceMapper(info.fileName, file).getOriginalPosition(info); + return newLoc === info ? undefined : tryGetOriginalLocation(newLoc) || newLoc; + } + + function tryGetGeneratedLocation(info: sourcemaps.SourceMappableLocation): sourcemaps.SourceMappableLocation | undefined { + const program = getProgram(); + const declarationPath = getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); + if (declarationPath === undefined) return undefined; + const declarationFile = getFile(declarationPath); + if (!declarationFile) return undefined; + const newLoc = getSourceMapper(declarationPath, declarationFile).getGeneratedPosition(info); + return newLoc === info ? undefined : newLoc; + } + + function getFile(fileName: string): SourceFileLike | undefined { + return getProgram().getSourceFile(fileName) || sourcemappedFileCache.get(toPath(fileName, currentDirectory, getCanonicalFileName)); + } + + function toLineColumnOffset(fileName: string, position: number): LineAndCharacter { + const path = toPath(fileName, currentDirectory, getCanonicalFileName); + const file = getProgram().getSourceFile(path) || sourcemappedFileCache.get(path)!; // TODO: GH#18217 + return file.getLineAndCharacterOfPosition(position); + } + + function clearCache(): void { + sourcemappedFileCache = createSourceFileLikeCache(host); + } + } +} diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 5eb26dc21d6a9..611bb26bf1e3b 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -49,7 +49,7 @@ namespace ts.SymbolDisplay { if (isFirstDeclarationOfSymbolParameter(symbol)) { return ScriptElementKind.parameterElement; } - else if (symbol.valueDeclaration && isConst(symbol.valueDeclaration)) { + else if (symbol.valueDeclaration && isVarConst(symbol.valueDeclaration as VariableDeclaration)) { return ScriptElementKind.constElement; } else if (forEach(symbol.declarations, isLet)) { @@ -172,7 +172,7 @@ namespace ts.SymbolDisplay { const useConstructSignatures = callExpressionLike.kind === SyntaxKind.NewExpression || (isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === SyntaxKind.SuperKeyword); - const allSignatures = useConstructSignatures ? type!.getConstructSignatures() : type!.getCallSignatures(); + const allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -184,7 +184,7 @@ namespace ts.SymbolDisplay { if (useConstructSignatures && (symbolFlags & SymbolFlags.Class)) { // Constructor symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type!.symbol, symbolKind); + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else if (symbolFlags & SymbolFlags.Alias) { symbolKind = ScriptElementKind.alias; @@ -211,8 +211,8 @@ namespace ts.SymbolDisplay { // If it is call or construct signature of lambda's write type name displayParts.push(punctuationPart(SyntaxKind.ColonToken)); displayParts.push(spacePart()); - if (!(getObjectFlags(type!) & ObjectFlags.Anonymous) && type!.symbol) { - addRange(displayParts, symbolToDisplayParts(typeChecker, type!.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.AllowAnyNodeKind | SymbolFormatFlags.WriteTypeParametersOrArguments)); + if (!(getObjectFlags(type) & ObjectFlags.Anonymous) && type.symbol) { + addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.AllowAnyNodeKind | SymbolFormatFlags.WriteTypeParametersOrArguments)); displayParts.push(lineBreakPart()); } if (useConstructSignatures) { @@ -238,7 +238,7 @@ namespace ts.SymbolDisplay { declaration === (location.kind === SyntaxKind.ConstructorKeyword ? functionDeclaration.parent : functionDeclaration)); if (locationIsSymbolDeclaration) { - const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type!.getNonNullableType().getConstructSignatures() : type!.getNonNullableType().getCallSignatures(); + const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration)!; // TODO: GH#18217 } @@ -249,12 +249,12 @@ namespace ts.SymbolDisplay { if (functionDeclaration.kind === SyntaxKind.Constructor) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type!.symbol, symbolKind); + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) addPrefixForAnyFunctionOrVar(functionDeclaration.kind === SyntaxKind.CallSignature && - !(type!.symbol.flags & SymbolFlags.TypeLiteral || type!.symbol.flags & SymbolFlags.ObjectLiteral) ? type!.symbol : symbol, symbolKind); + !(type.symbol.flags & SymbolFlags.TypeLiteral || type.symbol.flags & SymbolFlags.ObjectLiteral) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -298,7 +298,7 @@ namespace ts.SymbolDisplay { } if (symbolFlags & SymbolFlags.Enum) { prefixNextMeaning(); - if (forEach(symbol.declarations, isConstEnumDeclaration)) { + if (some(symbol.declarations, d => isEnumDeclaration(d) && isEnumConst(d))) { displayParts.push(keywordPart(SyntaxKind.ConstKeyword)); displayParts.push(spacePart()); } diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 2dff610d07d43..959f190d47401 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -212,9 +212,8 @@ namespace ts.textChanges { export class ChangeTracker { private readonly changes: Change[] = []; private readonly newFiles: { readonly oldFile: SourceFile, readonly fileName: string, readonly statements: ReadonlyArray }[] = []; - private readonly deletedNodesInLists = new NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. private readonly classesWithNodesInsertedAtStart = createMap(); // Set implemented as Map - private readonly deletedDeclarations: { readonly sourceFile: SourceFile, readonly node: Node }[] = []; + private readonly deletedNodes: { readonly sourceFile: SourceFile, readonly node: Node }[] = []; public static fromContext(context: TextChangesContext): ChangeTracker { return new ChangeTracker(getNewLineOrDefaultFromHost(context.host, context.formatContext.options), context.formatContext); @@ -234,16 +233,8 @@ namespace ts.textChanges { return this; } - deleteDeclaration(sourceFile: SourceFile, node: Node): void { - this.deletedDeclarations.push({ sourceFile, node }); - } - - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - public deleteNode(sourceFile: SourceFile, node: Node, options: ConfigurableStartEnd = {}) { - const startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); - const endPosition = getAdjustedEndPosition(sourceFile, node, options); - this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); - return this; + delete(sourceFile: SourceFile, node: Node): void { + this.deletedNodes.push({ sourceFile, node, }); } public deleteModifier(sourceFile: SourceFile, modifier: Modifier): void { @@ -263,32 +254,6 @@ namespace ts.textChanges { this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); } - public deleteNodeInList(sourceFile: SourceFile, node: Node) { - const containingList = formatting.SmartIndenter.getContainingList(node, sourceFile); - if (!containingList) { - Debug.fail("node is not a list element"); - return this; - } - const index = indexOfNode(containingList, node); - if (index < 0) { - return this; - } - if (containingList.length === 1) { - this.deleteNode(sourceFile, node); - return this; - } - - // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. - // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. - Debug.assert(!this.deletedNodesInLists.has(node), "Deleting a node twice"); - this.deletedNodesInLists.add(node); - this.deleteRange(sourceFile, { - pos: startPositionToDeleteNodeInList(sourceFile, node), - end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), - }); - return this; - } - public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: InsertNodeOptions = {}) { this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile, range, options, node: newNode }); return this; @@ -325,7 +290,7 @@ namespace ts.textChanges { return this.replaceNode(sourceFile, oldNode, newNode, { suffix }); } - private insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) { + public insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) { this.replaceRange(sourceFile, createTextRange(pos), newNode, options); } @@ -513,6 +478,7 @@ namespace ts.textChanges { case SyntaxKind.VariableDeclaration: case SyntaxKind.StringLiteral: + case SyntaxKind.Identifier: return { prefix: ", " }; case SyntaxKind.PropertyAssignment: @@ -538,7 +504,7 @@ namespace ts.textChanges { if (lparen) { // `() => {}` --> `function f() {}` this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [createToken(SyntaxKind.FunctionKeyword), createIdentifier(name)], { joiner: " " }); - this.deleteNode(sourceFile, arrow); + deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` @@ -691,27 +657,26 @@ namespace ts.textChanges { }); } - private finishTrailingCommaAfterDeletingNodesInList() { - this.deletedNodesInLists.forEach(node => { + private finishDeleteDeclarations(): void { + const deletedNodesInLists = new NodeSet(); // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + for (const { sourceFile, node } of this.deletedNodes) { + if (!this.deletedNodes.some(d => d.sourceFile === sourceFile && rangeContainsRangeExclusive(d.node, node))) { + deleteDeclaration.deleteDeclaration(this, deletedNodesInLists, sourceFile, node); + } + } + + deletedNodesInLists.forEach(node => { const sourceFile = node.getSourceFile(); const list = formatting.SmartIndenter.getContainingList(node, sourceFile)!; if (node !== last(list)) return; - const lastNonDeletedIndex = findLastIndex(list, n => !this.deletedNodesInLists.has(n), list.length - 2); + const lastNonDeletedIndex = findLastIndex(list, n => !deletedNodesInLists.has(n), list.length - 2); if (lastNonDeletedIndex !== -1) { this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) }); } }); } - private finishDeleteDeclarations(): void { - for (const { sourceFile, node } of this.deletedDeclarations) { - if (!this.deletedDeclarations.some(d => d.sourceFile === sourceFile && rangeContainsRangeExclusive(d.node, node))) { - deleteDeclaration.deleteDeclaration(this, sourceFile, node); - } - } - } - /** * Note: after calling this, the TextChanges object must be discarded! * @param validate only for tests @@ -721,7 +686,6 @@ namespace ts.textChanges { public getChanges(validate?: ValidateNonFormattedText): FileTextChanges[] { this.finishDeleteDeclarations(); this.finishClassesWithNodesInsertedAtStart(); - this.finishTrailingCommaAfterDeletingNodesInList(); const changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); for (const { oldFile, fileName, statements } of this.newFiles) { changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter, this.formatContext)); @@ -1037,7 +1001,7 @@ namespace ts.textChanges { } namespace deleteDeclaration { - export function deleteDeclaration(changes: ChangeTracker, sourceFile: SourceFile, node: Node): void { + export function deleteDeclaration(changes: ChangeTracker, deletedNodesInLists: NodeSet, sourceFile: SourceFile, node: Node): void { switch (node.kind) { case SyntaxKind.Parameter: { const oldFunction = node.parent; @@ -1062,43 +1026,56 @@ namespace ts.textChanges { changes.replaceNode(sourceFile, oldFunction, newFunction); } else { - changes.deleteNodeInList(sourceFile, node); + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; } case SyntaxKind.ImportDeclaration: - changes.deleteNode(sourceFile, node); + deleteNode(changes, sourceFile, node, + // For first import, leave header comment in place + node === sourceFile.imports[0].parent ? { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: false } : undefined); break; case SyntaxKind.BindingElement: const pattern = (node as BindingElement).parent; const preserveComma = pattern.kind === SyntaxKind.ArrayBindingPattern && node !== last(pattern.elements); if (preserveComma) { - changes.deleteNode(sourceFile, node); + deleteNode(changes, sourceFile, node); } else { - changes.deleteNodeInList(sourceFile, node); + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; case SyntaxKind.VariableDeclaration: - deleteVariableDeclaration(changes, sourceFile, node as VariableDeclaration); + deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node as VariableDeclaration); break; case SyntaxKind.TypeParameter: { - const typeParameters = getEffectiveTypeParameterDeclarations(node.parent); - if (typeParameters.length === 1) { - const { pos, end } = cast(typeParameters, isNodeArray); - const previousToken = getTokenAtPosition(sourceFile, pos - 1); - const nextToken = getTokenAtPosition(sourceFile, end); - Debug.assert(previousToken.kind === SyntaxKind.LessThanToken); - Debug.assert(nextToken.kind === SyntaxKind.GreaterThanToken); - - changes.deleteNodeRange(sourceFile, previousToken, nextToken); - } - else { - changes.deleteNodeInList(sourceFile, node); + const typeParam = node as TypeParameterDeclaration; + switch (typeParam.parent.kind) { + case SyntaxKind.JSDocTemplateTag: + changes.deleteRange(sourceFile, getRangeToDeleteJsDocTag(typeParam.parent, sourceFile)); + break; + case SyntaxKind.InferType: + // TODO: GH#25594 + break; + default: { + const typeParameters = getEffectiveTypeParameterDeclarations(typeParam.parent); + if (typeParameters.length === 1) { + const { pos, end } = cast(typeParameters, isNodeArray); + const previousToken = getTokenAtPosition(sourceFile, pos - 1); + const nextToken = getTokenAtPosition(sourceFile, end); + Debug.assert(previousToken.kind === SyntaxKind.LessThanToken); + Debug.assert(nextToken.kind === SyntaxKind.GreaterThanToken); + + changes.deleteNodeRange(sourceFile, previousToken, nextToken); + } + else { + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); + } + } } break; } @@ -1109,7 +1086,7 @@ namespace ts.textChanges { deleteImportBinding(changes, sourceFile, namedImports); } else { - changes.deleteNodeInList(sourceFile, node); + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; @@ -1122,10 +1099,10 @@ namespace ts.textChanges { deleteDefaultImport(changes, sourceFile, node.parent); } else if (isCallLikeExpression(node.parent)) { - changes.deleteNodeInList(sourceFile, node); + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } else { - changes.deleteNode(sourceFile, node); + deleteNode(changes, sourceFile, node, node.kind === SyntaxKind.SemicolonToken ? { useNonAdjustedEndPosition: true } : undefined); } } } @@ -1133,7 +1110,7 @@ namespace ts.textChanges { function deleteDefaultImport(changes: ChangeTracker, sourceFile: SourceFile, importClause: ImportClause): void { if (!importClause.namedBindings) { // Delete the whole import - changes.deleteNode(sourceFile, importClause.parent); + deleteNode(changes, sourceFile, importClause.parent); } else { // import |d,| * as ns from './file' @@ -1145,7 +1122,7 @@ namespace ts.textChanges { changes.deleteRange(sourceFile, { pos: start, end }); } else { - changes.deleteNode(sourceFile, importClause.name!); + deleteNode(changes, sourceFile, importClause.name!); } } } @@ -1163,11 +1140,11 @@ namespace ts.textChanges { // |import * as ns from './file'| // |import { a } from './file'| const importDecl = getAncestor(node, SyntaxKind.ImportDeclaration)!; - changes.deleteNode(sourceFile, importDecl); + deleteNode(changes, sourceFile, importDecl); } } - function deleteVariableDeclaration(changes: ChangeTracker, sourceFile: SourceFile, node: VariableDeclaration): void { + function deleteVariableDeclaration(changes: ChangeTracker, deletedNodesInLists: NodeSet, sourceFile: SourceFile, node: VariableDeclaration): void { const { parent } = node; if (parent.kind === SyntaxKind.CatchClause) { @@ -1177,7 +1154,7 @@ namespace ts.textChanges { } if (parent.declarations.length !== 1) { - changes.deleteNodeInList(sourceFile, node); + deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); return; } @@ -1189,16 +1166,49 @@ namespace ts.textChanges { break; case SyntaxKind.ForStatement: - changes.deleteNode(sourceFile, parent); + deleteNode(changes, sourceFile, parent); break; case SyntaxKind.VariableStatement: - changes.deleteNode(sourceFile, gp); + deleteNode(changes, sourceFile, gp); break; default: Debug.assertNever(gp); } } + + function getRangeToDeleteJsDocTag(node: JSDocTag, sourceFile: SourceFile): TextRange { + const { parent } = node; + const toDelete = parent.kind === SyntaxKind.JSDocComment && parent.comment === undefined && parent.tags!.length === 1 ? parent : node; + return createTextRangeFromNode(toDelete, sourceFile); + } + } + + /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ + // Exported for tests only! (TODO: improve tests to not need this) + export function deleteNode(changes: ChangeTracker, sourceFile: SourceFile, node: Node, options: ConfigurableStartEnd = {}): void { + const startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + const endPosition = getAdjustedEndPosition(sourceFile, node, options); + changes.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + + function deleteNodeInList(changes: ChangeTracker, deletedNodesInLists: NodeSet, sourceFile: SourceFile, node: Node): void { + const containingList = Debug.assertDefined(formatting.SmartIndenter.getContainingList(node, sourceFile)); + const index = indexOfNode(containingList, node); + Debug.assert(index !== -1); + if (containingList.length === 1) { + deleteNode(changes, sourceFile, node); + return; + } + + // Note: We will only delete a comma *after* a node. This will leave a trailing comma if we delete the last node. + // That's handled in the end by `finishTrailingCommaAfterDeletingNodesInList`. + Debug.assert(!deletedNodesInLists.has(node), "Deleting a node twice"); + deletedNodesInLists.add(node); + changes.deleteRange(sourceFile, { + pos: startPositionToDeleteNodeInList(sourceFile, node), + end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : startPositionToDeleteNodeInList(sourceFile, containingList[index + 1]), + }); } } diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 6e1495d78a270..355a4d302c0e8 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -29,6 +29,7 @@ "preProcess.ts", "rename.ts", "signatureHelp.ts", + "sourcemaps.ts", "suggestionDiagnostics.ts", "symbolDisplay.ts", "transpile.ts", diff --git a/src/services/types.ts b/src/services/types.ts index be897f20cd43c..51c98724c0957 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -78,7 +78,7 @@ namespace ts { /* @internal */ scriptSnapshot: IScriptSnapshot | undefined; /* @internal */ nameTable: UnderscoreEscapedMap | undefined; - /* @internal */ getNamedDeclarations(): Map; + /* @internal */ getNamedDeclarations(): Map>; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; @@ -242,7 +242,7 @@ namespace ts { readonly allowTextChangesInNewFiles?: boolean; } /* @internal */ - export const defaultPreferences: UserPreferences = {}; + export const emptyOptions = {}; // // Public services of a language service instance associated @@ -292,7 +292,7 @@ namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; @@ -334,6 +334,8 @@ namespace ts { getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; + /** @internal */ + getSourceMapper(): SourceMapper; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; @@ -371,7 +373,10 @@ namespace ts { export type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; export interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; @@ -379,6 +384,53 @@ namespace ts { includeInsertTextCompletions?: boolean; } + export type SignatureHelpTriggerCharacter = "," | "(" | "<"; + export type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + + export interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + + export type SignatureHelpTriggerReason = + | SignatureHelpInvokedReason + | SignatureHelpCharacterTypedReason + | SignatureHelpRetriggeredReason; + + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + export interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + export interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + export interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } + export interface ApplyCodeActionCommandResult { successMessage: string; } @@ -599,7 +651,7 @@ namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; // TODO: keyof typeof PatternMatchKind; (https://github.com/Microsoft/TypeScript/issues/15102) + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 75d2c157b1471..1d68aa9144d53 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -347,7 +347,6 @@ namespace ts { case SyntaxKind.Parameter: return hasModifier(node, ModifierFlags.ParameterPropertyModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.ImportSpecifier: - case SyntaxKind.ImportClause: case SyntaxKind.ExportSpecifier: case SyntaxKind.NamespaceImport: return ScriptElementKind.alias; @@ -375,12 +374,14 @@ namespace ts { return ScriptElementKind.unknown; } } + case SyntaxKind.Identifier: + return isImportClause(node.parent) ? ScriptElementKind.alias : ScriptElementKind.unknown; default: return ScriptElementKind.unknown; } function getKindOfVariableDeclaration(v: VariableDeclaration): ScriptElementKind { - return isConst(v) + return isVarConst(v) ? ScriptElementKind.constElement : isLet(v) ? ScriptElementKind.letElement @@ -678,7 +679,7 @@ namespace ts { let current: Node = sourceFile; outer: while (true) { // find the child that contains 'position' - for (const child of current.getChildren()) { + for (const child of current.getChildren(sourceFile)) { const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { // If this child begins after position, then all subsequent children will as well. @@ -729,21 +730,14 @@ namespace ts { // this is token that starts at the end of previous token - return it return n; } - - const children = n.getChildren(); - for (const child of children) { + return firstDefined(n.getChildren(), child => { const shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || // previous token ends exactly at the beginning of child (child.pos === previousToken.end); - - if (shouldDiveInChildNode && nodeHasTokens(child, sourceFile)) { - return find(child); - } - } - - return undefined; + return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find(child) : undefined; + }); } } @@ -751,7 +745,7 @@ namespace ts { * Finds the rightmost token satisfying `token.end <= position`, * excluding `JsxText` tokens containing only whitespace. */ - export function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, includeJsDoc?: boolean): Node | undefined { + export function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, excludeJsdoc?: boolean): Node | undefined { const result = find(startNode || sourceFile); Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; @@ -770,7 +764,7 @@ namespace ts { // we need to find the last token in a previous child. // 2) `position` is within the same span: we recurse on `child`. if (position < child.end) { - const start = child.getStart(sourceFile, includeJsDoc); + const start = child.getStart(sourceFile, /*includeJsDoc*/ !excludeJsdoc); const lookInPreviousChild = (start >= position) || // cursor in the leading trivia !nodeHasTokens(child, sourceFile) || @@ -923,11 +917,25 @@ namespace ts { } } + export function isPossiblyTypeArgumentPosition(token: Node, sourceFile: SourceFile, checker: TypeChecker): boolean { + const info = getPossibleTypeArgumentsInfo(token, sourceFile); + return info !== undefined && (isPartOfTypeNode(info.called) || + getPossibleGenericSignatures(info.called, info.nTypeArguments, checker).length !== 0 || + isPossiblyTypeArgumentPosition(info.called, sourceFile, checker)); + } + + export function getPossibleGenericSignatures(called: Expression, typeArgumentCount: number, checker: TypeChecker): ReadonlyArray { + const type = checker.getTypeAtLocation(called); + const signatures = isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); + return signatures.filter(candidate => !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount); + } + export interface PossibleTypeArgumentInfo { readonly called: Identifier; readonly nTypeArguments: number; } - export function isPossiblyTypeArgumentPosition(tokenIn: Node, sourceFile: SourceFile): PossibleTypeArgumentInfo | undefined { + // Get info for an expression like `f <` that may be the start of type arguments. + export function getPossibleTypeArgumentsInfo(tokenIn: Node, sourceFile: SourceFile): PossibleTypeArgumentInfo | undefined { let token: Node | undefined = tokenIn; // This function determines if the node could be type argument position // Since during editing, when type argument list is not complete, @@ -1024,12 +1032,8 @@ namespace ts { * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) * @param predicate Additional predicate to test on the comment range. */ - export function isInComment( - sourceFile: SourceFile, - position: number, - tokenAtPosition?: Node, - predicate?: (c: CommentRange) => boolean): boolean { - return !!formatting.getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ false, /*precedingToken*/ undefined, tokenAtPosition, predicate); + export function isInComment(sourceFile: SourceFile, position: number, tokenAtPosition?: Node): CommentRange | undefined { + return formatting.getRangeOfEnclosingComment(sourceFile, position, /*precedingToken*/ undefined, tokenAtPosition); } export function hasDocComment(sourceFile: SourceFile, position: number): boolean { @@ -1044,7 +1048,7 @@ namespace ts { } export function getNodeModifiers(node: Node): string { - const flags = getCombinedModifierFlags(node); + const flags = isDeclaration(node) ? getCombinedModifierFlags(node) : ModifierFlags.None; const result: string[] = []; if (flags & ModifierFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier); @@ -1140,23 +1144,26 @@ namespace ts { } export function isInReferenceComment(sourceFile: SourceFile, position: number): boolean { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, c => { - const commentText = sourceFile.text.substring(c.pos, c.end); - return tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ true); } export function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean { - return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, c => { - const commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - }); + return isInReferenceCommentWorker(sourceFile, position, /*shouldBeReference*/ false); + } + + function isInReferenceCommentWorker(sourceFile: SourceFile, position: number, shouldBeReference: boolean): boolean { + const range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined); + return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); } export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); } + export function createTextRangeFromNode(node: Node, sourceFile: SourceFile): TextRange { + return createTextRange(node.getStart(sourceFile), node.end); + } + export function createTextSpanFromRange(range: TextRange): TextSpan { return createTextSpanFromBounds(range.pos, range.end); } @@ -1195,8 +1202,7 @@ namespace ts { /** True if the symbol is for an external module, as opposed to a namespace. */ export function isExternalModuleSymbol(moduleSymbol: Symbol): boolean { - Debug.assert(!!(moduleSymbol.flags & SymbolFlags.Module)); - return moduleSymbol.name.charCodeAt(0) === CharacterCodes.doubleQuote; + return !!(moduleSymbol.flags & SymbolFlags.Module) && moduleSymbol.name.charCodeAt(0) === CharacterCodes.doubleQuote; } /** Returns `true` the first time it encounters a node and `false` afterwards. */ @@ -1363,6 +1369,40 @@ namespace ts { } } + export interface ReadonlyNodeMap { + get(node: TNode): TValue | undefined; + has(node: TNode): boolean; + } + + export class NodeMap implements ReadonlyNodeMap { + private map = createMap<{ node: TNode, value: TValue }>(); + + get(node: TNode): TValue | undefined { + const res = this.map.get(String(getNodeId(node))); + return res && res.value; + } + + getOrUpdate(node: TNode, setValue: () => TValue): TValue { + const res = this.get(node); + if (res) return res; + const value = setValue(); + this.set(node, value); + return value; + } + + set(node: TNode, value: TValue): void { + this.map.set(String(getNodeId(node)), { node, value }); + } + + has(node: TNode): boolean { + return this.map.has(String(getNodeId(node))); + } + + forEach(cb: (value: TValue, node: TNode) => void): void { + this.map.forEach(({ node, value }) => cb(value, node)); + } + } + export function getParentNodeInSpan(node: Node | undefined, file: SourceFile, span: TextSpan): Node | undefined { if (!node) return undefined; @@ -1394,6 +1434,13 @@ namespace ts { changes.insertNodeAtTopOfFile(sourceFile, importDecl, /*blankLineBetween*/ true); } } + + export function textSpansEqual(a: TextSpan | undefined, b: TextSpan | undefined): boolean { + return !!a && !!b && a.start === b.start && a.length === b.length; + } + export function documentSpansEqual(a: DocumentSpan, b: DocumentSpan): boolean { + return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan); + } } // Display-part writer helpers @@ -1405,14 +1452,25 @@ namespace ts { const displayPartWriter = getDisplayPartWriter(); function getDisplayPartWriter(): DisplayPartsSymbolWriter { + const absoluteMaximumLength = defaultMaximumTruncationLength * 10; // A hard cutoff to avoid overloading the messaging channel in worst-case scenarios let displayParts: SymbolDisplayPart[]; let lineStart: boolean; let indent: number; + let length: number; resetWriter(); const unknownWrite = (text: string) => writeKind(text, SymbolDisplayPartKind.text); return { - displayParts: () => displayParts, + displayParts: () => { + const finalText = displayParts.length && displayParts[displayParts.length - 1].text; + if (length > absoluteMaximumLength && finalText && finalText !== "...") { + if (!isWhiteSpaceLike(finalText.charCodeAt(finalText.length - 1))) { + displayParts.push(displayPart(" ", SymbolDisplayPartKind.space)); + } + displayParts.push(displayPart("...", SymbolDisplayPartKind.punctuation)); + } + return displayParts; + }, writeKeyword: text => writeKind(text, SymbolDisplayPartKind.keyword), writeOperator: text => writeKind(text, SymbolDisplayPartKind.operator), writePunctuation: text => writeKind(text, SymbolDisplayPartKind.punctuation), @@ -1442,9 +1500,11 @@ namespace ts { }; function writeIndent() { + if (length > absoluteMaximumLength) return; if (lineStart) { const indentString = getIndentString(indent); if (indentString) { + length += indentString.length; displayParts.push(displayPart(indentString, SymbolDisplayPartKind.space)); } lineStart = false; @@ -1452,16 +1512,22 @@ namespace ts { } function writeKind(text: string, kind: SymbolDisplayPartKind) { + if (length > absoluteMaximumLength) return; writeIndent(); + length += text.length; displayParts.push(displayPart(text, kind)); } function writeSymbol(text: string, symbol: Symbol) { + if (length > absoluteMaximumLength) return; writeIndent(); + length += text.length; displayParts.push(symbolPart(text, symbol)); } function writeLine() { + if (length > absoluteMaximumLength) return; + length += 1; displayParts.push(lineBreakPart()); lineStart = true; } @@ -1470,6 +1536,7 @@ namespace ts { displayParts = []; lineStart = true; indent = 0; + length = 0; } } diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 988e181852ab0..c10be2a9ff8e3 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -20,6 +20,7 @@ namespace Harness.Parallel.Host { // tslint:disable-next-line:variable-name const FailedTestReporter = require(path.resolve(__dirname, "../../scripts/failed-tests")) as typeof import("../../../scripts/failed-tests"); + const perfdataFileNameFragment = ".parallelperf"; const perfData = readSavedPerfData(configOption); const newTasks: Task[] = []; let tasks: Task[] = []; @@ -175,8 +176,6 @@ namespace Harness.Parallel.Host { } } - const perfdataFileNameFragment = ".parallelperf"; - function perfdataFileName(target?: string) { return `${perfdataFileNameFragment}${target ? `.${target}` : ""}.json`; } diff --git a/src/testRunner/rwcRunner.ts b/src/testRunner/rwcRunner.ts index eadbcc53e2d58..729ed167fffc0 100644 --- a/src/testRunner/rwcRunner.ts +++ b/src/testRunner/rwcRunner.ts @@ -198,8 +198,9 @@ namespace RWC { inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined!, compilerOptions, currentDirectory // TODO: GH#18217 ); // Reset compilerResult before calling into `compileDeclarationFiles` so the memory from the original compilation can be freed + const links = compilerResult.symlinks; compilerResult = undefined!; - const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(declContext)!; + const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(declContext, links)!; return Harness.Compiler.iterateErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.diagnostics, { caseSensitive, currentDirectory }); }, baselineOpts); diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 3943d4f4f85ca..b02f1a6c17532 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -39,7 +39,7 @@ "unittests/extractTestHelpers.ts", "unittests/tsserverProjectSystem.ts", "unittests/typingsInstaller.ts", - + "unittests/asserts.ts", "unittests/base64.ts", "unittests/builder.ts", @@ -54,6 +54,7 @@ "unittests/extractConstants.ts", "unittests/extractFunctions.ts", "unittests/extractRanges.ts", + "unittests/factory.ts", "unittests/hostNewLineSupport.ts", "unittests/incrementalParser.ts", "unittests/initializeTSConfig.ts", diff --git a/src/testRunner/unittests/cancellableLanguageServiceOperations.ts b/src/testRunner/unittests/cancellableLanguageServiceOperations.ts index a5947cc17e3dd..37f829d67a7b9 100644 --- a/src/testRunner/unittests/cancellableLanguageServiceOperations.ts +++ b/src/testRunner/unittests/cancellableLanguageServiceOperations.ts @@ -8,7 +8,7 @@ namespace ts { `; it("can cancel signature help mid-request", () => { verifyOperationCancelledAfter(file, 4, service => // Two calls are top-level in services, one is the root type, and the second should be for the parameter type - service.getSignatureHelpItems("file.ts", file.lastIndexOf("f"))!, + service.getSignatureHelpItems("file.ts", file.lastIndexOf("f"), emptyOptions)!, r => assert.exists(r.items[0]) ); }); diff --git a/src/testRunner/unittests/convertToBase64.ts b/src/testRunner/unittests/convertToBase64.ts index e41f73034c4a6..56c9562297784 100644 --- a/src/testRunner/unittests/convertToBase64.ts +++ b/src/testRunner/unittests/convertToBase64.ts @@ -2,7 +2,7 @@ namespace ts { describe("convertToBase64", () => { function runTest(input: string): void { const actual = convertToBase64(input); - const expected = new Buffer(input).toString("base64"); + const expected = sys.base64encode!(input); assert.equal(actual, expected, "Encoded string using convertToBase64 does not match buffer.toString('base64')"); } diff --git a/src/testRunner/unittests/extractTestHelpers.ts b/src/testRunner/unittests/extractTestHelpers.ts index c36ac88e8e0ac..d812eb96f88b9 100644 --- a/src/testRunner/unittests/extractTestHelpers.ts +++ b/src/testRunner/unittests/extractTestHelpers.ts @@ -124,7 +124,7 @@ namespace ts { endPosition: selectionRange.end, host: notImplementedHost, formatContext: formatting.getFormatContext(testFormatOptions), - preferences: defaultPreferences, + preferences: emptyOptions, }; const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange)); assert.equal(rangeToExtract.errors, undefined, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText); @@ -188,7 +188,7 @@ namespace ts { endPosition: selectionRange.end, host: notImplementedHost, formatContext: formatting.getFormatContext(testFormatOptions), - preferences: defaultPreferences, + preferences: emptyOptions, }; const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange)); assert.isUndefined(rangeToExtract.errors, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText); diff --git a/src/testRunner/unittests/factory.ts b/src/testRunner/unittests/factory.ts new file mode 100644 index 0000000000000..e17311147adc1 --- /dev/null +++ b/src/testRunner/unittests/factory.ts @@ -0,0 +1,54 @@ +namespace ts { + describe("FactoryAPI", () => { + describe("createExportAssignment", () => { + it("parenthesizes default export if necessary", () => { + function checkExpression(expression: Expression) { + const node = createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*isExportEquals*/ false, + expression, + ); + assert.strictEqual(node.expression.kind, SyntaxKind.ParenthesizedExpression); + } + + const clazz = createClassExpression(/*modifiers*/ undefined, "C", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [ + createProperty(/*decorators*/ undefined, [createToken(SyntaxKind.StaticKeyword)], "prop", /*questionOrExclamationToken*/ undefined, /*type*/ undefined, createLiteral("1")), + ]); + checkExpression(clazz); + checkExpression(createPropertyAccess(clazz, "prop")); + + const func = createFunctionExpression(/*modifiers*/ undefined, /*asteriskToken*/ undefined, "fn", /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, createBlock([])); + checkExpression(func); + checkExpression(createCall(func, /*typeArguments*/ undefined, /*argumentsArray*/ undefined)); + checkExpression(createTaggedTemplate(func, createNoSubstitutionTemplateLiteral(""))); + + checkExpression(createBinary(createLiteral("a"), SyntaxKind.CommaToken, createLiteral("b"))); + checkExpression(createCommaList([createLiteral("a"), createLiteral("b")])); + }); + }); + + describe("createArrowFunction", () => { + it("parenthesizes concise body if necessary", () => { + function checkBody(body: ConciseBody) { + const node = createArrowFunction( + /*modifiers*/ undefined, + /*typeParameters*/ undefined, + [], + /*type*/ undefined, + /*equalsGreaterThanToken*/ undefined, + body, + ); + assert.strictEqual(node.body.kind, SyntaxKind.ParenthesizedExpression); + } + + checkBody(createObjectLiteral()); + checkBody(createPropertyAccess(createObjectLiteral(), "prop")); + checkBody(createAsExpression(createPropertyAccess(createObjectLiteral(), "prop"), createTypeReferenceNode("T", /*typeArguments*/ undefined))); + checkBody(createNonNullExpression(createPropertyAccess(createObjectLiteral(), "prop"))); + checkBody(createCommaList([createLiteral("a"), createLiteral("b")])); + checkBody(createBinary(createLiteral("a"), SyntaxKind.CommaToken, createLiteral("b"))); + }); + }); + }); +} diff --git a/src/testRunner/unittests/organizeImports.ts b/src/testRunner/unittests/organizeImports.ts index b889f97ef1c6d..7fe99ffc784ee 100644 --- a/src/testRunner/unittests/organizeImports.ts +++ b/src/testRunner/unittests/organizeImports.ts @@ -270,7 +270,7 @@ export const Other = 1; content: "function F() { }", }; const languageService = makeLanguageService(testFile); - const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatOptions, defaultPreferences); + const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatOptions, emptyOptions); assert.isEmpty(changes); }); @@ -741,7 +741,7 @@ export * from "lib"; function runBaseline(baselinePath: string, testFile: TestFSWithWatch.File, ...otherFiles: TestFSWithWatch.File[]) { const { path: testPath, content: testContent } = testFile; const languageService = makeLanguageService(testFile, ...otherFiles); - const changes = languageService.organizeImports({ type: "file", fileName: testPath }, testFormatOptions, defaultPreferences); + const changes = languageService.organizeImports({ type: "file", fileName: testPath }, testFormatOptions, emptyOptions); assert.equal(changes.length, 1); assert.equal(changes[0].fileName, testPath); diff --git a/src/testRunner/unittests/projectReferences.ts b/src/testRunner/unittests/projectReferences.ts index 070d26cccd5f9..4702c0c26ceb9 100644 --- a/src/testRunner/unittests/projectReferences.ts +++ b/src/testRunner/unittests/projectReferences.ts @@ -285,4 +285,23 @@ namespace ts { }); }); + describe("errors when a file in a composite project occurs outside the root", () => { + it("Errors when a file is outside the rootdir", () => { + const spec: TestSpecification = { + "/alpha": { + files: { "/alpha/src/a.ts": "import * from '../../beta/b'", "/beta/b.ts": "export { }" }, + options: { + declaration: true, + outDir: "bin" + }, + references: [] + } + }; + testProjectReferences(spec, "/alpha/tsconfig.json", (program) => { + assertHasError("Issues an error about the rootDir", program.getOptionsDiagnostics(), Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files); + assertHasError("Issues an error about the fileList", program.getOptionsDiagnostics(), Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern); + }); + }); + }); + } diff --git a/src/testRunner/unittests/textChanges.ts b/src/testRunner/unittests/textChanges.ts index 0c06eecb51d31..a2ba91f04a2fa 100644 --- a/src/testRunner/unittests/textChanges.ts +++ b/src/testRunner/unittests/textChanges.ts @@ -128,6 +128,7 @@ function bar() { function findVariableDeclarationContaining(name: string, sourceFile: SourceFile): VariableDeclaration { return cast(findChild(name, sourceFile), isVariableDeclaration); } + const { deleteNode } = textChanges; { const text = ` var x = 1; // some comment - 1 @@ -138,19 +139,19 @@ var y = 2; // comment 3 var z = 3; // comment 4 `; runSingleFileTest("deleteNode1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile)); + deleteNode(changeTracker, sourceFile, findVariableStatementContaining("y", sourceFile)); }); runSingleFileTest("deleteNode2", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true }); + deleteNode(changeTracker, sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true }); }); runSingleFileTest("deleteNode3", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedEndPosition: true }); + deleteNode(changeTracker, sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedEndPosition: true }); }); runSingleFileTest("deleteNode4", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + deleteNode(changeTracker, sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); }); runSingleFileTest("deleteNode5", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNode(sourceFile, findVariableStatementContaining("x", sourceFile)); + deleteNode(changeTracker, sourceFile, findVariableStatementContaining("x", sourceFile)); }); } { @@ -377,25 +378,25 @@ class A { { const text = `var a = 1, b = 2, c = 3;`; runSingleFileTest("deleteNodeInList1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + changeTracker.delete(sourceFile, findChild("a", sourceFile)); }); runSingleFileTest("deleteNodeInList2", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + changeTracker.delete(sourceFile, findChild("b", sourceFile)); }); runSingleFileTest("deleteNodeInList3", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + changeTracker.delete(sourceFile, findChild("c", sourceFile)); }); } { const text = `var a = 1,b = 2,c = 3;`; runSingleFileTest("deleteNodeInList1_1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + changeTracker.delete(sourceFile, findChild("a", sourceFile)); }); runSingleFileTest("deleteNodeInList2_1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + changeTracker.delete(sourceFile, findChild("b", sourceFile)); }); runSingleFileTest("deleteNodeInList3_1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + changeTracker.delete(sourceFile, findChild("c", sourceFile)); }); } { @@ -406,13 +407,13 @@ namespace M { c = 3; }`; runSingleFileTest("deleteNodeInList4", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + changeTracker.delete(sourceFile, findChild("a", sourceFile)); }); runSingleFileTest("deleteNodeInList5", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + changeTracker.delete(sourceFile, findChild("b", sourceFile)); }); runSingleFileTest("deleteNodeInList6", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + changeTracker.delete(sourceFile, findChild("c", sourceFile)); }); } { @@ -425,13 +426,13 @@ namespace M { c = 3; // comment 5 }`; runSingleFileTest("deleteNodeInList4_1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + changeTracker.delete(sourceFile, findChild("a", sourceFile)); }); runSingleFileTest("deleteNodeInList5_1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + changeTracker.delete(sourceFile, findChild("b", sourceFile)); }); runSingleFileTest("deleteNodeInList6_1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + changeTracker.delete(sourceFile, findChild("c", sourceFile)); }); } { @@ -440,13 +441,13 @@ function foo(a: number, b: string, c = true) { return 1; }`; runSingleFileTest("deleteNodeInList7", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + changeTracker.delete(sourceFile, findChild("a", sourceFile)); }); runSingleFileTest("deleteNodeInList8", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + changeTracker.delete(sourceFile, findChild("b", sourceFile)); }); runSingleFileTest("deleteNodeInList9", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + changeTracker.delete(sourceFile, findChild("c", sourceFile)); }); } { @@ -455,13 +456,13 @@ function foo(a: number,b: string,c = true) { return 1; }`; runSingleFileTest("deleteNodeInList10", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + changeTracker.delete(sourceFile, findChild("a", sourceFile)); }); runSingleFileTest("deleteNodeInList11", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + changeTracker.delete(sourceFile, findChild("b", sourceFile)); }); runSingleFileTest("deleteNodeInList12", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + changeTracker.delete(sourceFile, findChild("c", sourceFile)); }); } { @@ -473,13 +474,13 @@ function foo( return 1; }`; runSingleFileTest("deleteNodeInList13", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + changeTracker.delete(sourceFile, findChild("a", sourceFile)); }); runSingleFileTest("deleteNodeInList14", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + changeTracker.delete(sourceFile, findChild("b", sourceFile)); }); runSingleFileTest("deleteNodeInList15", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + changeTracker.delete(sourceFile, findChild("c", sourceFile)); }); } { @@ -661,7 +662,7 @@ class A { } `; runSingleFileTest("deleteNodeAfterInClass1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNode(sourceFile, findChild("x", sourceFile)); + deleteNode(changeTracker, sourceFile, findChild("x", sourceFile)); }); } { @@ -672,7 +673,7 @@ class A { } `; runSingleFileTest("deleteNodeAfterInClass2", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.deleteNode(sourceFile, findChild("x", sourceFile)); + deleteNode(changeTracker, sourceFile, findChild("x", sourceFile)); }); } { diff --git a/src/testRunner/unittests/transform.ts b/src/testRunner/unittests/transform.ts index 6c74c558b16b4..31422003b44c9 100644 --- a/src/testRunner/unittests/transform.ts +++ b/src/testRunner/unittests/transform.ts @@ -268,33 +268,115 @@ namespace ts { return fs.readFileSync("/.src/index.d.ts").toString(); } + function addSyntheticComment(nodeFilter: (node: Node) => boolean) { + return (context: TransformationContext) => { + return (sourceFile: SourceFile): SourceFile => { + return visitNode(sourceFile, rootTransform, isSourceFile); + }; + function rootTransform(node: T): VisitResult { + if (nodeFilter(node)) { + setEmitFlags(node, EmitFlags.NoLeadingComments); + setSyntheticLeadingComments(node, [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "comment", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + return visitEachChild(node, rootTransform, context); + } + }; + } + // https://github.com/Microsoft/TypeScript/issues/24096 testBaseline("transformAddCommentToArrowReturnValue", () => { return transpileModule(`const foo = () => void 0 `, { transformers: { - before: [addSyntheticComment], + before: [addSyntheticComment(isVoidExpression)], }, compilerOptions: { target: ScriptTarget.ES5, newLine: NewLineKind.CarriageReturnLineFeed, } }).outputText; + }); - function addSyntheticComment(context: TransformationContext) { - return (sourceFile: SourceFile): SourceFile => { - return visitNode(sourceFile, rootTransform, isSourceFile); - }; - function rootTransform(node: T): VisitResult { - if (isVoidExpression(node)) { - setEmitFlags(node, EmitFlags.NoLeadingComments); - setSyntheticLeadingComments(node, [{ kind: SyntaxKind.SingleLineCommentTrivia, text: "// comment!", pos: -1, end: -1, hasTrailingNewLine: true }]); - return node; - } - return visitEachChild(node, rootTransform, context); - } - } + // https://github.com/Microsoft/TypeScript/issues/17594 + testBaseline("transformAddCommentToExportedVar", () => { + return transpileModule(`export const exportedDirectly = 1; +const exportedSeparately = 2; +export {exportedSeparately}; +`, { + transformers: { + before: [addSyntheticComment(isVariableStatement)], + }, + compilerOptions: { + target: ScriptTarget.ES5, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + }); + + // https://github.com/Microsoft/TypeScript/issues/17594 + testBaseline("transformAddCommentToImport", () => { + return transpileModule(` +// Previous comment on import. +import {Value} from 'somewhere'; +import * as X from 'somewhere'; +// Previous comment on export. +export { /* specifier comment */ X, Y} from 'somewhere'; +export * from 'somewhere'; +export {Value}; +`, { + transformers: { + before: [addSyntheticComment(n => isImportDeclaration(n) || isExportDeclaration(n) || isImportSpecifier(n) || isExportSpecifier(n))], + }, + compilerOptions: { + target: ScriptTarget.ES5, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + }); + + // https://github.com/Microsoft/TypeScript/issues/17594 + testBaseline("transformAddCommentToProperties", () => { + return transpileModule(` +// class comment. +class Clazz { + // original comment 1. + static staticProp: number = 1; + // original comment 2. + instanceProp: number = 2; + // original comment 3. + constructor(readonly field = 1) {} +} +`, { + transformers: { + before: [addSyntheticComment(n => isPropertyDeclaration(n) || isParameterPropertyDeclaration(n) || isClassDeclaration(n) || isConstructorDeclaration(n))], + }, + compilerOptions: { + target: ScriptTarget.ES2015, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + }); + + testBaseline("transformAddCommentToNamespace", () => { + return transpileModule(` +// namespace comment. +namespace Foo { + export const x = 1; +} +// another comment. +namespace Foo { + export const y = 1; +} +`, { + transformers: { + before: [addSyntheticComment(n => isModuleDeclaration(n))], + }, + compilerOptions: { + target: ScriptTarget.ES2015, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; }); }); } diff --git a/src/testRunner/unittests/tsbuild.ts b/src/testRunner/unittests/tsbuild.ts index f9e030ba3ad28..5cb546f8abba8 100644 --- a/src/testRunner/unittests/tsbuild.ts +++ b/src/testRunner/unittests/tsbuild.ts @@ -233,6 +233,38 @@ namespace ts { assert.isBelow(fs.statSync("/src/core/index.js").mtimeMs, time(), "Upstream JS file should not have been rebuilt"); }); }); + + describe("tsbuild - with resolveJsonModule option", () => { + const projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite"); + const allExpectedOutputs = ["/src/tests/dist/src/index.js", "/src/tests/dist/src/index.d.ts", "/src/tests/dist/src/hello.json"]; + + function verifyProjectWithResolveJsonModule(configFile: string, ...expectedDiagnosticMessages: DiagnosticMessage[]) { + const fs = projFs.shadow(); + const host = new fakes.CompilerHost(fs); + const builder = createSolutionBuilder(host, buildHost, [configFile], { dry: false, force: false, verbose: false }); + clearDiagnostics(); + builder.buildAllProjects(); + assertDiagnosticMessages(...expectedDiagnosticMessages); + if (!expectedDiagnosticMessages.length) { + // Check for outputs. Not an exhaustive list + for (const output of allExpectedOutputs) { + assert(fs.existsSync(output), `Expect file ${output} to exist`); + } + } + } + + it("with resolveJsonModule and include only", () => { + verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withInclude.json", Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern); + }); + + it("with resolveJsonModule and files containing json file", () => { + verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withFiles.json"); + }); + + it("with resolveJsonModule and include and files", () => { + verifyProjectWithResolveJsonModule("/src/tests/tsconfig_withIncludeAndFiles.json"); + }); + }); } export namespace OutFile { @@ -427,4 +459,4 @@ namespace ts { fs.makeReadonly(); return fs; } -} \ No newline at end of file +} diff --git a/src/testRunner/unittests/tscWatchMode.ts b/src/testRunner/unittests/tscWatchMode.ts index ed03c6ad48dc4..e6c805148ee20 100644 --- a/src/testRunner/unittests/tscWatchMode.ts +++ b/src/testRunner/unittests/tscWatchMode.ts @@ -2313,58 +2313,99 @@ declare module "fs" { }); describe("tsc-watch console clearing", () => { - function checkConsoleClearing(options: CompilerOptions = {}) { - const file = { - path: "f.ts", - content: "" - }; - const files = [file, libFile]; - const disableConsoleClear = options.diagnostics || options.extendedDiagnostics || options.preserveWatchOutput; - const host = createWatchedSystem(files); - createWatchOfFilesAndCompilerOptions([file.path], host, options); - checkOutputErrorsInitial(host, emptyArray, disableConsoleClear, options.extendedDiagnostics ? [ - "Current directory: / CaseSensitiveFileNames: false\n", + const currentDirectoryLog = "Current directory: / CaseSensitiveFileNames: false\n"; + const fileWatcherAddedLog = [ + "FileWatcher:: Added:: WatchInfo: /f.ts 250 Source file\n", + "FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 Source file\n" + ]; + + const file: File = { + path: "/f.ts", + content: "" + }; + + function getProgramSynchronizingLog(options: CompilerOptions) { + return [ "Synchronizing program\n", "CreatingProgramWith::\n", - " roots: [\"f.ts\"]\n", - " options: {\"extendedDiagnostics\":true}\n", - "FileWatcher:: Added:: WatchInfo: f.ts 250 Source file\n", - "FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 Source file\n" - ] : undefined); + " roots: [\"/f.ts\"]\n", + ` options: ${JSON.stringify(options)}\n` + ]; + } - file.content = "//"; - host.reloadFS(files); + function isConsoleClearDisabled(options: CompilerOptions) { + return options.diagnostics || options.extendedDiagnostics || options.preserveWatchOutput; + } + + function verifyCompilation(host: WatchedSystem, options: CompilerOptions, initialDisableOptions?: CompilerOptions) { + const disableConsoleClear = isConsoleClearDisabled(options); + const hasLog = options.extendedDiagnostics || options.diagnostics; + checkOutputErrorsInitial(host, emptyArray, initialDisableOptions ? isConsoleClearDisabled(initialDisableOptions) : disableConsoleClear, hasLog ? [ + currentDirectoryLog, + ...getProgramSynchronizingLog(options), + ...(options.extendedDiagnostics ? fileWatcherAddedLog : emptyArray) + ] : undefined); + host.modifyFile(file.path, "//"); host.runQueuedTimeoutCallbacks(); - checkOutputErrorsIncremental(host, emptyArray, disableConsoleClear, options.extendedDiagnostics ? [ - "FileWatcher:: Triggered with /f.ts1:: WatchInfo: f.ts 250 Source file\n", + checkOutputErrorsIncremental(host, emptyArray, disableConsoleClear, hasLog ? [ + "FileWatcher:: Triggered with /f.ts 1:: WatchInfo: /f.ts 250 Source file\n", "Scheduling update\n", - "Elapsed:: 0ms FileWatcher:: Triggered with /f.ts1:: WatchInfo: f.ts 250 Source file\n" - ] : undefined, options.extendedDiagnostics ? [ - "Synchronizing program\n", - "CreatingProgramWith::\n", - " roots: [\"f.ts\"]\n", - " options: {\"extendedDiagnostics\":true}\n" - ] : undefined); + "Elapsed:: 0ms FileWatcher:: Triggered with /f.ts 1:: WatchInfo: /f.ts 250 Source file\n" + ] : undefined, hasLog ? getProgramSynchronizingLog(options) : undefined); + } + + function checkConsoleClearingUsingCommandLineOptions(options: CompilerOptions = {}) { + const files = [file, libFile]; + const host = createWatchedSystem(files); + createWatchOfFilesAndCompilerOptions([file.path], host, options); + verifyCompilation(host, options); } it("without --diagnostics or --extendedDiagnostics", () => { - checkConsoleClearing(); + checkConsoleClearingUsingCommandLineOptions(); }); it("with --diagnostics", () => { - checkConsoleClearing({ + checkConsoleClearingUsingCommandLineOptions({ diagnostics: true, }); }); it("with --extendedDiagnostics", () => { - checkConsoleClearing({ + checkConsoleClearingUsingCommandLineOptions({ extendedDiagnostics: true, }); }); it("with --preserveWatchOutput", () => { - checkConsoleClearing({ + checkConsoleClearingUsingCommandLineOptions({ preserveWatchOutput: true, }); }); + + describe("when preserveWatchOutput is true in config file", () => { + const compilerOptions: CompilerOptions = { + preserveWatchOutput: true + }; + const configFile: File = { + path: "/tsconfig.json", + content: JSON.stringify({ compilerOptions }) + }; + const files = [file, configFile, libFile]; + it("using createWatchOfConfigFile ", () => { + const host = createWatchedSystem(files); + createWatchOfConfigFile(configFile.path, host); + // Initially console is cleared if --preserveOutput is not provided since the config file is yet to be parsed + verifyCompilation(host, compilerOptions, {}); + }); + it("when createWatchProgram is invoked with configFileParseResult on WatchCompilerHostOfConfigFile", () => { + const host = createWatchedSystem(files); + const reportDiagnostic = createDiagnosticReporter(host); + const optionsToExtend: CompilerOptions = {}; + const configParseResult = parseConfigFileWithSystem(configFile.path, optionsToExtend, host, reportDiagnostic)!; + const watchCompilerHost = createWatchCompilerHostOfConfigFile(configParseResult.options.configFilePath!, optionsToExtend, host, /*createProgram*/ undefined, reportDiagnostic, createWatchStatusReporter(host)); + watchCompilerHost.configFileParsingResult = configParseResult; + createWatchProgram(watchCompilerHost); + verifyCompilation(host, compilerOptions); + }); + }); }); describe("tsc-watch with different polling/non polling options", () => { diff --git a/src/testRunner/unittests/tsserverProjectSystem.ts b/src/testRunner/unittests/tsserverProjectSystem.ts index 2345cf216a0b9..309107923e9d1 100644 --- a/src/testRunner/unittests/tsserverProjectSystem.ts +++ b/src/testRunner/unittests/tsserverProjectSystem.ts @@ -415,22 +415,48 @@ namespace ts.projectSystem { checkArray("Open files", arrayFrom(projectService.openFiles.keys(), path => projectService.getScriptInfoForPath(path as Path)!.fileName), expectedFiles.map(file => file.path)); } - function textSpanFromSubstring(str: string, substring: string): TextSpan { + function protocolLocationFromSubstring(str: string, substring: string): protocol.Location { const start = str.indexOf(substring); Debug.assert(start !== -1); - return createTextSpan(start, substring.length); + return protocolToLocation(str)(start); } - - function protocolTextSpanFromSubstring(str: string, substring: string): protocol.TextSpan { - const start = str.indexOf(substring); + function protocolToLocation(text: string): (pos: number) => protocol.Location { + const lineStarts = computeLineStarts(text); + return pos => { + const x = computeLineAndCharacterOfPosition(lineStarts, pos); + return { line: x.line + 1, offset: x.character + 1 }; + }; + } + function protocolTextSpanFromSubstring(str: string, substring: string, options?: SpanFromSubstringOptions): protocol.TextSpan { + const span = textSpanFromSubstring(str, substring, options); + const toLocation = protocolToLocation(str); + return { start: toLocation(span.start), end: toLocation(textSpanEnd(span)) }; + } + function textSpanFromSubstring(str: string, substring: string, options?: SpanFromSubstringOptions): TextSpan { + const start = nthIndexOf(str, substring, options ? options.index : 0); Debug.assert(start !== -1); - const lineStarts = computeLineStarts(str); - const toLocation = (pos: number) => lineAndCharacterToLocation(computeLineAndCharacterOfPosition(lineStarts, pos)); - return { start: toLocation(start), end: toLocation(start + substring.length) }; + return createTextSpan(start, substring.length); + } + function protocolFileLocationFromSubstring(file: File, substring: string): protocol.FileLocationRequestArgs { + return { file: file.path, ...protocolLocationFromSubstring(file.content, substring) }; + } + function protocolFileSpanFromSubstring(file: File, substring: string, options?: SpanFromSubstringOptions) { + return { file: file.path, ...protocolTextSpanFromSubstring(file.content, substring, options) }; + } + function documentSpanFromSubstring(file: File, substring: string, options?: SpanFromSubstringOptions): DocumentSpan { + return { fileName: file.path, textSpan: textSpanFromSubstring(file.content, substring, options) }; + } + interface SpanFromSubstringOptions { + readonly index: number; } - function lineAndCharacterToLocation(lc: LineAndCharacter): protocol.Location { - return { line: lc.line + 1, offset: lc.character + 1 }; + function nthIndexOf(str: string, substr: string, n: number): number { + let index = -1; + for (; n >= 0; n--) { + index = str.indexOf(substr, index + 1); + if (index === -1) return -1; + } + return index; } /** @@ -485,10 +511,24 @@ namespace ts.projectSystem { }; } - export function openFilesForSession(files: ReadonlyArray, session: server.Session) { + export function executeSessionRequest(session: server.Session, command: TRequest["command"], args: TRequest["arguments"]): TResponse["body"] { + return session.executeCommand(makeSessionRequest(command, args)).response as TResponse["body"]; + } + + export function executeSessionRequestNoResponse(session: server.Session, command: TRequest["command"], args: TRequest["arguments"]): void { + session.executeCommand(makeSessionRequest(command, args)); + } + + export function openFilesForSession(files: ReadonlyArray, session: server.Session): void { for (const file of files) { - const request = makeSessionRequest(CommandNames.Open, { file: file.path }); - session.executeCommand(request); + session.executeCommand(makeSessionRequest(CommandNames.Open, + "projectRootPath" in file ? { file: typeof file.file === "string" ? file.file : file.file.path, projectRootPath: file.projectRootPath } : { file: file.path })); + } + } + + export function closeFilesForSession(files: ReadonlyArray, session: server.Session): void { + for (const file of files) { + session.executeCommand(makeSessionRequest(CommandNames.Close, { file: file.path })); } } @@ -1508,13 +1548,13 @@ namespace ts.projectSystem { service.checkNumberOfProjects({ externalProjects: 1 }); checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, libFile.path]); - const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, defaultPreferences)!; + const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, emptyOptions)!; // should contain completions for string assert.isTrue(completions1.entries.some(e => e.name === "charAt"), "should contain 'charAt'"); assert.isFalse(completions1.entries.some(e => e.name === "toExponential"), "should not contain 'toExponential'"); service.closeClientFile(f2.path); - const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, defaultPreferences)!; + const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2, emptyOptions)!; // should contain completions for string assert.isFalse(completions2.entries.some(e => e.name === "charAt"), "should not contain 'charAt'"); assert.isTrue(completions2.entries.some(e => e.name === "toExponential"), "should contain 'toExponential'"); @@ -1540,11 +1580,11 @@ namespace ts.projectSystem { service.checkNumberOfProjects({ externalProjects: 1 }); checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, libFile.path]); - const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0, defaultPreferences)!; + const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0, emptyOptions)!; assert.isTrue(completions1.entries.some(e => e.name === "somelongname"), "should contain 'somelongname'"); service.closeClientFile(f2.path); - const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0, defaultPreferences)!; + const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0, emptyOptions)!; assert.isFalse(completions2.entries.some(e => e.name === "somelongname"), "should not contain 'somelongname'"); const sf2 = service.externalProjects[0].getLanguageService().getProgram()!.getSourceFile(f2.path)!; assert.equal(sf2.text, ""); @@ -2184,7 +2224,7 @@ namespace ts.projectSystem { // Check identifiers defined in HTML content are available in .ts file const project = configuredProjectAt(projectService, 0); - let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1, defaultPreferences); + let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1, emptyOptions); assert(completions && completions.entries[0].name === "hello", `expected entry hello to be in completion list`); // Close HTML file @@ -2198,7 +2238,7 @@ namespace ts.projectSystem { checkProjectActualFiles(configuredProjectAt(projectService, 0), [file1.path, file2.path, config.path]); // Check identifiers defined in HTML content are not available in .ts file - completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 5, defaultPreferences); + completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 5, emptyOptions); assert(completions && completions.entries[0].name !== "hello", `unexpected hello entry in completion list`); }); @@ -3368,7 +3408,7 @@ namespace ts.projectSystem { host.reloadFS(files.map(f => f === fileSubA ? fileA : f)); host.checkTimeoutQueueLength(2); - closeFile(fileSubA); + closeFilesForSession([fileSubA], session); // This should cancel existing updates and schedule new ones host.checkTimeoutQueueLength(2); checkNumberOfProjects(services, { configuredProjects: 1 }); @@ -3388,7 +3428,7 @@ namespace ts.projectSystem { // file is deleted but watches are not yet invoked const originalFileExists = host.fileExists; host.fileExists = s => s === fileA.path ? false : originalFileExists.call(host, s); - closeFile(fileA); + closeFilesForSession([fileA], session); host.checkTimeoutQueueLength(2); // Update configured project and projects for open file checkProjectActualFiles(services.configuredProjects.get(config.path)!, filesWithFileA.map(f => f.path)); @@ -3436,23 +3476,7 @@ namespace ts.projectSystem { assert.isFalse(hasErrorMsg()); function openFile(file: File) { - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: file.path, - fileContent: file.content, - projectRootPath - } - }); - } - - function closeFile(file: File) { - session.executeCommandSeq({ - command: protocol.CommandTypes.Close, - arguments: { - file: file.path - } - }); + openFilesForSession([{ file, projectRootPath }], session); } }); }); @@ -3669,40 +3693,17 @@ namespace ts.projectSystem { const files = [libFile, app, serverUtilities, backendTest]; const host = createServerHost(files); const session = createSession(host, { useInferredProjectPerProjectRoot: true, canUseEvents: true }); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: app.path, - projectRootPath: projectRoot - } - }); + openFilesForSession([{ file: app, projectRootPath: projectRoot }], session); const service = session.getProjectService(); checkNumberOfProjects(service, { inferredProjects: 1 }); const project = service.inferredProjects[0]; checkProjectActualFiles(project, [libFile.path, app.path]); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: backendTest.path, - projectRootPath: projectRoot - } - }); + openFilesForSession([{ file: backendTest, projectRootPath: projectRoot }], session); checkNumberOfProjects(service, { inferredProjects: 1 }); checkProjectActualFiles(project, files.map(f => f.path)); checkErrors([backendTest.path, app.path]); - session.executeCommandSeq({ - command: protocol.CommandTypes.Close, - arguments: { - file: backendTest.path - } - }); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: serverUtilities.path, - projectRootPath: projectRoot - } - }); + closeFilesForSession([backendTest], session); + openFilesForSession([{ file: serverUtilities.path, projectRootPath: projectRoot }], session); checkErrors([serverUtilities.path, app.path]); function checkErrors(openFiles: [string, string]) { @@ -4980,7 +4981,7 @@ namespace ts.projectSystem { assert.isTrue(error2Result.length === 0); }); - it("should report semanitc errors for loose JS files with '// @ts-check' and skipLibCheck=true", () => { + it("should report semantic errors for loose JS files with '// @ts-check' and skipLibCheck=true", () => { const jsFile = { path: "/a/jsFile.js", content: ` @@ -4999,10 +5000,10 @@ namespace ts.projectSystem { ); const errorResult = session.executeCommand(getErrRequest).response; assert.isTrue(errorResult.length === 1); - assert.equal(errorResult[0].code, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code); + assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code); }); - it("should report semanitc errors for configured js project with '// @ts-check' and skipLibCheck=true", () => { + it("should report semantic errors for configured js project with '// @ts-check' and skipLibCheck=true", () => { const jsconfigFile = { path: "/a/jsconfig.json", content: "{}" @@ -5026,10 +5027,10 @@ namespace ts.projectSystem { ); const errorResult = session.executeCommand(getErrRequest).response; assert.isTrue(errorResult.length === 1); - assert.equal(errorResult[0].code, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code); + assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code); }); - it("should report semanitc errors for configured js project with checkJs=true and skipLibCheck=true", () => { + it("should report semantic errors for configured js project with checkJs=true and skipLibCheck=true", () => { const jsconfigFile = { path: "/a/jsconfig.json", content: JSON.stringify({ @@ -5055,7 +5056,7 @@ namespace ts.projectSystem { ); const errorResult = session.executeCommand(getErrRequest).response; assert.isTrue(errorResult.length === 1); - assert.equal(errorResult[0].code, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code); + assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code); }); }); @@ -7869,72 +7870,42 @@ namespace ts.projectSystem { const host = createServerHost(files); const session = createSession(host); const projectService = session.getProjectService(); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: aFile.path, - projectRootPath: folderA - } - }); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: bFile.path, - projectRootPath: folderB - } - }); - - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: aFc, - projectRootPath: folderA - } - }); - session.executeCommandSeq({ - command: protocol.CommandTypes.Open, - arguments: { - file: bFc, - projectRootPath: folderB - } - }); + openFilesForSession( + [ + { file: aFile, projectRootPath: folderA }, + { file: bFile, projectRootPath: folderB }, + { file: aFc, projectRootPath: folderA }, + { file: bFc, projectRootPath: folderB }, + ], + session); checkNumberOfProjects(projectService, { configuredProjects: 2 }); assert.isDefined(projectService.configuredProjects.get(aTsconfig.path)); assert.isDefined(projectService.configuredProjects.get(bTsconfig.path)); - verifyRenameResponse(session.executeCommandSeq({ - command: protocol.CommandTypes.Rename, - arguments: { - file: aFc, - line: 1, - offset: 14, - findInStrings: false, - findInComments: false - } - }).response as protocol.RenameResponseBody); - - function verifyRenameResponse({ info, locs }: protocol.RenameResponseBody) { - assert.isTrue(info.canRename); - assert.equal(locs.length, 4); - verifyLocations(0, aFile.path, aFc); - verifyLocations(2, bFile.path, bFc); + const response = executeSessionRequest(session, protocol.CommandTypes.Rename, { file: aFc, ...protocolLocationFromSubstring(cFile.content, "C") }); - function verifyLocations(locStartIndex: number, firstFile: string, secondFile: string) { - assert.deepEqual(locs[locStartIndex], { - file: firstFile, - locs: [ - { start: { line: 1, offset: 39 }, end: { line: 1, offset: 40 } }, - { start: { line: 1, offset: 9 }, end: { line: 1, offset: 10 } } - ] - }); - assert.deepEqual(locs[locStartIndex + 1], { - file: secondFile, - locs: [ - { start: { line: 1, offset: 14 }, end: { line: 1, offset: 15 } } - ] - }); - } - } + assert.equal(aFile.content, bFile.content); + const abLocs: protocol.TextSpan[] = [ + protocolTextSpanFromSubstring(aFile.content, "C"), + protocolTextSpanFromSubstring(aFile.content, "C", { index: 1 }), + ]; + const cLocs: protocol.TextSpan[] = [protocolTextSpanFromSubstring(cFile.content, "C")]; + assert.deepEqual(response, { + info: { + canRename: true, + displayName: "C", + fullDisplayName: '"/users/username/projects/a/c/fc".C', + kind: ScriptElementKind.constElement, + kindModifiers: ScriptElementKindModifier.exportedModifier, + localizedErrorMessage: undefined, + }, + locs: [ + { file: aFc, locs: cLocs }, + { file: aFile.path, locs: abLocs }, + { file: bFc, locs: cLocs }, + { file: bFile.path, locs: abLocs }, + ], + }); }); describe("module resolution when symlinked folder contents change and resolve modules", () => { @@ -8519,7 +8490,7 @@ new C();` }); }); - it("when watching directories for failed lookup locations in amd resolution", () => { + describe("when watching directories for failed lookup locations in amd resolution", () => { const projectRoot = "/user/username/projects/project"; const nodeFile: File = { path: `${projectRoot}/src/typings/node.d.ts`, @@ -8563,19 +8534,35 @@ export const x = 10;` } }) }; - const files = [nodeFile, electronFile, srcFile, moduleFile, configFile, libFile]; - const host = createServerHost(files); - const service = createProjectService(host); - service.openClientFile(srcFile.path, srcFile.content, ScriptKind.TS, projectRoot); - checkProjectActualFiles(service.configuredProjects.get(configFile.path)!, files.map(f => f.path)); - checkWatchedFilesDetailed(host, mapDefined(files, f => f === srcFile ? undefined : f.path), 1); - checkWatchedDirectoriesDetailed(host, [`${projectRoot}`], 1, /*recursive*/ false); // failed lookup for fs - const expectedWatchedDirectories = createMap(); - expectedWatchedDirectories.set(`${projectRoot}/src`, 2); // Wild card and failed lookup - expectedWatchedDirectories.set(`${projectRoot}/somefolder`, 1); // failed lookup for somefolder/module2 - expectedWatchedDirectories.set(`${projectRoot}/node_modules`, 1); // failed lookup for with node_modules/@types/fs - expectedWatchedDirectories.set(`${projectRoot}/src/typings`, 1); // typeroot directory - checkWatchedDirectoriesDetailed(host, expectedWatchedDirectories, /*recursive*/ true); + + function verifyModuleResolution(useNodeFile: boolean) { + const files = [...(useNodeFile ? [nodeFile] : []), electronFile, srcFile, moduleFile, configFile, libFile]; + const host = createServerHost(files); + const service = createProjectService(host); + service.openClientFile(srcFile.path, srcFile.content, ScriptKind.TS, projectRoot); + checkProjectActualFiles(service.configuredProjects.get(configFile.path)!, files.map(f => f.path)); + checkWatchedFilesDetailed(host, mapDefined(files, f => f === srcFile ? undefined : f.path), 1); + if (useNodeFile) { + checkWatchedDirectories(host, emptyArray, /*recursive*/ false); // since fs resolves to ambient module, shouldnt watch failed lookup + } + else { + checkWatchedDirectoriesDetailed(host, [`${projectRoot}`], 1, /*recursive*/ false); // failed lookup for fs + } + const expectedWatchedDirectories = createMap(); + expectedWatchedDirectories.set(`${projectRoot}/src`, 2); // Wild card and failed lookup + expectedWatchedDirectories.set(`${projectRoot}/somefolder`, 1); // failed lookup for somefolder/module2 + expectedWatchedDirectories.set(`${projectRoot}/node_modules`, 1); // failed lookup for with node_modules/@types/fs + expectedWatchedDirectories.set(`${projectRoot}/src/typings`, 1); // typeroot directory + checkWatchedDirectoriesDetailed(host, expectedWatchedDirectories, /*recursive*/ true); + } + + it("when resolves to ambient module", () => { + verifyModuleResolution(/*useNodeFile*/ true); + }); + + it("when resolution fails", () => { + verifyModuleResolution(/*useNodeFile*/ false); + }); }); }); @@ -8606,10 +8593,10 @@ export const x = 10;` tscWatchDirectory === Tsc_WatchDirectory.WatchFile ? expectedWatchedFiles : createMap(); - // For failed resolution lookup and tsconfig files - mapOfDirectories.set(projectFolder, 2); + // For failed resolution lookup and tsconfig files => cached so only watched only once + mapOfDirectories.set(projectFolder, 1); // Through above recursive watches - mapOfDirectories.set(projectSrcFolder, 2); + mapOfDirectories.set(projectSrcFolder, 1); // node_modules/@types folder mapOfDirectories.set(`${projectFolder}/${nodeModulesAtTypes}`, 1); const expectedCompletions = ["file1"]; @@ -8684,7 +8671,7 @@ export const x = 10;` Debug.assert(!!project.resolveModuleNames); - const edits = project.getLanguageService().getEditsForFileRename("/old.ts", "/new.ts", testFormatOptions, defaultPreferences); + const edits = project.getLanguageService().getEditsForFileRename("/old.ts", "/new.ts", testFormatOptions, emptyOptions); assert.deepEqual>(edits, [{ fileName: "/user.ts", textChanges: [{ @@ -8705,7 +8692,7 @@ export const x = 10;` }; const aTsconfig: File = { path: "/a/tsconfig.json", - content: "{}", + content: JSON.stringify({ files: ["./old.ts", "./user.ts"] }), }; const bUserTs: File = { path: "/b/user.ts", @@ -8720,12 +8707,15 @@ export const x = 10;` const session = createSession(host); openFilesForSession([aUserTs, bUserTs], session); - const renameRequest = makeSessionRequest(CommandNames.GetEditsForFileRename, { - oldFilePath: "/a/old.ts", + const response = executeSessionRequest(session, CommandNames.GetEditsForFileRename, { + oldFilePath: aOldTs.path, newFilePath: "/a/new.ts", }); - const response = session.executeCommand(renameRequest).response as protocol.GetEditsForFileRenameResponse["body"]; - assert.deepEqual(response, [ + assert.deepEqual>(response, [ + { + fileName: aTsconfig.path, + textChanges: [{ ...protocolTextSpanFromSubstring(aTsconfig.content, "./old.ts"), newText: "new.ts" }], + }, { fileName: aUserTs.path, textChanges: [{ ...protocolTextSpanFromSubstring(aUserTs.content, "./old"), newText: "./new" }], @@ -8736,6 +8726,31 @@ export const x = 10;` }, ]); }); + + it("works with file moved to inferred project", () => { + const aTs: File = { path: "/a.ts", content: 'import {} from "./b";' }; + const cTs: File = { path: "/c.ts", content: "export {};" }; + const tsconfig: File = { path: "/tsconfig.json", content: JSON.stringify({ files: ["./a.ts", "./b.ts"] }) }; + + const host = createServerHost([aTs, cTs, tsconfig]); + const session = createSession(host); + openFilesForSession([aTs, cTs], session); + + const response = executeSessionRequest(session, CommandNames.GetEditsForFileRename, { + oldFilePath: "/b.ts", + newFilePath: cTs.path, + }); + assert.deepEqual>(response, [ + { + fileName: "/tsconfig.json", + textChanges: [{ ...protocolTextSpanFromSubstring(tsconfig.content, "./b.ts"), newText: "c.ts" }], + }, + { + fileName: "/a.ts", + textChanges: [{ ...protocolTextSpanFromSubstring(aTs.content, "./b"), newText: "./c" }], + }, + ]); + }); }); describe("tsserverProjectSystem document registry in project service", () => { @@ -8830,4 +8845,522 @@ export const x = 10;` assert.equal(moduleInfo.cacheSourceFile.sourceFile.text, updatedModuleContent); }); }); + + describe("tsserverProjectSystem syntax operations", () => { + function navBarFull(session: TestSession, file: File) { + return JSON.stringify(session.executeCommandSeq({ + command: protocol.CommandTypes.NavBarFull, + arguments: { file: file.path } + }).response); + } + + function openFile(session: TestSession, file: File) { + session.executeCommandSeq({ + command: protocol.CommandTypes.Open, + arguments: { file: file.path, fileContent: file.content } + }); + } + + it("works when file is removed and added with different content", () => { + const projectRoot = "/user/username/projects/myproject"; + const app: File = { + path: `${projectRoot}/app.ts`, + content: "console.log('Hello world');" + }; + const unitTest1: File = { + path: `${projectRoot}/unitTest1.ts`, + content: `import assert = require('assert'); + +describe("Test Suite 1", () => { + it("Test A", () => { + assert.ok(true, "This shouldn't fail"); + }); + + it("Test B", () => { + assert.ok(1 === 1, "This shouldn't fail"); + assert.ok(false, "This should fail"); + }); +});` + }; + const tsconfig: File = { + path: `${projectRoot}/tsconfig.json`, + content: "{}" + }; + const files = [app, libFile, tsconfig]; + const host = createServerHost(files); + const session = createSession(host); + const service = session.getProjectService(); + openFile(session, app); + + checkNumberOfProjects(service, { configuredProjects: 1 }); + const project = service.configuredProjects.get(tsconfig.path)!; + const expectedFilesWithoutUnitTest1 = files.map(f => f.path); + checkProjectActualFiles(project, expectedFilesWithoutUnitTest1); + + host.writeFile(unitTest1.path, unitTest1.content); + host.runQueuedTimeoutCallbacks(); + const expectedFilesWithUnitTest1 = expectedFilesWithoutUnitTest1.concat(unitTest1.path); + checkProjectActualFiles(project, expectedFilesWithUnitTest1); + + openFile(session, unitTest1); + checkProjectActualFiles(project, expectedFilesWithUnitTest1); + + const navBarResultUnitTest1 = navBarFull(session, unitTest1); + host.removeFile(unitTest1.path); + host.checkTimeoutQueueLengthAndRun(2); + checkProjectActualFiles(project, expectedFilesWithoutUnitTest1); + + session.executeCommandSeq({ + command: protocol.CommandTypes.Close, + arguments: { file: unitTest1.path } + }); + checkProjectActualFiles(project, expectedFilesWithoutUnitTest1); + + const unitTest1WithChangedContent: File = { + path: unitTest1.path, + content: `import assert = require('assert'); + +export function Test1() { + assert.ok(true, "This shouldn't fail"); +}; + +export function Test2() { + assert.ok(1 === 1, "This shouldn't fail"); + assert.ok(false, "This should fail"); +};` + }; + host.writeFile(unitTest1.path, unitTest1WithChangedContent.content); + host.runQueuedTimeoutCallbacks(); + checkProjectActualFiles(project, expectedFilesWithUnitTest1); + + openFile(session, unitTest1WithChangedContent); + checkProjectActualFiles(project, expectedFilesWithUnitTest1); + const sourceFile = project.getLanguageService().getNonBoundSourceFile(unitTest1WithChangedContent.path); + assert.strictEqual(sourceFile.text, unitTest1WithChangedContent.content); + + const navBarResultUnitTest1WithChangedContent = navBarFull(session, unitTest1WithChangedContent); + assert.notStrictEqual(navBarResultUnitTest1WithChangedContent, navBarResultUnitTest1, "With changes in contents of unitTest file, we should see changed naviagation bar item result"); + }); + }); + + function makeSampleProjects() { + const aTs: File = { + path: "/a/a.ts", + content: "export function fnA() {}\nexport interface IfaceA {}\nexport const instanceA: IfaceA = {};", + }; + const compilerOptions: CompilerOptions = { + outDir: "bin", + declaration: true, + declarationMap: true, + composite: true, + }; + const configContent = JSON.stringify({ compilerOptions }); + const aTsconfig: File = { path: "/a/tsconfig.json", content: configContent }; + + const aDtsMapContent: SourceMapSection = { + version: 3, + file: "a.d.ts", + sourceRoot: "", + sources: ["../a.ts"], + names: [], + mappings: "AAAA,wBAAgB,GAAG,SAAK;AACxB,MAAM,WAAW,MAAM;CAAG;AAC1B,eAAO,MAAM,SAAS,EAAE,MAAW,CAAC" + }; + const aDtsMap: File = { + path: "/a/bin/a.d.ts.map", + content: JSON.stringify(aDtsMapContent), + }; + const aDts: File = { + path: "/a/bin/a.d.ts", + // Need to mangle the sourceMappingURL part or it breaks the build + content: `export declare function fnA(): void;\nexport interface IfaceA {\n}\nexport declare const instanceA: IfaceA;\n//# source${""}MappingURL=a.d.ts.map`, + }; + + const bTs: File = { + path: "/b/b.ts", + content: "export function fnB() {}", + }; + const bTsconfig: File = { path: "/b/tsconfig.json", content: configContent }; + + const bDtsMapContent: SourceMapSection = { + version: 3, + file: "b.d.ts", + sourceRoot: "", + sources: ["../b.ts"], + names: [], + mappings: "AAAA,wBAAgB,GAAG,SAAK", + }; + const bDtsMap: File = { + path: "/b/bin/b.d.ts.map", + content: JSON.stringify(bDtsMapContent), + }; + const bDts: File = { + // Need to mangle the sourceMappingURL part or it breaks the build + path: "/b/bin/b.d.ts", + content: `export declare function fnB(): void;\n//# source${""}MappingURL=b.d.ts.map`, + }; + + const userTs: File = { + path: "/user/user.ts", + content: 'import { fnA, instanceA } from "../a/bin/a";\nimport { fnB } from "../b/bin/b";\nexport function fnUser() { fnA(); fnB(); instanceA; }', + }; + + const host = createServerHost([aTs, aTsconfig, aDtsMap, aDts, bTsconfig, bTs, bDtsMap, bDts, userTs]); + const session = createSession(host); + + checkDeclarationFiles(aTs, session, [aDtsMap, aDts]); + checkDeclarationFiles(bTs, session, [bDtsMap, bDts]); + + // Testing what happens if we delete the original sources. + host.removeFile(bTs.path); + + openFilesForSession([userTs], session); + + return { session, aTs, bDts, userTs }; + } + + describe("tsserverProjectSystem project references", () => { + it("goToDefinition", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.Definition, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "fnA")]); + }); + + it("getDefinitionAndBoundSpan", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.DefinitionAndBoundSpan, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, { + textSpan: protocolTextSpanFromSubstring(userTs.content, "fnA", { index: 1 }), + definitions: [protocolFileSpanFromSubstring(aTs, "fnA")], + }); + }); + + it("goToType", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.TypeDefinition, protocolFileLocationFromSubstring(userTs, "instanceA")); + assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "IfaceA")]); + }); + + it("goToImplementation", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.Implementation, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "fnA")]); + }); + + it("goToDefinition -- target does not exist", () => { + const { session, bDts, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, CommandNames.Definition, protocolFileLocationFromSubstring(userTs, "fnB()")); + // bTs does not exist, so stick with bDts + assert.deepEqual(response, [protocolFileSpanFromSubstring(bDts, "fnB")]); + }); + + it("navigateTo", () => { + const { session, aTs, bDts, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, CommandNames.Navto, { file: userTs.path, searchValue: "fn" }); + assert.deepEqual | undefined>(response, [ + { + ...protocolFileSpanFromSubstring(bDts, "export declare function fnB(): void;"), + name: "fnB", + matchKind: "prefix", + isCaseSensitive: true, + kind: ScriptElementKind.functionElement, + kindModifiers: "export,declare", + }, + { + ...protocolFileSpanFromSubstring(userTs, "export function fnUser() { fnA(); fnB(); instanceA; }"), + name: "fnUser", + matchKind: "prefix", + isCaseSensitive: true, + kind: ScriptElementKind.functionElement, + kindModifiers: "export", + }, + { + ...protocolFileSpanFromSubstring(aTs, "export function fnA() {}"), + name: "fnA", + matchKind: "prefix", + isCaseSensitive: true, + kind: ScriptElementKind.functionElement, + kindModifiers: "export", + }, + ]); + }); + + const referenceATs = (aTs: File): protocol.ReferencesResponseItem => makeReferenceItem(aTs, /*isDefinition*/ true, "fnA", "export function fnA() {}"); + const referencesUserTs = (userTs: File): ReadonlyArray => [ + makeReferenceItem(userTs, /*isDefinition*/ true, "fnA", "import { fnA, instanceA } from \"../a/bin/a\";"), + makeReferenceItem(userTs, /*isDefinition*/ false, "fnA", "export function fnUser() { fnA(); fnB(); instanceA; }", { index: 1 }), + ]; + + it("findAllReferences", () => { + const { session, aTs, userTs } = makeSampleProjects(); + + const response = executeSessionRequest(session, protocol.CommandTypes.References, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, { + refs: [...referencesUserTs(userTs), referenceATs(aTs)], + symbolName: "fnA", + symbolStartOffset: protocolLocationFromSubstring(userTs.content, "fnA()").offset, + symbolDisplayString: "(alias) fnA(): void\nimport fnA", + }); + }); + + it("findAllReferences -- starting at definition", () => { + const { session, aTs, userTs } = makeSampleProjects(); + openFilesForSession([aTs], session); // If it's not opened, the reference isn't found. + const response = executeSessionRequest(session, protocol.CommandTypes.References, protocolFileLocationFromSubstring(aTs, "fnA")); + assert.deepEqual(response, { + refs: [referenceATs(aTs), ...referencesUserTs(userTs)], + symbolName: "fnA", + symbolStartOffset: protocolLocationFromSubstring(aTs.content, "fnA").offset, + symbolDisplayString: "function fnA(): void", + }); + }); + + it("findAllReferencesFull", () => { + const { session, aTs, userTs } = makeSampleProjects(); + + interface ReferencesFullRequest extends protocol.FileLocationRequest { command: protocol.CommandTypes.ReferencesFull; } + interface ReferencesFullResponse extends protocol.Response { body: ReadonlyArray; } + const responseFull = executeSessionRequest(session, protocol.CommandTypes.ReferencesFull, protocolFileLocationFromSubstring(userTs, "fnA()")); + + function fnAVoid(kind: SymbolDisplayPartKind): SymbolDisplayPart[] { + return [ + keywordPart(SyntaxKind.FunctionKeyword), + spacePart(), + displayPart("fnA", kind), + punctuationPart(SyntaxKind.OpenParenToken), + punctuationPart(SyntaxKind.CloseParenToken), + punctuationPart(SyntaxKind.ColonToken), + spacePart(), + keywordPart(SyntaxKind.VoidKeyword), + ]; + } + assert.deepEqual>(responseFull, [ + { + definition: { + ...documentSpanFromSubstring(userTs, "fnA"), + kind: ScriptElementKind.alias, + name: "(alias) function fnA(): void\nimport fnA", + containerKind: ScriptElementKind.unknown, + containerName: "", + displayParts: [ + punctuationPart(SyntaxKind.OpenParenToken), + textPart("alias"), + punctuationPart(SyntaxKind.CloseParenToken), + spacePart(), + ...fnAVoid(SymbolDisplayPartKind.aliasName), + lineBreakPart(), + keywordPart(SyntaxKind.ImportKeyword), + spacePart(), + displayPart("fnA", SymbolDisplayPartKind.aliasName), + ], + }, + references: [ + makeReferenceEntry(userTs, /*isDefinition*/ true, "fnA"), + makeReferenceEntry(userTs, /*isDefinition*/ false, "fnA", { index: 1 }), + ], + }, + { + definition: { + ...documentSpanFromSubstring(aTs, "fnA"), + kind: ScriptElementKind.functionElement, + name: "function fnA(): void", + containerKind: ScriptElementKind.unknown, + containerName: "", + displayParts: fnAVoid(SymbolDisplayPartKind.functionName), + }, + references: [ + makeReferenceEntry(aTs, /*isDefinition*/ true, "fnA"), + ], + } + ]); + }); + + it("findAllReferences -- target does not exist", () => { + const { session, bDts, userTs } = makeSampleProjects(); + + const response = executeSessionRequest(session, protocol.CommandTypes.References, protocolFileLocationFromSubstring(userTs, "fnB()")); + assert.deepEqual(response, { + refs: [ + makeReferenceItem(userTs, /*isDefinition*/ true, "fnB", "import { fnB } from \"../b/bin/b\";"), + makeReferenceItem(userTs, /*isDefinition*/ false, "fnB", "export function fnUser() { fnA(); fnB(); instanceA; }", { index: 1 }), + makeReferenceItem(bDts, /*isDefinition*/ true, "fnB", "export declare function fnB(): void;"), + ], + symbolName: "fnB", + symbolStartOffset: protocolLocationFromSubstring(userTs.content, "fnB()").offset, + symbolDisplayString: "(alias) fnB(): void\nimport fnB", + }); + }); + + const renameATs = (aTs: File): protocol.SpanGroup => ({ + file: aTs.path, + locs: [protocolTextSpanFromSubstring(aTs.content, "fnA")], + }); + const renameUserTs = (userTs: File): protocol.SpanGroup => ({ + file: userTs.path, + locs: [ + protocolTextSpanFromSubstring(userTs.content, "fnA"), + protocolTextSpanFromSubstring(userTs.content, "fnA", { index: 1 }), + ], + }); + + it("renameLocations", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual(response, { + info: { + canRename: true, + displayName: "fnA", + fullDisplayName: "fnA", + kind: ScriptElementKind.alias, + kindModifiers: ScriptElementKindModifier.none, + localizedErrorMessage: undefined, + }, + locs: [renameUserTs(userTs), renameATs(aTs)], + }); + }); + + it("renameLocations -- starting at definition", () => { + const { session, aTs, userTs } = makeSampleProjects(); + openFilesForSession([aTs], session); // If it's not opened, the reference isn't found. + const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(aTs, "fnA")); + assert.deepEqual(response, { + info: { + canRename: true, + displayName: "fnA", + fullDisplayName: '"/a/a".fnA', + kind: ScriptElementKind.functionElement, + kindModifiers: ScriptElementKindModifier.exportedModifier, + localizedErrorMessage: undefined, + }, + locs: [renameATs(aTs), renameUserTs(userTs)], + }); + }); + + it("renameLocationsFull", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.RenameLocationsFull, protocolFileLocationFromSubstring(userTs, "fnA()")); + assert.deepEqual>(response, [ + documentSpanFromSubstring(userTs, "fnA"), + documentSpanFromSubstring(userTs, "fnA", { index: 1 }), + documentSpanFromSubstring(aTs, "fnA"), + ]); + }); + + it("renameLocations -- target does not exist", () => { + const { session, bDts, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.Rename, protocolFileLocationFromSubstring(userTs, "fnB()")); + assert.deepEqual(response, { + info: { + canRename: true, + displayName: "fnB", + fullDisplayName: "fnB", + kind: ScriptElementKind.alias, + kindModifiers: ScriptElementKindModifier.none, + localizedErrorMessage: undefined, + }, + locs: [ + { + file: userTs.path, + locs: [ + protocolTextSpanFromSubstring(userTs.content, "fnB"), + protocolTextSpanFromSubstring(userTs.content, "fnB", { index: 1 }), + ], + }, + { + file: bDts.path, + locs: [protocolTextSpanFromSubstring(bDts.content, "fnB")], + } + ], + }); + + }); + + it("getEditsForFileRename", () => { + const { session, aTs, userTs } = makeSampleProjects(); + const response = executeSessionRequest(session, protocol.CommandTypes.GetEditsForFileRename, { + oldFilePath: aTs.path, + newFilePath: "/a/aNew.ts", + }); + assert.deepEqual>(response, [ + { + fileName: userTs.path, + textChanges: [ + { ...protocolTextSpanFromSubstring(userTs.content, "../a/bin/a"), newText: "../a/bin/aNew" }, + ], + }, + ]); + }); + }); + + describe("Untitled files", () => { + it("Can convert positions to locations", () => { + const aTs: File = { path: "/proj/a.ts", content: "" }; + const tsconfig: File = { path: "/proj/tsconfig.json", content: "{}" }; + const session = createSession(createServerHost([aTs, tsconfig])); + + openFilesForSession([aTs], session); + + const untitledFile = "untitled:^Untitled-1"; + executeSessionRequestNoResponse(session, protocol.CommandTypes.Open, { + file: untitledFile, + fileContent: "let foo = 1;\nfooo/**/", + scriptKindName: "TS", + projectRootPath: "/proj", + }); + + const response = executeSessionRequest(session, protocol.CommandTypes.GetCodeFixes, { + file: untitledFile, + startLine: 2, + startOffset: 1, + endLine: 2, + endOffset: 5, + errorCodes: [Diagnostics.Cannot_find_name_0_Did_you_mean_1.code], + }); + assert.deepEqual | undefined>(response, [ + { + description: "Change spelling to 'foo'", + fixAllDescription: "Fix all detected spelling errors", + fixId: "fixSpelling", + fixName: "spelling", + changes: [{ + fileName: untitledFile, + textChanges: [{ + start: { line: 2, offset: 1 }, + end: { line: 2, offset: 5 }, + newText: "foo", + }], + }], + commands: undefined, + }, + ]); + }); + }); + + function makeReferenceItem(file: File, isDefinition: boolean, text: string, lineText: string, options?: SpanFromSubstringOptions): protocol.ReferencesResponseItem { + return { + ...protocolFileSpanFromSubstring(file, text, options), + isDefinition, + isWriteAccess: isDefinition, + lineText, + }; + } + + function makeReferenceEntry(file: File, isDefinition: boolean, text: string, options?: SpanFromSubstringOptions): ReferenceEntry { + return { + ...documentSpanFromSubstring(file, text, options), + isDefinition, + isWriteAccess: isDefinition, + isInString: undefined, + }; + } + + function checkDeclarationFiles(file: File, session: TestSession, expectedFiles: ReadonlyArray): void { + openFilesForSession([file], session); + const project = Debug.assertDefined(session.getProjectService().getDefaultProjectForFile(file.path as server.NormalizedPath, /*ensureProject*/ false)); + const program = project.getCurrentProgram(); + const output = getFileEmitOutput(program, Debug.assertDefined(program.getSourceFile(file.path)), /*emitOnlyDtsFiles*/ true); + closeFilesForSession([file], session); + + Debug.assert(!output.emitSkipped); + assert.deepEqual(output.outputFiles, expectedFiles.map((e): OutputFile => ({ name: e.path, text: e.content, writeByteOrderMark: false }))); + } } diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index 4aa4932a61af3..acbd4a3574aeb 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -1,7 +1,7 @@ { "compilerOptions": { "pretty": true, - "lib": ["es5"], + "lib": ["es2015"], "target": "es5", "declaration": true, diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index cbb91ae70a843..17f38c3c7ce66 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -199,7 +199,7 @@ namespace ts.server { private write(s: string) { if (this.fd >= 0) { - const buf = new Buffer(s); + const buf = sys.bufferFrom!(s); // tslint:disable-next-line no-null-keyword fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null!); // TODO: GH#18217 } @@ -869,7 +869,7 @@ namespace ts.server { } // Override sys.write because fs.writeSync is not reliable on Node 4 - sys.write = (s: string) => writeMessage(new Buffer(s, "utf8")); + sys.write = (s: string) => writeMessage(sys.bufferFrom!(s, "utf8")); sys.watchFile = (fileName, callback) => { const watchedFile = pollingWatchedFileSet.addFile(fileName, callback); return { diff --git a/tests/baselines/reference/ES5For-of17.errors.txt b/tests/baselines/reference/ES5For-of17.errors.txt index 3b9ab93a565b7..ee24a232bd2af 100644 --- a/tests/baselines/reference/ES5For-of17.errors.txt +++ b/tests/baselines/reference/ES5For-of17.errors.txt @@ -7,6 +7,7 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts(3,20): error for (let v of [v]) { ~ !!! error TS2448: Block-scoped variable 'v' used before its declaration. +!!! related TS2728 tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts:3:14: 'v' is declared here. var x = v; v++; } diff --git a/tests/baselines/reference/ES5For-of20.errors.txt b/tests/baselines/reference/ES5For-of20.errors.txt index d58aa6c781f3d..c72dee5d27ffc 100644 --- a/tests/baselines/reference/ES5For-of20.errors.txt +++ b/tests/baselines/reference/ES5For-of20.errors.txt @@ -8,6 +8,7 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts(4,15): error for (let v of [v]) { ~ !!! error TS2448: Block-scoped variable 'v' used before its declaration. +!!! related TS2728 tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts:3:14: 'v' is declared here. const v; ~ !!! error TS1155: 'const' declarations must be initialized. diff --git a/tests/baselines/reference/ES5For-ofTypeCheck13.types b/tests/baselines/reference/ES5For-ofTypeCheck13.types index 4812ae8d82c4b..a1cdba4359b78 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck13.types +++ b/tests/baselines/reference/ES5For-ofTypeCheck13.types @@ -2,7 +2,7 @@ const strSet: Set = new Set() >strSet : Set >Set : Set ->new Set() : Set +>new Set() : Set >Set : SetConstructor strSet.add('Hello') diff --git a/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt index 0da61368eee3b..207d3569b31ef 100644 --- a/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt +++ b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt @@ -32,6 +32,7 @@ tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(2,31): erro export var Instance = new A(); ~ !!! error TS2449: Class 'A' used before its declaration. +!!! related TS2728 tests/cases/conformance/internalModules/DeclarationMerging/simple.ts:6:7: 'A' is declared here. } // duplicate identifier diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.errors.txt b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.errors.txt index 96864565d85e9..68033f3eeec9f 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.errors.txt +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.errors.txt @@ -35,4 +35,5 @@ tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAnd !!! error TS2339: Property 'fn2' does not exist on type 'typeof A'. var fng2 = A.fng2; ~~~~ -!!! error TS2551: Property 'fng2' does not exist on type 'typeof A'. Did you mean 'fng'? \ No newline at end of file +!!! error TS2551: Property 'fng2' does not exist on type 'typeof A'. Did you mean 'fng'? +!!! related TS2728 tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts:7:21: 'fng' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/aliasDoesNotDuplicateSignatures.types b/tests/baselines/reference/aliasDoesNotDuplicateSignatures.types index ada54494a831e..da8e7f3b8b6ea 100644 --- a/tests/baselines/reference/aliasDoesNotDuplicateSignatures.types +++ b/tests/baselines/reference/aliasDoesNotDuplicateSignatures.types @@ -6,7 +6,7 @@ declare namespace demoNS { >f : () => void } declare module 'demoModule' { ->'demoModule' : typeof 'demoModule' +>'demoModule' : typeof import("demoModule") import alias = demoNS; >alias : typeof alias diff --git a/tests/baselines/reference/ambientDeclarations.types b/tests/baselines/reference/ambientDeclarations.types index 3d0b53ee19d2d..2c1df08edb8ea 100644 --- a/tests/baselines/reference/ambientDeclarations.types +++ b/tests/baselines/reference/ambientDeclarations.types @@ -163,7 +163,7 @@ var q = M1.fn(); // Ambient external module in the global module // Ambient external module with a string literal name that is a top level external module name declare module 'external1' { ->'external1' : typeof 'external1' +>'external1' : typeof import("external1") var q; >q : any diff --git a/tests/baselines/reference/ambientDeclarationsExternal.types b/tests/baselines/reference/ambientDeclarationsExternal.types index 522c9bd1442db..be62a31835475 100644 --- a/tests/baselines/reference/ambientDeclarationsExternal.types +++ b/tests/baselines/reference/ambientDeclarationsExternal.types @@ -20,7 +20,7 @@ var n: number; === tests/cases/conformance/ambient/decls.ts === // Ambient external module with export assignment declare module 'equ' { ->'equ' : typeof 'equ' +>'equ' : typeof import("equ") var x; >x : any @@ -30,7 +30,7 @@ declare module 'equ' { } declare module 'equ2' { ->'equ2' : typeof 'equ2' +>'equ2' : typeof import("equ2") var x: number; >x : number diff --git a/tests/baselines/reference/ambientErrors.types b/tests/baselines/reference/ambientErrors.types index bd4033e93976a..84914d8d645b2 100644 --- a/tests/baselines/reference/ambientErrors.types +++ b/tests/baselines/reference/ambientErrors.types @@ -97,16 +97,16 @@ module M2 { >M2 : any declare module 'nope' { } ->'nope' : typeof 'nope' +>'nope' : typeof import("nope") } // Ambient external module with a string literal name that isn't a top level external module name declare module '../foo' { } ->'../foo' : typeof '../foo' +>'../foo' : typeof import("../foo") // Ambient external module with export assignment and other exported members declare module 'bar' { ->'bar' : typeof 'bar' +>'bar' : typeof import("bar") var n; >n : any diff --git a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types index 1737229413118..27a6610fcd568 100644 --- a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types +++ b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types @@ -10,7 +10,7 @@ var c = new A(); === tests/cases/compiler/ambientExternalModuleWithInternalImportDeclaration_0.ts === declare module 'M' { ->'M' : typeof 'M' +>'M' : typeof import("M") module C { >C : typeof C diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types index f061663aac8ad..2646b9ea0077c 100644 --- a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types @@ -7,7 +7,7 @@ declare module "./relativeModule" { } declare module ".\\relativeModule" { ->".\\relativeModule" : typeof import(".\\\\relativeModule") +>".\\relativeModule" : typeof import(".\\relativeModule") var x: string; >x : string diff --git a/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.types index c943603fb52ee..fc2eb77491a64 100644 --- a/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.types +++ b/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.types @@ -10,7 +10,7 @@ var c = new A(); === tests/cases/compiler/ambientExternalModuleWithoutInternalImportDeclaration_0.ts === declare module 'M' { ->'M' : typeof 'M' +>'M' : typeof import("M") module C { >C : typeof C diff --git a/tests/baselines/reference/anonymousClassExpression2.errors.txt b/tests/baselines/reference/anonymousClassExpression2.errors.txt index 6bc858bc5426b..fb8bec4e315ef 100644 --- a/tests/baselines/reference/anonymousClassExpression2.errors.txt +++ b/tests/baselines/reference/anonymousClassExpression2.errors.txt @@ -17,6 +17,7 @@ tests/cases/compiler/anonymousClassExpression2.ts(13,18): error TS2551: Property this.methodA; // error ~~~~~~~ !!! error TS2551: Property 'methodA' does not exist on type 'B'. Did you mean 'methodB'? +!!! related TS2728 tests/cases/compiler/anonymousClassExpression2.ts:12:9: 'methodB' is declared here. this.methodB; // ok } } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5438ceb07222f..5118830e840ce 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1,6 +1,20 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.0"; + const versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ const version: string; } @@ -46,525 +60,6 @@ declare namespace ts { interface Push { push(...values: T[]): void; } - type EqualityComparer = (a: T, b: T) => boolean; - type Comparer = (a: T, b: T) => Comparison; - enum Comparison { - LessThan = -1, - EqualTo = 0, - GreaterThan = 1 - } -} -declare namespace ts { - /** Create a new map. If a template object is provided, the map will copy entries from it. */ - function createMap(): Map; - function createMapFromEntries(entries: [string, T][]): Map; - function createMapFromTemplate(template: MapLike): Map; - const MapCtr: new () => Map; - function length(array: ReadonlyArray | undefined): number; - /** - * Iterates through 'array' by index and performs the callback on each element of array until the callback - * returns a truthy value, then returns that value. - * If no such value is found, the callback is applied to each element of array and undefined is returned. - */ - function forEach(array: ReadonlyArray | undefined, callback: (element: T, index: number) => U | undefined): U | undefined; - /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ - function firstDefined(array: ReadonlyArray | undefined, callback: (element: T, index: number) => U | undefined): U | undefined; - function firstDefinedIterator(iter: Iterator, callback: (element: T) => U | undefined): U | undefined; - function zipWith(arrayA: ReadonlyArray, arrayB: ReadonlyArray, callback: (a: T, b: U, index: number) => V): V[]; - function zipToIterator(arrayA: ReadonlyArray, arrayB: ReadonlyArray): Iterator<[T, U]>; - function zipToMap(keys: ReadonlyArray, values: ReadonlyArray): Map; - /** - * Iterates through `array` by index and performs the callback on each element of array until the callback - * returns a falsey value, then returns false. - * If no such value is found, the callback is applied to each element of array and `true` is returned. - */ - function every(array: ReadonlyArray, callback: (element: T, index: number) => boolean): boolean; - /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ - function find(array: ReadonlyArray, predicate: (element: T, index: number) => element is U): U | undefined; - function find(array: ReadonlyArray, predicate: (element: T, index: number) => boolean): T | undefined; - function findLast(array: ReadonlyArray, predicate: (element: T, index: number) => element is U): U | undefined; - function findLast(array: ReadonlyArray, predicate: (element: T, index: number) => boolean): T | undefined; - /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ - function findIndex(array: ReadonlyArray, predicate: (element: T, index: number) => boolean, startIndex?: number): number; - function findLastIndex(array: ReadonlyArray, predicate: (element: T, index: number) => boolean, startIndex?: number): number; - /** - * Returns the first truthy result of `callback`, or else fails. - * This is like `forEach`, but never returns undefined. - */ - function findMap(array: ReadonlyArray, callback: (element: T, index: number) => U | undefined): U; - function contains(array: ReadonlyArray | undefined, value: T, equalityComparer?: EqualityComparer): boolean; - function arraysEqual(a: ReadonlyArray, b: ReadonlyArray, equalityComparer?: EqualityComparer): boolean; - function indexOfAnyCharCode(text: string, charCodes: ReadonlyArray, start?: number): number; - function countWhere(array: ReadonlyArray, predicate: (x: T, i: number) => boolean): number; - /** - * Filters an array by a predicate function. Returns the same array instance if the predicate is - * true for all elements, otherwise returns a new array instance containing the filtered subset. - */ - function filter(array: T[], f: (x: T) => x is U): U[]; - function filter(array: T[], f: (x: T) => boolean): T[]; - function filter(array: ReadonlyArray, f: (x: T) => x is U): ReadonlyArray; - function filter(array: ReadonlyArray, f: (x: T) => boolean): ReadonlyArray; - function filter(array: T[] | undefined, f: (x: T) => x is U): U[] | undefined; - function filter(array: T[] | undefined, f: (x: T) => boolean): T[] | undefined; - function filter(array: ReadonlyArray | undefined, f: (x: T) => x is U): ReadonlyArray | undefined; - function filter(array: ReadonlyArray | undefined, f: (x: T) => boolean): ReadonlyArray | undefined; - function filterMutate(array: T[], f: (x: T, i: number, array: T[]) => boolean): void; - function clear(array: {}[]): void; - function map(array: ReadonlyArray, f: (x: T, i: number) => U): U[]; - function map(array: ReadonlyArray | undefined, f: (x: T, i: number) => U): U[] | undefined; - function mapIterator(iter: Iterator, mapFn: (x: T) => U): Iterator; - function sameMap(array: T[], f: (x: T, i: number) => T): T[]; - function sameMap(array: ReadonlyArray, f: (x: T, i: number) => T): ReadonlyArray; - function sameMap(array: T[] | undefined, f: (x: T, i: number) => T): T[] | undefined; - function sameMap(array: ReadonlyArray | undefined, f: (x: T, i: number) => T): ReadonlyArray | undefined; - /** - * Flattens an array containing a mix of array or non-array elements. - * - * @param array The array to flatten. - */ - function flatten(array: ReadonlyArray | undefined>): T[]; - function flatten(array: ReadonlyArray | undefined> | undefined): T[] | undefined; - /** - * Maps an array. If the mapped value is an array, it is spread into the result. - * - * @param array The array to map. - * @param mapfn The callback used to map the result into one or more values. - */ - function flatMap(array: ReadonlyArray, mapfn: (x: T, i: number) => U | ReadonlyArray | undefined): U[]; - function flatMap(array: ReadonlyArray | undefined, mapfn: (x: T, i: number) => U | ReadonlyArray | undefined): U[] | undefined; - function flatMapIterator(iter: Iterator, mapfn: (x: T) => U[] | Iterator | undefined): Iterator; - /** - * Maps an array. If the mapped value is an array, it is spread into the result. - * Avoids allocation if all elements map to themselves. - * - * @param array The array to map. - * @param mapfn The callback used to map the result into one or more values. - */ - function sameFlatMap(array: T[], mapfn: (x: T, i: number) => T | ReadonlyArray): T[]; - function sameFlatMap(array: ReadonlyArray, mapfn: (x: T, i: number) => T | ReadonlyArray): ReadonlyArray; - function mapAllOrFail(array: ReadonlyArray, mapFn: (x: T, i: number) => U | undefined): U[] | undefined; - function mapDefined(array: ReadonlyArray | undefined, mapFn: (x: T, i: number) => U | undefined): U[]; - function mapDefinedIterator(iter: Iterator, mapFn: (x: T) => U | undefined): Iterator; - const emptyIterator: Iterator; - function singleIterator(value: T): Iterator; - /** - * Maps contiguous spans of values with the same key. - * - * @param array The array to map. - * @param keyfn A callback used to select the key for an element. - * @param mapfn A callback used to map a contiguous chunk of values to a single value. - */ - function spanMap(array: ReadonlyArray, keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[]; - function spanMap(array: ReadonlyArray | undefined, keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[] | undefined; - function mapEntries(map: ReadonlyMap, f: (key: string, value: T) => [string, U]): Map; - function mapEntries(map: ReadonlyMap | undefined, f: (key: string, value: T) => [string, U]): Map | undefined; - function some(array: ReadonlyArray | undefined): array is ReadonlyArray; - function some(array: ReadonlyArray | undefined, predicate: (value: T) => boolean): boolean; - /** Calls the callback with (start, afterEnd) index pairs for each range where 'pred' is true. */ - function getRangesWhere(arr: ReadonlyArray, pred: (t: T) => boolean, cb: (start: number, afterEnd: number) => void): void; - function concatenate(array1: T[], array2: T[]): T[]; - function concatenate(array1: ReadonlyArray, array2: ReadonlyArray): ReadonlyArray; - function concatenate(array1: T[] | undefined, array2: T[] | undefined): T[]; - function concatenate(array1: ReadonlyArray | undefined, array2: ReadonlyArray | undefined): ReadonlyArray; - /** - * Deduplicates an unsorted array. - * @param equalityComparer An optional `EqualityComparer` used to determine if two values are duplicates. - * @param comparer An optional `Comparer` used to sort entries before comparison, though the - * result will remain in the original order in `array`. - */ - function deduplicate(array: ReadonlyArray, equalityComparer?: EqualityComparer, comparer?: Comparer): T[]; - function deduplicate(array: ReadonlyArray | undefined, equalityComparer?: EqualityComparer, comparer?: Comparer): T[] | undefined; - function insertSorted(array: SortedArray, insert: T, compare: Comparer): void; - function sortAndDeduplicate(array: ReadonlyArray, comparer: Comparer, equalityComparer?: EqualityComparer): T[]; - function arrayIsEqualTo(array1: ReadonlyArray | undefined, array2: ReadonlyArray | undefined, equalityComparer?: (a: T, b: T) => boolean): boolean; - /** - * Compacts an array, removing any falsey elements. - */ - function compact(array: T[]): T[]; - function compact(array: ReadonlyArray): ReadonlyArray; - /** - * Gets the relative complement of `arrayA` with respect to `arrayB`, returning the elements that - * are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted - * based on the provided comparer. - */ - function relativeComplement(arrayA: T[] | undefined, arrayB: T[] | undefined, comparer: Comparer): T[] | undefined; - function sum, K extends string>(array: ReadonlyArray, prop: K): number; - /** - * Appends a value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param value The value to append to the array. If `value` is `undefined`, nothing is - * appended. - */ - function append(to: T[], value: T | undefined): T[]; - function append(to: T[] | undefined, value: T): T[]; - function append(to: T[] | undefined, value: T | undefined): T[] | undefined; - function append(to: Push, value: T | undefined): void; - /** - * Appends a range of value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - * @param start The offset in `from` at which to start copying values. - * @param end The offset in `from` at which to stop copying values (non-inclusive). - */ - function addRange(to: T[], from: ReadonlyArray | undefined, start?: number, end?: number): T[]; - function addRange(to: T[] | undefined, from: ReadonlyArray | undefined, start?: number, end?: number): T[] | undefined; - /** - * @return Whether the value was added. - */ - function pushIfUnique(array: T[], toAdd: T, equalityComparer?: EqualityComparer): boolean; - /** - * Unlike `pushIfUnique`, this can take `undefined` as an input, and returns a new array. - */ - function appendIfUnique(array: T[] | undefined, toAdd: T, equalityComparer?: EqualityComparer): T[]; - /** - * Returns a new sorted array. - */ - function sort(array: ReadonlyArray, comparer: Comparer): T[]; - function arrayIterator(array: ReadonlyArray): Iterator; - /** - * Stable sort of an array. Elements equal to each other maintain their relative position in the array. - */ - function stableSort(array: ReadonlyArray, comparer: Comparer): T[]; - function rangeEquals(array1: ReadonlyArray, array2: ReadonlyArray, pos: number, end: number): boolean; - /** - * Returns the element at a specific offset in an array if non-empty, `undefined` otherwise. - * A negative offset indicates the element should be retrieved from the end of the array. - */ - function elementAt(array: ReadonlyArray | undefined, offset: number): T | undefined; - /** - * Returns the first element of an array if non-empty, `undefined` otherwise. - */ - function firstOrUndefined(array: ReadonlyArray): T | undefined; - function first(array: ReadonlyArray): T; - /** - * Returns the last element of an array if non-empty, `undefined` otherwise. - */ - function lastOrUndefined(array: ReadonlyArray): T | undefined; - function last(array: ReadonlyArray): T; - /** - * Returns the only element of an array if it contains only one element, `undefined` otherwise. - */ - function singleOrUndefined(array: ReadonlyArray | undefined): T | undefined; - /** - * Returns the only element of an array if it contains only one element; otheriwse, returns the - * array. - */ - function singleOrMany(array: T[]): T | T[]; - function singleOrMany(array: ReadonlyArray): T | ReadonlyArray; - function singleOrMany(array: T[] | undefined): T | T[] | undefined; - function singleOrMany(array: ReadonlyArray | undefined): T | ReadonlyArray | undefined; - function replaceElement(array: ReadonlyArray, index: number, value: T): T[]; - /** - * Performs a binary search, finding the index at which `value` occurs in `array`. - * If no such index is found, returns the 2's-complement of first index at which - * `array[index]` exceeds `value`. - * @param array A sorted array whose first element must be no larger than number - * @param value The value to be searched for in the array. - * @param keySelector A callback used to select the search key from `value` and each element of - * `array`. - * @param keyComparer A callback used to compare two keys in a sorted array. - * @param offset An offset into `array` at which to start the search. - */ - function binarySearch(array: ReadonlyArray, value: T, keySelector: (v: T) => U, keyComparer: Comparer, offset?: number): number; - function reduceLeft(array: ReadonlyArray | undefined, f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceLeft(array: ReadonlyArray, f: (memo: T, value: T, i: number) => T): T | undefined; - /** - * Indicates whether a map-like contains an own property with the specified key. - * - * @param map A map-like. - * @param key A property key. - */ - function hasProperty(map: MapLike, key: string): boolean; - /** - * Gets the value of an owned property in a map-like. - * - * @param map A map-like. - * @param key A property key. - */ - function getProperty(map: MapLike, key: string): T | undefined; - /** - * Gets the owned, enumerable property keys of a map-like. - */ - function getOwnKeys(map: MapLike): string[]; - function getOwnValues(sparseArray: T[]): T[]; - /** Shims `Array.from`. */ - function arrayFrom(iterator: Iterator, map: (t: T) => U): U[]; - function arrayFrom(iterator: Iterator): T[]; - function assign(t: T, ...args: (T | undefined)[]): T; - /** - * Performs a shallow equality comparison of the contents of two map-likes. - * - * @param left A map-like whose properties should be compared. - * @param right A map-like whose properties should be compared. - */ - function equalOwnProperties(left: MapLike | undefined, right: MapLike | undefined, equalityComparer?: EqualityComparer): boolean; - /** - * Creates a map from the elements of an array. - * - * @param array the array of input elements. - * @param makeKey a function that produces a key for a given element. - * - * This function makes no effort to avoid collisions; if any two elements produce - * the same key with the given 'makeKey' function, then the element with the higher - * index in the array will be the one associated with the produced key. - */ - function arrayToMap(array: ReadonlyArray, makeKey: (value: T) => string | undefined): Map; - function arrayToMap(array: ReadonlyArray, makeKey: (value: T) => string | undefined, makeValue: (value: T) => U): Map; - function arrayToNumericMap(array: ReadonlyArray, makeKey: (value: T) => number): T[]; - function arrayToNumericMap(array: ReadonlyArray, makeKey: (value: T) => number, makeValue: (value: T) => U): U[]; - function arrayToMultiMap(values: ReadonlyArray, makeKey: (value: T) => string): MultiMap; - function arrayToMultiMap(values: ReadonlyArray, makeKey: (value: T) => string, makeValue: (value: T) => U): MultiMap; - function group(values: ReadonlyArray, getGroupId: (value: T) => string): ReadonlyArray>; - function clone(object: T): T; - function extend(first: T1, second: T2): T1 & T2; - 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; - } - function createMultiMap(): MultiMap; - /** - * Tests whether a value is an array. - */ - function isArray(value: any): value is ReadonlyArray<{}>; - function toArray(value: T | T[]): T[]; - function toArray(value: T | ReadonlyArray): ReadonlyArray; - /** - * Tests whether a value is string - */ - function isString(text: any): text is string; - function tryCast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined; - function cast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut; - /** Does nothing. */ - function noop(_?: {} | null | undefined): void; - /** Do nothing and return false */ - function returnFalse(): false; - /** Do nothing and return true */ - function returnTrue(): true; - /** Returns its argument. */ - function identity(x: T): T; - /** Returns lower case string */ - function toLowerCase(x: string): string; - /** Throws an error because a function is not implemented. */ - function notImplemented(): never; - function memoize(callback: () => T): () => T; - /** - * High-order function, creates a function that executes a function composition. - * For example, `chain(a, b)` is the equivalent of `x => ((a', b') => y => b'(a'(y)))(a(x), b(x))` - * - * @param args The functions to chain. - */ - function chain(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U; - /** - * High-order function, composes functions. Note that functions are composed inside-out; - * for example, `compose(a, b)` is the equivalent of `x => b(a(x))`. - * - * @param args The functions to compose. - */ - function compose(...args: ((t: T) => T)[]): (t: T) => T; - enum AssertionLevel { - None = 0, - Normal = 1, - Aggressive = 2, - VeryAggressive = 3 - } - /** - * Safer version of `Function` which should not be called. - * Every function should be assignable to this, but this should not be assignable to every function. - */ - type AnyFunction = (...args: never[]) => void; - namespace Debug { - let currentAssertionLevel: AssertionLevel; - let isDebugging: boolean; - function shouldAssert(level: AssertionLevel): boolean; - function assert(expression: boolean, message?: string, verboseDebugInfo?: string | (() => string), stackCrawlMark?: AnyFunction): void; - function assertEqual(a: T, b: T, msg?: string, msg2?: string): void; - function assertLessThan(a: number, b: number, msg?: string): void; - function assertLessThanOrEqual(a: number, b: number): void; - function assertGreaterThanOrEqual(a: number, b: number): void; - function fail(message?: string, stackCrawlMark?: AnyFunction): never; - function assertDefined(value: T | null | undefined, message?: string): T; - function assertEachDefined>(value: A, message?: string): A; - function assertNever(member: never, message?: string, stackCrawlMark?: AnyFunction): never; - function getFunctionName(func: AnyFunction): any; - } - function equateValues(a: T, b: T): boolean; - /** - * Compare the equality of two strings using a case-sensitive ordinal comparison. - * - * Case-sensitive comparisons compare both strings one code-point at a time using the integer - * value of each code-point after applying `toUpperCase` to each string. We always map both - * strings to their upper-case form as some unicode characters do not properly round-trip to - * lowercase (such as `ẞ` (German sharp capital s)). - */ - function equateStringsCaseInsensitive(a: string, b: string): boolean; - /** - * Compare the equality of two strings using a case-sensitive ordinal comparison. - * - * Case-sensitive comparisons compare both strings one code-point at a time using the - * integer value of each code-point. - */ - function equateStringsCaseSensitive(a: string, b: string): boolean; - /** - * Compare two numeric values for their order relative to each other. - * To compare strings, use any of the `compareStrings` functions. - */ - function compareValues(a: number | undefined, b: number | undefined): Comparison; - function min(a: T, b: T, compare: Comparer): T; - /** - * Compare two strings using a case-insensitive ordinal comparison. - * - * Ordinal comparisons are based on the difference between the unicode code points of both - * strings. Characters with multiple unicode representations are considered unequal. Ordinal - * comparisons provide predictable ordering, but place "a" after "B". - * - * Case-insensitive comparisons compare both strings one code-point at a time using the integer - * value of each code-point after applying `toUpperCase` to each string. We always map both - * strings to their upper-case form as some unicode characters do not properly round-trip to - * lowercase (such as `ẞ` (German sharp capital s)). - */ - function compareStringsCaseInsensitive(a: string, b: string): Comparison; - /** - * Compare two strings using a case-sensitive ordinal comparison. - * - * Ordinal comparisons are based on the difference between the unicode code points of both - * strings. Characters with multiple unicode representations are considered unequal. Ordinal - * comparisons provide predictable ordering, but place "a" after "B". - * - * Case-sensitive comparisons compare both strings one code-point at a time using the integer - * value of each code-point. - */ - function compareStringsCaseSensitive(a: string | undefined, b: string | undefined): Comparison; - function getStringComparer(ignoreCase?: boolean): typeof compareStringsCaseInsensitive; - function getUILocale(): string | undefined; - function setUILocale(value: string | undefined): void; - /** - * Compare two strings in a using the case-sensitive sort behavior of the UI locale. - * - * Ordering is not predictable between different host locales, but is best for displaying - * ordered data for UI presentation. Characters with multiple unicode representations may - * be considered equal. - * - * Case-sensitive comparisons compare strings that differ in base characters, or - * accents/diacritic marks, or case as unequal. - */ - function compareStringsCaseSensitiveUI(a: string, b: string): Comparison; - function compareProperties(a: T | undefined, b: T | undefined, key: K, comparer: Comparer): Comparison; - /** True is greater than false. */ - function compareBooleans(a: boolean, b: boolean): Comparison; - /** - * Given a name and a list of names that are *not* equal to the name, return a spelling suggestion if there is one that is close enough. - * Names less than length 3 only check for case-insensitive equality, not Levenshtein distance. - * - * If there is a candidate that's the same except for case, return that. - * If there is a candidate that's within one edit of the name, return that. - * Otherwise, return the candidate with the smallest Levenshtein distance, - * except for candidates: - * * With no name - * * Whose length differs from the target name by more than 0.34 of the length of the name. - * * Whose levenshtein distance is more than 0.4 of the length of the name - * (0.4 allows 1 substitution/transposition for every 5 characters, - * and 1 insertion/deletion at 3 characters) - */ - function getSpellingSuggestion(name: string, candidates: T[], getName: (candidate: T) => string | undefined): T | undefined; - function endsWith(str: string, suffix: string): boolean; - function removeSuffix(str: string, suffix: string): string; - function tryRemoveSuffix(str: string, suffix: string): string | undefined; - function stringContains(str: string, substring: string): boolean; - function fileExtensionIs(path: string, extension: string): boolean; - function fileExtensionIsOneOf(path: string, extensions: ReadonlyArray): boolean; - /** - * Takes a string like "jquery-min.4.2.3" and returns "jquery" - */ - function removeMinAndVersionNumbers(fileName: string): string; - /** Remove an item from an array, moving everything to its right one space left. */ - function orderedRemoveItem(array: T[], item: T): boolean; - /** Remove an item by index from an array, moving everything to its right one space left. */ - function orderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItemAt(array: T[], index: number): void; - /** Remove the *first* occurrence of `item` from the array. */ - function unorderedRemoveItem(array: T[], item: T): boolean; - type GetCanonicalFileName = (fileName: string) => string; - function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): GetCanonicalFileName; - /** Represents a "prefix*suffix" pattern. */ - interface Pattern { - prefix: string; - suffix: string; - } - function patternText({ prefix, suffix }: Pattern): string; - /** - * Given that candidate matches pattern, returns the text matching the '*'. - * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" - */ - function matchedText(pattern: Pattern, candidate: string): string; - /** Return the object corresponding to the best pattern to match `candidate`. */ - function findBestPatternMatch(values: ReadonlyArray, getPattern: (value: T) => Pattern, candidate: string): T | undefined; - function startsWith(str: string, prefix: string): boolean; - function removePrefix(str: string, prefix: string): string; - function tryRemovePrefix(str: string, prefix: string, getCanonicalFileName?: GetCanonicalFileName): string | undefined; - function and(f: (arg: T) => boolean, g: (arg: T) => boolean): (arg: T) => boolean; - function or(f: (arg: T) => boolean, g: (arg: T) => boolean): (arg: T) => boolean; - function assertTypeIsNever(_: never): void; - function singleElementArray(t: T | undefined): T[] | undefined; - function enumerateInsertsAndDeletes(newItems: ReadonlyArray, oldItems: ReadonlyArray, comparer: (a: T, b: U) => Comparison, inserted: (newItem: T) => void, deleted: (oldItem: U) => void, unchanged?: (oldItem: U, newItem: T) => void): void; -} -declare namespace ts { - /** Gets a timestamp with (at least) ms resolution */ - const timestamp: () => number; -} -/** Performance measurements for the compiler. */ -declare namespace ts.performance { - /** - * Marks a performance event. - * - * @param markName The name of the mark. - */ - function mark(markName: string): void; - /** - * Adds a performance measurement with the specified name. - * - * @param measureName The name of the performance measurement. - * @param startMarkName The name of the starting mark. If not supplied, the point at which the - * profiler was enabled is used. - * @param endMarkName The name of the ending mark. If not supplied, the current timestamp is - * used. - */ - function measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - /** - * Gets the number of times a marker was encountered. - * - * @param markName The name of the mark. - */ - function getCount(markName: string): number; - /** - * Gets the total duration of all measurements with the supplied name. - * - * @param measureName The name of the measure whose durations should be accumulated. - */ - function getDuration(measureName: string): number; - /** - * Iterate over each measure, performing some action - * - * @param cb The action to perform for each measure - */ - function forEachMeasure(cb: (measureName: string, duration: number) => void): void; - /** Enables (and resets) performance measurements for the compiler. */ - function enable(): void; - /** Disables performance measurements for the compiler. */ - function disable(): void; } declare namespace ts { type Path = string & { @@ -915,9 +410,7 @@ declare namespace ts { FirstJSDocNode = 281, LastJSDocNode = 302, FirstJSDocTagNode = 292, - LastJSDocTagNode = 302, - FirstContextualKeyword = 117, - LastContextualKeyword = 145 + LastJSDocTagNode = 302 } enum NodeFlags { None = 0, @@ -940,18 +433,13 @@ declare namespace ts { JavaScriptFile = 65536, ThisNodeOrAnySubNodesHasError = 131072, HasAggregatedChildData = 262144, - PossiblyContainsDynamicImport = 524288, - PossiblyContainsImportMeta = 1048576, JSDoc = 2097152, - Ambient = 4194304, - InWithStatement = 8388608, JsonFile = 16777216, BlockScoped = 3, ReachabilityCheckFlags = 384, ReachabilityAndEmitFlags = 1408, ContextFlags = 12679168, - TypeExcludesFlags = 20480, - PermanentlySetIncrementalFlags = 1572864 + TypeExcludesFlags = 20480 } enum ModifierFlags { None = 0, @@ -982,42 +470,21 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3 } - 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; - symbol: Symbol; - locals?: SymbolTable; - nextContainer?: Node; - localSymbol?: Symbol; - flowNode?: FlowNode; - emitNode?: EmitNode; - contextualType?: Type; - contextualMapper?: TypeMapper; } interface JSDocContainer { - jsDoc?: JSDoc[]; - jsDocCache?: ReadonlyArray; } type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken; type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; - type MutableNodeArray = NodeArray & T[]; interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; - transformFlags: TransformFlags; } interface Token extends Node { kind: TKind; @@ -1037,17 +504,6 @@ declare namespace ts { type MinusToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; - enum GeneratedIdentifierFlags { - None = 0, - Auto = 1, - Loop = 2, - Unique = 3, - Node = 4, - KindMask = 7, - ReservedInNestedScopes = 8, - Optimistic = 16, - FileLevel = 32 - } interface Identifier extends PrimaryExpression, Declaration { kind: SyntaxKind.Identifier; /** @@ -1056,23 +512,15 @@ declare namespace ts { */ escapedText: __String; originalKeywordKind?: SyntaxKind; - autoGenerateFlags?: GeneratedIdentifierFlags; - autoGenerateId?: number; isInJSDocNamespace?: boolean; - typeArguments?: NodeArray; - jsdocDotPos?: number; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface GeneratedIdentifier extends Identifier { - autoGenerateFlags: GeneratedIdentifierFlags; - } interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; - jsdocDotPos?: number; } type EntityName = Identifier | QualifiedName; type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; @@ -1083,12 +531,6 @@ declare namespace ts { interface NamedDeclaration extends Declaration { name?: DeclarationName; } - interface DynamicNamedDeclaration extends NamedDeclaration { - name: ComputedPropertyName; - } - interface LateBoundDeclaration extends DynamicNamedDeclaration { - name: LateBoundName; - } interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } @@ -1096,9 +538,6 @@ declare namespace ts { kind: SyntaxKind.ComputedPropertyName; expression: Expression; } - interface LateBoundName extends ComputedPropertyName { - expression: EntityNameExpression; - } interface Decorator extends Node { kind: SyntaxKind.Decorator; parent: NamedDeclaration; @@ -1106,7 +545,7 @@ declare namespace ts { } interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; - parent: DeclarationWithTypeParameters | InferTypeNode; + parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -1118,7 +557,6 @@ declare namespace ts { typeParameters?: NodeArray; parameters: NodeArray; type?: TypeNode; - typeArguments?: NodeArray; } type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { @@ -1158,7 +596,6 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - type BindingElementGrandparent = BindingElement["parent"]["parent"]; interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; @@ -1253,7 +690,6 @@ declare namespace ts { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; - returnFlowNode?: FlowNode; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ interface SemicolonClassElement extends ClassElement { @@ -1289,11 +725,6 @@ declare namespace ts { argument: TypeNode; qualifier?: EntityName; } - type LiteralImportTypeNode = ImportTypeNode & { - argument: LiteralTypeNode & { - literal: StringLiteral; - }; - }; interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } @@ -1375,9 +806,6 @@ declare namespace ts { operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword; type: TypeNode; } - interface UniqueTypeOperatorNode extends TypeOperatorNode { - operator: SyntaxKind.UniqueKeyword; - } interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; @@ -1396,9 +824,6 @@ declare namespace ts { } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; - textSourceNode?: Identifier | StringLiteralLike | NumericLiteral; - /** Note: this is only set when synthesizing a node, not during parsing. */ - singleQuote?: boolean; } type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; interface Expression extends Node { @@ -1561,24 +986,8 @@ declare namespace ts { interface NoSubstitutionTemplateLiteral extends LiteralExpression { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - enum TokenFlags { - None = 0, - PrecedingLineBreak = 1, - PrecedingJSDocComment = 2, - Unterminated = 4, - ExtendedUnicodeEscape = 8, - Scientific = 16, - Octal = 32, - HexSpecifier = 64, - BinarySpecifier = 128, - OctalSpecifier = 256, - ContainsSeparator = 512, - BinaryOrOctalSpecifier = 384, - NumericLiteralFlags = 1008 - } interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; - numericLiteralFlags: TokenFlags; } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; @@ -1611,7 +1020,6 @@ declare namespace ts { interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; - multiLine?: boolean; } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; @@ -1629,7 +1037,6 @@ declare namespace ts { } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; - multiLine?: boolean; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; @@ -1713,7 +1120,10 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; } @@ -1778,12 +1188,6 @@ declare namespace ts { interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } - /** - * Marks the end of transformed declaration to properly emit exports. - */ - interface EndOfDeclarationMarker extends Statement { - kind: SyntaxKind.EndOfDeclarationMarker; - } /** * A list of comma-separated expressions. This node is only created by transformations. */ @@ -1791,12 +1195,6 @@ declare namespace ts { kind: SyntaxKind.CommaListExpression; elements: NodeArray; } - /** - * Marks the beginning of a merged transformed declaration. - */ - interface MergeDeclarationMarker extends Statement { - kind: SyntaxKind.MergeDeclarationMarker; - } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1811,7 +1209,6 @@ declare namespace ts { interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; - multiLine?: boolean; } interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; @@ -1821,9 +1218,6 @@ declare namespace ts { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface PrologueDirective extends ExpressionStatement { - expression: StringLiteral; - } interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; @@ -1923,7 +1317,8 @@ declare namespace ts { block: Block; } type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; @@ -1981,9 +1376,6 @@ declare namespace ts { } type ModuleName = Identifier | StringLiteral; type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface AmbientModuleDeclaration extends ModuleDeclaration { - body?: ModuleBlock; - } interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent: ModuleBody | SourceFile; @@ -2285,36 +1677,12 @@ declare namespace ts { path: string; name?: string; } - /** - * Subset of properties from SourceFile that are used in multiple utility functions - */ - interface SourceFileLike { - readonly text: string; - lineMap?: ReadonlyArray; - } - interface RedirectInfo { - /** Source file this redirects to. */ - readonly redirectTarget: SourceFile; - /** - * Source file for the duplicate package. This will not be used by the Program, - * but we need to keep this around so we can watch for changes in underlying. - */ - readonly unredirected: SourceFile; - } interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; statements: NodeArray; endOfFileToken: Token; fileName: string; - path: Path; text: string; - resolvedPath: Path; - /** - * If two source files are for the same version of the same package, one will redirect to the other. - * (See `createRedirectSourceFile` in program.ts.) - * The redirect will have this set. The redirected-to source file will be in `redirectTargetsSet`. - */ - redirectInfo?: RedirectInfo; amdDependencies: ReadonlyArray; moduleName?: string; referencedFiles: ReadonlyArray; @@ -2322,7 +1690,6 @@ declare namespace ts { libReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; isDeclarationFile: boolean; - renamedDependencies?: ReadonlyMap; /** * lib.d.ts should have a reference comment like * @@ -2333,49 +1700,11 @@ declare namespace ts { */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; - scriptKind: ScriptKind; - /** - * The first "most obvious" node that makes a file an external module. - * This is intended to be the first top-level import/export, - * but could be arbitrarily nested (e.g. `import.meta`). - */ - externalModuleIndicator?: Node; - commonJsModuleIndicator?: Node; - identifiers: Map; - nodeCount: number; - identifierCount: number; - symbolCount: number; - parseDiagnostics: DiagnosticWithLocation[]; - bindDiagnostics: DiagnosticWithLocation[]; - bindSuggestionDiagnostics?: DiagnosticWithLocation[]; - jsDocDiagnostics?: DiagnosticWithLocation[]; - additionalSyntacticDiagnostics?: ReadonlyArray; - lineMap: ReadonlyArray; - classifiableNames?: ReadonlyUnderscoreEscapedMap; - resolvedModules?: Map; - resolvedTypeReferenceDirectiveNames: Map; - imports: ReadonlyArray; - /** - * When a file's references are redirected due to project reference directives, - * the original names of the references are stored in this array - */ - redirectedReferences?: ReadonlyArray; - moduleAugmentations: ReadonlyArray; - patternAmbientModules?: PatternAmbientModule[]; - ambientModuleNames: ReadonlyArray; - checkJsDirective?: CheckJsDirective; - version: string; - pragmas: PragmaMap; - localJsxNamespace?: __String; - localJsxFactory?: EntityName; } interface Bundle extends Node { kind: SyntaxKind.Bundle; prepends: ReadonlyArray; sourceFiles: ReadonlyArray; - syntheticFileReferences?: ReadonlyArray; - syntheticTypeReferences?: ReadonlyArray; - hasNoDefaultLib?: boolean; } interface InputFiles extends Node { kind: SyntaxKind.InputFiles; @@ -2447,11 +1776,6 @@ declare namespace ts { * Get a list of files in the program */ getSourceFiles(): ReadonlyArray; - /** - * Get a list of file names that were passed to 'createProgram' or referenced in a - * program source file but could not be located. - */ - getMissingFilePaths(): ReadonlyArray; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -2470,44 +1794,18 @@ declare namespace ts { getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; getConfigFileParsingDiagnostics(): ReadonlyArray; - getSuggestionDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; - getCommonSourceDirectory(): string; - getDiagnosticsProducingTypeChecker(): TypeChecker; - dropDiagnosticsProducingTypeChecker(): void; - getClassifiableNames(): UnderscoreEscapedMap; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; - getFileProcessingDiagnostics(): DiagnosticCollection; - getResolvedTypeReferenceDirectives(): Map; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - structureIsReused?: StructureIsReused; - getSourceFileFromReference(referencingFile: SourceFile, ref: FileReference): SourceFile | undefined; - getLibFileFromReference(ref: FileReference): SourceFile | undefined; - /** Given a source file, get the name of the package it was imported from. */ - sourceFileToPackageName: Map; - /** Set of all source files that some other source file redirects to. */ - redirectTargetsSet: Map; - /** Is the file emitted file */ - isEmittedFile(file: string): boolean; - getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; getProjectReferences(): (ResolvedProjectReference | undefined)[] | undefined; } interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; } - enum StructureIsReused { - Not = 0, - SafeModules = 1, - Completely = 2 - } interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ before?: TransformerFactory[]; @@ -2540,7 +1838,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -2553,13 +1850,6 @@ declare namespace ts { /** Contains declaration emit diagnostics */ diagnostics: ReadonlyArray; emittedFiles?: string[]; - sourceMaps?: SourceMapData[]; - } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): ReadonlyArray; - getSourceFile(fileName: string): SourceFile | undefined; - getResolvedTypeReferenceDirectives(): ReadonlyMap; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; @@ -2573,16 +1863,10 @@ declare namespace ts { 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. - */ - getParameterType(signature: Signature, parameterIndex: number): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & { typeArguments?: NodeArray; @@ -2618,28 +1902,16 @@ declare namespace ts { */ getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; - getTypeAtLocation(node: Node): Type | undefined; + 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, flags?: SymbolFormatFlags): string; typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - writeSignature(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, writer?: EmitTextWriter): string; - writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; - writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string; - writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; getContextualType(node: Expression): Type | undefined; - getContextualTypeForArgumentAtIndex(call: CallLikeExpression, argIndex: number): Type | undefined; - getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute): Type | undefined; - isContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike): boolean; /** * returns unknownSignature in the case of an error. * returns undefined if the node is not valid. @@ -2651,91 +1923,19 @@ declare namespace ts { isUndefinedSymbol(symbol: Symbol): boolean; isArgumentsSymbol(symbol: Symbol): boolean; isUnknownSymbol(symbol: Symbol): boolean; - getMergedSymbol(symbol: Symbol): Symbol; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined; isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName | ImportTypeNode, propertyName: string): boolean; - /** Exclude accesses to private properties or methods with a `this` parameter that `type` doesn't satisfy. */ - isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode, type: Type, property: Symbol): boolean; /** Follow all aliases to get the original symbol. */ getAliasedSymbol(symbol: Symbol): Symbol; - /** Follow a *single* alias to get the immediately aliased symbol. */ - getImmediateAliasedSymbol(symbol: Symbol): Symbol | undefined; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - /** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */ - getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[]; getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined; getJsxIntrinsicTagNamesAt(location: Node): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; - /** - * Unlike `tryGetMemberInModuleExports`, this includes properties of an `export =` value. - * Does *not* return properties of primitive types. - */ - tryGetMemberInModuleExportsAndProperties(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; - getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; - getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; getDefaultFromTypeParameter(type: Type): Type | undefined; - getAnyType(): Type; - getStringType(): Type; - getNumberType(): Type; - getBooleanType(): Type; - getFalseType(): Type; - getTrueType(): Type; - getVoidType(): Type; - getUndefinedType(): Type; - getNullType(): Type; - getESSymbolType(): Type; - getNeverType(): Type; - getUnionType(types: Type[], subtypeReduction?: UnionReduction): Type; - createArrayType(elementType: Type): Type; - createPromiseType(type: Type): Type; - createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): Type; - createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[] | undefined, thisParameter: Symbol | undefined, parameters: Symbol[], resolvedReturnType: Type, typePredicate: TypePredicate | undefined, minArgumentCount: number, hasRestParameter: boolean, hasLiteralTypes: boolean): Signature; - createSymbol(flags: SymbolFlags, name: __String): TransientSymbol; - createIndexInfo(type: Type, isReadonly: boolean, declaration?: SignatureDeclaration): IndexInfo; - isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; - tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined; - getSymbolWalker(accept?: (symbol: Symbol) => boolean): SymbolWalker; - getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; - isArrayLikeType(type: Type): boolean; - /** - * For a union, will include a property if it's defined in *any* of the member types. - * So for `{ a } | { b }`, this will include both `a` and `b`. - * Does not include properties of primitive types. - */ - getAllPossiblePropertiesOfTypes(type: ReadonlyArray): Symbol[]; - resolveName(name: string, location: Node, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined; - getJsxNamespace(location?: Node): string; - /** - * Note that this will return undefined in the following case: - * // a.ts - * export namespace N { export class C { } } - * // b.ts - * <> - * Where `C` is the symbol we're looking for. - * This should be called in a loop climbing parents of the symbol, so we'll get `N`. - */ - getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined; - getTypePredicateOfSignature(signature: Signature): TypePredicate; - resolveExternalModuleSymbol(symbol: Symbol): Symbol; - /** @param node A location where we might consider accessing `this`. Not necessarily a ThisExpression. */ - tryGetThisTypeAt(node: Node): Type | undefined; - getTypeArgumentConstraint(node: TypeNode): Type | undefined; - /** - * Does *not* get *all* suggestion diagnostics, just the ones that were convenient to report in the checker. - * Others are added in computeSuggestionDiagnostics. - */ - getSuggestionDiagnostics(file: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** * Depending on the operation performed, it may be appropriate to throw away the checker * if the cancellation token is triggered. Typically, if it is used for error checking @@ -2743,11 +1943,6 @@ declare namespace ts { */ runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) => T): T; } - enum UnionReduction { - None = 0, - Literal = 1, - Subtype = 2 - } enum NodeBuilderFlags { None = 0, NoTruncation = 1, @@ -2808,60 +2003,6 @@ declare namespace ts { AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8 } - interface SymbolWalker { - /** Note: Return values are not ordered. */ - walkType(root: Type): { - visitedTypes: ReadonlyArray; - visitedSymbols: ReadonlyArray; - }; - /** Note: Return values are not ordered. */ - walkSymbol(root: Symbol): { - visitedTypes: ReadonlyArray; - visitedSymbols: ReadonlyArray; - }; - } - /** - * @deprecated - */ - interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ - interface SymbolWriter extends SymbolTracker { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeProperty(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - } - enum SymbolAccessibility { - Accessible = 0, - NotAccessible = 1, - CannotBeNamed = 2 - } - enum SyntheticSymbolKind { - UnionOrIntersection = 0, - Spread = 1 - } enum TypePredicateKind { This = 0, Identifier = 1 @@ -2879,88 +2020,6 @@ declare namespace ts { parameterIndex: number; } type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; - type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration; - interface ValidImportTypeNode extends ImportTypeNode { - argument: LiteralTypeNode & { - literal: StringLiteral; - }; - } - type AnyValidImportOrReExport = (ImportDeclaration | ExportDeclaration) & { - moduleSpecifier: StringLiteral; - } | ImportEqualsDeclaration & { - moduleReference: ExternalModuleReference & { - expression: StringLiteral; - }; - } | RequireOrImportCall | ValidImportTypeNode; - type RequireOrImportCall = CallExpression & { - arguments: [StringLiteralLike]; - }; - type LateVisibilityPaintedStatement = AnyImportSyntax | VariableStatement | ClassDeclaration | FunctionDeclaration | ModuleDeclaration | TypeAliasDeclaration | InterfaceDeclaration | EnumDeclaration; - interface SymbolVisibilityResult { - accessibility: SymbolAccessibility; - aliasesToMakeVisible?: LateVisibilityPaintedStatement[]; - errorSymbolName?: string; - errorNode?: Node; - } - interface SymbolAccessibilityResult extends SymbolVisibilityResult { - errorModuleName?: string; - } - interface AllAccessorDeclarations { - firstAccessor: AccessorDeclaration; - secondAccessor: AccessorDeclaration | undefined; - getAccessor: AccessorDeclaration | undefined; - setAccessor: AccessorDeclaration | undefined; - } - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ - 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 | undefined; - getReferencedImportDeclaration(node: Identifier): Declaration | undefined; - getReferencedDeclarationWithCollidingName(node: Identifier): Declaration | undefined; - 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 | AnyImportSyntax): boolean; - isLateBound(node: Declaration): node is LateBoundDeclaration; - collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined; - isImplementationOfOverload(node: FunctionLike): boolean | undefined; - isRequiredInitializedParameter(node: ParameterDeclaration): boolean; - isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean; - createTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker, addUndefined?: boolean): TypeNode | undefined; - createReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined; - createTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined; - createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): Expression; - isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags | undefined, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; - isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined; - getReferencedValueDeclaration(reference: Identifier): Declaration | undefined; - getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind; - isOptionalParameter(node: ParameterDeclaration): boolean; - moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; - isArgumentsLocalBinding(node: Identifier): boolean; - getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): SourceFile | undefined; - getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[] | undefined; - getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[] | undefined; - isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; - getJsxFactoryEntity(location?: Node): EntityName | undefined; - getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations; - } enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2990,7 +2049,7 @@ declare namespace ts { Optional = 16777216, Transient = 33554432, JSContainer = 67108864, - All = 67108863, + ModuleExports = 134217728, Enum = 384, Variable = 3, Value = 67216319, @@ -3018,13 +2077,9 @@ declare namespace ts { AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, - HasExports = 1955, - HasMembers = 6240, BlockScoped = 418, PropertyOrAccessor = 98308, - ClassMember = 106500, - Classifiable = 2885600, - LateBindingContainer = 6240 + ClassMember = 106500 } interface Symbol { flags: SymbolFlags; @@ -3034,72 +2089,6 @@ declare namespace ts { members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; - id?: number; - mergeId?: number; - parent?: Symbol; - exportSymbol?: Symbol; - nameType?: Type; - constEnumOnlyModule?: boolean; - isReferenced?: SymbolFlags; - isReplaceableByMethod?: boolean; - isAssigned?: boolean; - } - interface SymbolLinks { - immediateTarget?: Symbol; - target?: Symbol; - type?: Type; - uniqueESSymbolType?: Type; - declaredType?: Type; - typeParameters?: TypeParameter[]; - outerTypeParameters?: TypeParameter[]; - inferredClassType?: Type; - instantiations?: Map; - mapper?: TypeMapper; - referenced?: boolean; - containingType?: UnionOrIntersectionType; - leftSpread?: Symbol; - rightSpread?: Symbol; - syntheticOrigin?: Symbol; - isDiscriminantProperty?: boolean; - resolvedExports?: SymbolTable; - resolvedMembers?: SymbolTable; - exportsChecked?: boolean; - typeParametersChecked?: boolean; - isDeclarationWithCollidingName?: boolean; - bindingElement?: BindingElement; - exportsSomeValue?: boolean; - enumKind?: EnumKind; - originatingImport?: ImportDeclaration | ImportCall; - lateSymbol?: Symbol; - specifierCache?: Map; - } - enum EnumKind { - Numeric = 0, - Literal = 1 - } - enum CheckFlags { - Instantiated = 1, - SyntheticProperty = 2, - SyntheticMethod = 4, - Readonly = 8, - Partial = 16, - HasNonUniformType = 32, - ContainsPublic = 64, - ContainsProtected = 128, - ContainsPrivate = 256, - ContainsStatic = 512, - Late = 1024, - ReverseMapped = 2048, - OptionalParameter = 4096, - RestParameter = 8192, - Synthetic = 6 - } - interface TransientSymbol extends Symbol, SymbolLinks { - checkFlags: CheckFlags; - } - interface ReverseMappedSymbol extends TransientSymbol { - propertyType: Type; - mappedType: MappedType; } enum InternalSymbolName { Call = "__call", @@ -3150,53 +2139,6 @@ declare namespace ts { } /** SymbolTable based on ES6 Map interface. */ type SymbolTable = UnderscoreEscapedMap; - /** Used to track a `declare module "foo*"`-like declaration. */ - interface PatternAmbientModule { - pattern: Pattern; - symbol: Symbol; - } - enum NodeCheckFlags { - TypeChecked = 1, - LexicalThis = 2, - CaptureThis = 4, - CaptureNewTarget = 8, - 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; - resolvedSignatures?: Map; - resolvedSymbol?: Symbol; - resolvedIndexInfo?: IndexInfo; - maybeTypePredicate?: boolean; - enumMemberValue?: string | number; - isVisible?: boolean; - containsArgumentsReference?: boolean; - hasReportedStatementInAmbientContext?: boolean; - jsxFlags: JsxFlags; - resolvedJsxElementAttributesType?: Type; - resolvedJsxElementAllAttributesType?: Type; - hasSuperCall?: boolean; - superCall?: SuperCall; - switchTypes?: Type[]; - } enum TypeFlags { Any = 1, Unknown = 2, @@ -3223,28 +2165,16 @@ declare namespace ts { Conditional = 4194304, Substitution = 8388608, NonPrimitive = 16777216, - FreshLiteral = 33554432, - UnionOfUnitTypes = 67108864, - ContainsWideningType = 134217728, - ContainsObjectLiteral = 268435456, - ContainsAnyFunctionType = 536870912, - AnyOrUnknown = 3, - Nullable = 24576, Literal = 448, Unit = 27072, StringOrNumberLiteral = 192, - StringOrNumberLiteralOrUnique = 2240, - DefinitelyFalsy = 29120, PossiblyFalsy = 29148, - Intrinsic = 16839967, - Primitive = 32764, StringLike = 68, NumberLike = 168, BooleanLike = 272, EnumLike = 544, ESSymbolLike = 3072, VoidLike = 12288, - DisjointDomains = 16809468, UnionOrIntersection = 786432, StructuredType = 917504, TypeVariable = 2162688, @@ -3253,29 +2183,15 @@ declare namespace ts { Instantiable = 15794176, StructuredOrInstantiable = 16711680, Narrowable = 33492479, - NotUnionOrUnit = 16909315, - NotUnit = 16749629, - RequiresWidening = 402653184, - PropagatingFlags = 939524096, - NonWideningType = 134217728, - Wildcard = 268435456, - EmptyObject = 536870912, - ConstructionFlags = 939524096, - GenericMappedType = 134217728 + NotUnionOrUnit = 16909315 } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; - id: number; - checker: TypeChecker; symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: ReadonlyArray; - wildcardInstantiation?: Type; - } - interface IntrinsicType extends Type { - intrinsicName: string; } interface LiteralType extends Type { value: string | number; @@ -3319,8 +2235,6 @@ declare namespace ts { outerTypeParameters: TypeParameter[] | undefined; localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: BaseType[]; } type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { @@ -3344,16 +2258,7 @@ declare namespace ts { target: GenericType; typeArguments?: ReadonlyArray; } - enum Variance { - Invariant = 0, - Covariant = 1, - Contravariant = 2, - Bivariant = 3, - Independent = 4 - } interface GenericType extends InterfaceType, TypeReference { - instantiations: Map; - variances?: Variance[]; } interface TupleType extends GenericType { minLength: number; @@ -3365,76 +2270,19 @@ declare namespace ts { } interface UnionOrIntersectionType extends Type { types: Type[]; - propertyCache: SymbolTable; - resolvedProperties: Symbol[]; - resolvedIndexType: IndexType; - resolvedStringIndexType: IndexType; - resolvedBaseConstraint: Type; - couldContainTypeVariables: boolean; } interface UnionType extends UnionOrIntersectionType { } interface IntersectionType extends UnionOrIntersectionType { - resolvedApparentType: Type; } type StructuredType = ObjectType | UnionType | IntersectionType; - interface AnonymousType extends ObjectType { - target?: AnonymousType; - mapper?: TypeMapper; - } - interface MappedType extends AnonymousType { - declaration: MappedTypeNode; - typeParameter?: TypeParameter; - constraintType?: Type; - templateType?: Type; - modifiersType?: Type; - } interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface ReverseMappedType extends ObjectType { - source: Type; - mappedType: MappedType; - } - interface ResolvedType extends ObjectType, UnionOrIntersectionType { - members: SymbolTable; - properties: Symbol[]; - callSignatures: ReadonlyArray; - constructSignatures: ReadonlyArray; - stringIndexInfo?: IndexInfo; - numberIndexInfo?: IndexInfo; - } - interface FreshObjectLiteralType extends ResolvedType { - regularType: ResolvedType; - } - interface IterableOrIteratorType extends ObjectType, UnionType { - iteratedTypeOfIterable?: Type; - iteratedTypeOfIterator?: Type; - iteratedTypeOfAsyncIterable?: Type; - iteratedTypeOfAsyncIterator?: Type; - } - interface PromiseOrAwaitableType extends ObjectType, UnionType { - promiseTypeOfPromiseConstructor?: Type; - promisedTypeOfPromise?: Type; - awaitedTypeOfType?: Type; - } - interface SyntheticDefaultModuleType extends Type { - syntheticType?: Type; - } interface InstantiableType extends Type { - resolvedBaseConstraint?: Type; - resolvedIndexType?: IndexType; - resolvedStringIndexType?: IndexType; } interface TypeParameter extends InstantiableType { - /** Retrieve using getConstraintFromTypeParameter */ - constraint?: Type; - default?: Type; - target?: TypeParameter; - mapper?: TypeMapper; - isThisType?: boolean; - resolvedDefaultType?: Type; } interface IndexedAccessType extends InstantiableType { objectType: Type; @@ -3445,7 +2293,6 @@ declare namespace ts { type TypeVariable = TypeParameter | IndexedAccessType; interface IndexType extends InstantiableType { type: InstantiableType | UnionOrIntersectionType; - stringsOnly: boolean; } interface ConditionalRoot { node: ConditionalTypeNode; @@ -3466,9 +2313,6 @@ declare namespace ts { extendsType: Type; resolvedTrueType?: Type; resolvedFalseType?: Type; - resolvedDefaultConstraint?: Type; - mapper?: TypeMapper; - combinedMapper?: TypeMapper; } interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; @@ -3482,19 +2326,6 @@ declare namespace ts { declaration?: SignatureDeclaration | JSDocSignature; typeParameters?: ReadonlyArray; parameters: ReadonlyArray; - thisParameter?: Symbol; - resolvedReturnType?: Type; - resolvedTypePredicate?: TypePredicate; - minArgumentCount: number; - hasRestParameter: boolean; - hasLiteralTypes: boolean; - target?: Signature; - mapper?: TypeMapper; - unionSignatures?: Signature[]; - erasedSignatureCache?: Signature; - canonicalSignatureCache?: Signature; - isolatedSignatureType?: ObjectType; - instantiations?: Map; } enum IndexKind { String = 0, @@ -3505,7 +2336,6 @@ declare namespace ts { isReadonly: boolean; declaration?: IndexSignatureDeclaration; } - type TypeMapper = (t: TypeParameter) => Type; enum InferencePriority { NakedTypeVariable = 1, HomomorphicMappedType = 2, @@ -3516,58 +2346,6 @@ declare namespace ts { AlwaysStrict = 64, PriorityImpliesCombination = 28 } - interface InferenceInfo { - typeParameter: TypeParameter; - candidates: Type[] | undefined; - contraCandidates: Type[] | undefined; - inferredType?: Type; - priority?: InferencePriority; - topLevel: boolean; - isFixed: boolean; - } - enum InferenceFlags { - None = 0, - InferUnionTypes = 1, - NoDefault = 2, - AnyDefault = 4 - } - /** - * Ternary values are defined such that - * x & y is False if either x or y is False. - * x & y is Maybe if either x or y is Maybe, but neither x or y is False. - * x & y is True if both x and y are True. - * x | y is False if both x and y are False. - * x | y is Maybe if either x or y is Maybe, but neither x or y is True. - * x | y is True if either x or y is True. - */ - enum Ternary { - False = 0, - Maybe = 1, - True = -1 - } - type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary; - interface InferenceContext extends TypeMapper { - typeParameters: ReadonlyArray; - signature?: Signature; - inferences: InferenceInfo[]; - flags: InferenceFlags; - compareTypes: TypeComparer; - } - interface WideningContext { - parent?: WideningContext; - propertyName?: __String; - siblings?: Type[]; - resolvedProperties?: Symbol[]; - } - enum SpecialPropertyAssignmentKind { - None = 0, - ExportsProperty = 1, - ModuleExports = 2, - PrototypeProperty = 3, - ThisProperty = 4, - Property = 5, - Prototype = 6 - } /** @deprecated Use FileExtensionInfo instead. */ type JsFileExtensionInfo = FileExtensionInfo; interface FileExtensionInfo { @@ -3595,14 +2373,14 @@ declare namespace ts { next?: DiagnosticMessageChain; } interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -3619,9 +2397,6 @@ declare namespace ts { Suggestion = 2, Message = 3 } - function diagnosticCategoryName(d: { - category: DiagnosticCategory; - }, lowerCase?: boolean): string; enum ModuleResolutionKind { Classic = 1, NodeJs = 2 @@ -3641,44 +2416,31 @@ declare namespace ts { } type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; interface CompilerOptions { - all?: boolean; allowJs?: boolean; - allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; - /** An error if set - this should only go through the -b pipeline and not actually be observed */ - build?: boolean; charset?: string; checkJs?: boolean; - configFilePath?: string; - /** configFile is set as non enumerable property so as to avoid checking of json source files */ - readonly configFile?: TsConfigSourceFile; declaration?: boolean; declarationMap?: boolean; emitDeclarationOnly?: boolean; declarationDir?: string; - diagnostics?: boolean; - extendedDiagnostics?: boolean; disableSizeLimit?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; - help?: boolean; importHelpers?: boolean; - init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; jsx?: JsxEmit; keyofStringsOnly?: boolean; lib?: string[]; - listEmittedFiles?: boolean; - listFiles?: boolean; locale?: string; mapRoot?: string; maxNodeModuleJsDepth?: number; @@ -3686,7 +2448,6 @@ declare namespace ts { moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; - noEmitForJsFiles?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; @@ -3704,12 +2465,9 @@ declare namespace ts { outDir?: string; outFile?: string; paths?: MapLike; - plugins?: PluginImport[]; preserveConstEnums?: boolean; preserveSymlinks?: boolean; - preserveWatchOutput?: boolean; project?: string; - pretty?: boolean; reactNamespace?: string; jsxFactory?: string; composite?: boolean; @@ -3727,15 +2485,12 @@ declare namespace ts { stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; - suppressOutputPathCheck?: boolean; target?: ScriptTarget; traceResolution?: boolean; resolveJsonModule?: boolean; types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; - version?: boolean; - watch?: boolean; esModuleInterop?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } @@ -3809,32 +2564,15 @@ declare namespace ts { errors: Diagnostic[]; wildcardDirectories?: MapLike; compileOnSave?: boolean; - configFileSpecs?: ConfigFileSpecs; } enum WatchDirectoryFlags { None = 0, Recursive = 1 } - interface ConfigFileSpecs { - filesSpecs: ReadonlyArray | undefined; - referencesSpecs: ReadonlyArray | undefined; - /** - * Present to report errors (user specified specs), validatedIncludeSpecs are used for file name matching - */ - includeSpecs?: ReadonlyArray; - /** - * Present to report errors (user specified specs), validatedExcludeSpecs are used for file name matching - */ - excludeSpecs?: ReadonlyArray; - validatedIncludeSpecs?: ReadonlyArray; - validatedExcludeSpecs?: ReadonlyArray; - wildcardDirectories: MapLike; - } interface ExpandResult { fileNames: string[]; projectReferences: ReadonlyArray | undefined; wildcardDirectories: MapLike; - spec: ConfigFileSpecs; } interface CreateProgramOptions { rootNames: ReadonlyArray; @@ -3844,163 +2582,9 @@ declare namespace ts { oldProgram?: Program; configFileParsingDiagnostics?: ReadonlyArray; } - interface CommandLineOptionBase { - name: string; - type: "string" | "number" | "boolean" | "object" | "list" | Map; - isFilePath?: boolean; - shortName?: string; - description?: DiagnosticMessage; - paramType?: DiagnosticMessage; - isTSConfigOnly?: boolean; - isCommandLineOnly?: boolean; - showInSimplifiedHelpView?: boolean; - category?: DiagnosticMessage; - } - interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase { - type: "string" | "number" | "boolean"; - } - interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: Map; - } - interface TsConfigOnlyOption extends CommandLineOptionBase { - type: "object"; - elementOptions?: Map; - extraKeyDiagnosticMessage?: DiagnosticMessage; - } - interface CommandLineOptionOfListType extends CommandLineOptionBase { - type: "list"; - element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption; - } - type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption | CommandLineOptionOfListType; - 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 UpToDateHost { fileExists(fileName: string): boolean; - getModifiedTime(fileName: string): Date; + getModifiedTime(fileName: string): Date | undefined; getUnchangedTime?(fileName: string): Date | undefined; getLastStatus?(fileName: string): UpToDateStatus | undefined; setLastStatus?(fileName: string, status: UpToDateStatus): void; @@ -4038,7 +2622,6 @@ declare namespace ts { * If changing this, remember to change `moduleResolutionIsEqualTo`. */ interface ResolvedModuleFull extends ResolvedModule { - readonly originalPath?: string; /** * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. * This is optional for backwards-compatibility, but will be added if not provided. @@ -4075,7 +2658,6 @@ declare namespace ts { } interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; - readonly failedLookupLocations: ReadonlyArray; } interface ResolvedTypeReferenceDirective { primary: boolean; @@ -4086,7 +2668,6 @@ declare namespace ts { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; readonly failedLookupLocations: ReadonlyArray; } - type HasInvalidatedResolution = (sourceFile: Path) => boolean; interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; @@ -4106,97 +2687,19 @@ declare namespace ts { */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string | undefined; - onReleaseOldSourceFile?(oldSourceFile: SourceFile, oldOptions: CompilerOptions): void; - hasInvalidatedResolution?: HasInvalidatedResolution; - hasChangedAutomaticTypeDirectiveNames?: boolean; createHash?(data: string): string; - getModifiedTime?(fileName: string): Date; + getModifiedTime?(fileName: string): Date | undefined; setModifiedTime?(fileName: string, date: Date): void; deleteFile?(fileName: string): void; } - 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, - ContainsDynamicImport = 67108864, - Super = 134217728, - ContainsSuper = 268435456, - HasComputedFlags = 536870912, - AssertTypeScript = 3, - AssertJsx = 4, - AssertESNext = 8, - AssertES2017 = 16, - AssertES2016 = 32, - AssertES2015 = 192, - AssertGenerator = 768, - AssertDestructuringAssignment = 3072, - OuterExpressionExcludes = 536872257, - PropertyAccessExcludes = 671089985, - NodeExcludes = 939525441, - ArrowFunctionExcludes = 1003902273, - FunctionExcludes = 1003935041, - ConstructorExcludes = 1003668801, - MethodOrAccessorExcludes = 1003668801, - ClassExcludes = 942011713, - ModuleExcludes = 977327425, - TypeExcludes = -3, - ObjectLiteralExcludes = 942740801, - ArrayLiteralOrCallOrNewExcludes = 940049729, - VariableDeclarationListExcludes = 948962625, - ParameterExcludes = 939525441, - CatchClauseExcludes = 940574017, - BindingPatternExcludes = 940049729, - TypeScriptClassSyntaxMask = 274432, - ES2015FunctionSyntaxMask = 163840 - } interface SourceMapRange extends TextRange { source?: SourceMapSource; } interface SourceMapSource { fileName: string; text: string; - lineMap: ReadonlyArray; skipTrivia?: (pos: number) => number; } - interface EmitNode { - annotatedNodes?: Node[]; - flags: EmitFlags; - leadingComments?: SynthesizedComment[]; - trailingComments?: SynthesizedComment[]; - commentRange?: TextRange; - sourceMapRange?: SourceMapRange; - tokenSourceMapRanges?: (SourceMapRange | undefined)[]; - constantValue?: string | number; - externalHelpersModuleName?: Identifier; - helpers?: EmitHelper[]; - startsOnNewLine?: boolean; - } enum EmitFlags { None = 0, SingleLine = 1, @@ -4226,9 +2729,7 @@ declare namespace ts { NoHoisting = 2097152, HasEndOfDeclarationMarker = 4194304, Iterator = 8388608, - NoAsciiEscaping = 16777216, - TypeScriptClassWrapper = 33554432, - NeverApplyImportHelper = 67108864 + NoAsciiEscaping = 16777216 } interface EmitHelper { readonly name: string; @@ -4236,38 +2737,7 @@ declare namespace ts { readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } - type UniqueNameHandler = (baseName: string, checkFn?: (name: string) => boolean, optimistic?: boolean) => string; type EmitHelperUniqueNameCallback = (name: string) => string; - /** - * Used by the checker, this enum keeps track of external emit helpers that should be type - * checked. - */ - enum ExternalEmitHelpers { - Extends = 1, - Assign = 2, - Rest = 4, - Decorate = 8, - Metadata = 16, - Param = 32, - Awaiter = 64, - Generator = 128, - Values = 256, - Read = 512, - Spread = 1024, - Await = 2048, - AsyncGenerator = 4096, - AsyncDelegator = 8192, - AsyncValues = 16384, - ExportStar = 32768, - MakeTemplateObject = 65536, - FirstEmitHelper = 1, - LastEmitHelper = 65536, - ForOfIncludes = 256, - ForAwaitOfIncludes = 16384, - AsyncGeneratorIncludes = 6144, - AsyncDelegatorIncludes = 26624, - SpreadIncludes = 1536 - } enum EmitHint { SourceFile = 0, Expression = 1, @@ -4275,20 +2745,7 @@ declare namespace ts { MappedTypeParameter = 3, Unspecified = 4 } - interface EmitHost extends ScriptReferenceHost, ModuleSpecifierResolutionHost { - getSourceFiles(): ReadonlyArray; - getCurrentDirectory(): string; - isSourceFileFromExternalLibrary(file: SourceFile): boolean; - getCommonSourceDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - isEmitBlocked(emitFileName: string): boolean; - getPrependNodes(): ReadonlyArray; - writeFile: WriteFileCallback; - } interface TransformationContext { - getEmitResolver(): EmitResolver; - getEmitHost(): EmitHost; /** Gets the compiler options supplied to the transformer. */ getCompilerOptions(): CompilerOptions; /** Starts a new lexical environment. */ @@ -4337,7 +2794,6 @@ declare namespace ts { * before returning the `NodeTransformer` callback. */ onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; - addDiagnostic(diag: DiagnosticWithLocation): void; } interface TransformationResult { /** Gets the transformed source files. */ @@ -4405,20 +2861,6 @@ declare namespace ts { * Prints a bundle of source files as-is, without any emit transformations. */ printBundle(bundle: Bundle): string; - writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void; - writeList(format: ListFormat, list: NodeArray | undefined, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void; - writeFile(sourceFile: SourceFile, writer: EmitTextWriter): void; - writeBundle(bundle: Bundle, writer: EmitTextWriter, info?: BundleInfo): void; - } - /** - * When a bundle contains prepended content, we store a file on disk indicating where the non-prepended - * content of that file starts. On a subsequent build where there are no upstream .d.ts changes, we - * read the bundle info file and the original .js file to quickly re-use portion of the file - * that didn't originate in prepended content. - */ - interface BundleInfo { - originalOffset: number; - totalLength: number; } interface PrintHandlers { /** @@ -4462,59 +2904,17 @@ declare namespace ts { * ``` */ substituteNode?(hint: EmitHint, node: Node): Node; - onEmitSourceMapOfNode?: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; - onEmitSourceMapOfToken?: (node: Node | undefined, token: SyntaxKind, writer: (s: string) => void, pos: number, emitCallback: (token: SyntaxKind, writer: (s: string) => void, pos: number) => number) => number; - onEmitSourceMapOfPosition?: (pos: number) => void; - onSetSourceFile?: (node: SourceFile) => void; - onBeforeEmitNodeArray?: (nodes: NodeArray | undefined) => void; - onAfterEmitNodeArray?: (nodes: NodeArray | undefined) => void; - onBeforeEmitToken?: (node: Node) => void; - onAfterEmitToken?: (node: Node) => void; } interface PrinterOptions { removeComments?: boolean; newLine?: NewLineKind; omitTrailingSemicolon?: boolean; noEmitHelpers?: boolean; - module?: CompilerOptions["module"]; - target?: CompilerOptions["target"]; - sourceMap?: boolean; - inlineSourceMap?: boolean; - extendedDiagnostics?: boolean; - onlyPrintJsDocStyle?: boolean; - } - interface EmitTextWriter extends SymbolWriter { - write(s: string): void; - writeTextOfNode(text: string, node: Node): void; - getText(): string; - rawWrite(s: string): void; - writeLiteral(s: string): void; - getTextPos(): number; - getLine(): number; - getColumn(): number; - getIndent(): number; - isAtStartOfLine(): boolean; } interface GetEffectiveTypeRootsHost { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - /** @internal */ - interface ModuleSpecifierResolutionHost extends GetEffectiveTypeRootsHost { - useCaseSensitiveFileNames?(): boolean; - fileExists?(path: string): boolean; - readFile?(path: string): string | undefined; - getSourceFiles?(): ReadonlyArray; - } - /** @deprecated See comment on SymbolWriter */ - interface SymbolTracker { - trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError?(): void; - reportPrivateInBaseOfClassExpression?(propertyName: string): void; - reportInaccessibleUniqueSymbolError?(): void; - moduleResolverHost?: ModuleSpecifierResolutionHost; - trackReferencedAmbientModule?(decl: ModuleDeclaration): void; - } interface TextSpan { start: number; length: number; @@ -4523,13 +2923,6 @@ declare namespace ts { span: TextSpan; newLength: number; } - interface DiagnosticCollection { - add(diagnostic: Diagnostic): void; - getGlobalDiagnostics(): Diagnostic[]; - getDiagnostics(fileName: string): DiagnosticWithLocation[]; - getDiagnostics(): Diagnostic[]; - reattachFileDiagnostics(newFile: SourceFile): void; - } interface SyntaxList extends Node { _children: Node[]; } @@ -4598,145 +2991,10 @@ declare namespace ts { Parameters = 1296, IndexSignatureParameters = 4432 } - enum PragmaKindFlags { - None = 0, - /** - * Triple slash comment of the form - * /// - */ - TripleSlashXML = 1, - /** - * Single line comment of the form - * // @pragma-name argval1 argval2 - * or - * /// @pragma-name argval1 argval2 - */ - SingleLine = 2, - /** - * Multiline non-jsdoc pragma of the form - * /* @pragma-name argval1 argval2 * / - */ - MultiLine = 4, - All = 7, - Default = 7 - } - interface PragmaArgumentSpecification { - name: TName; - optional?: boolean; - captureSpan?: boolean; - } - interface PragmaDefinition { - args?: [PragmaArgumentSpecification] | [PragmaArgumentSpecification, PragmaArgumentSpecification] | [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification] | [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification]; - kind?: PragmaKindFlags; - } - const commentPragmas: { - "reference": { - args: [{ - name: "types"; - optional: true; - captureSpan: true; - }, { - name: "lib"; - optional: true; - captureSpan: true; - }, { - name: "path"; - optional: true; - captureSpan: true; - }, { - name: "no-default-lib"; - optional: true; - }]; - kind: PragmaKindFlags; - }; - "amd-dependency": { - args: [{ - name: "path"; - }, { - name: "name"; - optional: true; - }]; - kind: PragmaKindFlags; - }; - "amd-module": { - args: [{ - name: "name"; - }]; - kind: PragmaKindFlags; - }; - "ts-check": { - kind: PragmaKindFlags; - }; - "ts-nocheck": { - kind: PragmaKindFlags; - }; - "jsx": { - args: [{ - name: "factory"; - }]; - kind: PragmaKindFlags; - }; - }; - type PragmaArgTypeMaybeCapture = TDesc extends { - captureSpan: true; - } ? { - value: string; - pos: number; - end: number; - } : string; - type PragmaArgTypeOptional = TDesc extends { - optional: true; - } ? { - [K in TName]?: PragmaArgTypeMaybeCapture; - } : { - [K in TName]: PragmaArgTypeMaybeCapture; - }; - /** - * Maps a pragma definition into the desired shape for its arguments object - * Maybe the below is a good argument for types being iterable on struture in some way. - */ - type PragmaArgumentType = T extends { - args: [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification]; - } ? PragmaArgTypeOptional & PragmaArgTypeOptional & PragmaArgTypeOptional & PragmaArgTypeOptional : T extends { - args: [PragmaArgumentSpecification, PragmaArgumentSpecification, PragmaArgumentSpecification]; - } ? PragmaArgTypeOptional & PragmaArgTypeOptional & PragmaArgTypeOptional : T extends { - args: [PragmaArgumentSpecification, PragmaArgumentSpecification]; - } ? PragmaArgTypeOptional & PragmaArgTypeOptional : T extends { - args: [PragmaArgumentSpecification]; - } ? PragmaArgTypeOptional : object; - type ConcretePragmaSpecs = typeof commentPragmas; - type PragmaPsuedoMap = { - [K in keyof ConcretePragmaSpecs]?: { - arguments: PragmaArgumentType; - range: CommentRange; - }; - }; - type PragmaPsuedoMapEntry = { - [K in keyof PragmaPsuedoMap]: { - name: K; - args: PragmaPsuedoMap[K]; - }; - }[keyof PragmaPsuedoMap]; - /** - * A strongly-typed es6 map of pragma entries, the values of which are either a single argument - * value (if only one was found), or an array of multiple argument values if the pragma is present - * in multiple places - */ - interface PragmaMap extends Map { - set(key: TKey, value: PragmaPsuedoMap[TKey] | PragmaPsuedoMap[TKey][]): this; - get(key: TKey): PragmaPsuedoMap[TKey] | PragmaPsuedoMap[TKey][]; - forEach(action: (value: PragmaPsuedoMap[TKey] | PragmaPsuedoMap[TKey][], key: TKey) => void): void; - } } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { - /** - * Set a high stack trace limit to provide more information in case of an error. - * Called for command-line and server use cases. - * Not called if TypeScript is used as a library. - */ - function setStackTraceLimit(): void; enum FileWatcherEventKind { Created = 0, Changed = 1, @@ -4744,47 +3002,6 @@ declare namespace ts { } type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; type DirectoryWatcherCallback = (fileName: string) => void; - interface WatchedFile { - readonly fileName: string; - readonly callback: FileWatcherCallback; - mtime: Date; - } - enum PollingInterval { - High = 2000, - Medium = 500, - Low = 250 - } - function watchFileUsingPriorityPollingInterval(host: System, fileName: string, callback: FileWatcherCallback, watchPriority: PollingInterval): FileWatcher; - type HostWatchFile = (fileName: string, callback: FileWatcherCallback, pollingInterval: PollingInterval | undefined) => FileWatcher; - type HostWatchDirectory = (fileName: string, callback: DirectoryWatcherCallback, recursive?: boolean) => FileWatcher; - const missingFileModifiedTime: Date; - let unchangedPollThresholds: { - [PollingInterval.Low]: number; - [PollingInterval.Medium]: number; - [PollingInterval.High]: number; - }; - function setCustomPollingValues(system: System): void; - function createDynamicPriorityPollingWatchFile(host: { - getModifiedTime: System["getModifiedTime"]; - setTimeout: System["setTimeout"]; - }): HostWatchFile; - /** - * Returns true if file status changed - */ - function onWatchedFileStat(watchedFile: WatchedFile, modifiedTime: Date): boolean; - interface RecursiveDirectoryWatcherHost { - watchDirectory: HostWatchDirectory; - getAccessibleSortedChildDirectories(path: string): ReadonlyArray; - directoryExists(dir: string): boolean; - filePathComparer: Comparer; - realpath(s: string): string; - } - /** - * Watch the directory recursively using host provided method to watch child directories - * that means if this is recursive watcher, watch the children directories as well - * (eg on OS that dont support recursive watch using fs.watch use fs.watchFile) - */ - function createRecursiveDirectoryWatcher(host: RecursiveDirectoryWatcherHost): (directoryName: string, callback: DirectoryWatcherCallback) => FileWatcher; interface System { args: string[]; newLine: string; @@ -4808,7 +3025,7 @@ declare namespace ts { getCurrentDirectory(): string; getDirectories(path: string): string[]; readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; - getModifiedTime?(path: string): Date; + getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; /** @@ -4820,13 +3037,9 @@ declare namespace ts { getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; - getEnvironmentVariable(name: string): string; - tryEnableSourceMapsForHost?(): void; - debugMode?: boolean; setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; clearTimeout?(timeoutId: any): void; clearScreen?(): void; - setBlocking?(): void; base64decode?(input: string): string; base64encode?(input: string): string; } @@ -4836,1120 +3049,8 @@ declare namespace ts { function getNodeMajorVersion(): number | undefined; let sys: System; } -declare namespace ts { - const Diagnostics: { - Unterminated_string_literal: DiagnosticMessage; - Identifier_expected: DiagnosticMessage; - _0_expected: DiagnosticMessage; - A_file_cannot_have_a_reference_to_itself: DiagnosticMessage; - Trailing_comma_not_allowed: DiagnosticMessage; - Asterisk_Slash_expected: DiagnosticMessage; - An_element_access_expression_should_take_an_argument: DiagnosticMessage; - Unexpected_token: DiagnosticMessage; - A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: DiagnosticMessage; - A_rest_parameter_must_be_last_in_a_parameter_list: DiagnosticMessage; - Parameter_cannot_have_question_mark_and_initializer: DiagnosticMessage; - A_required_parameter_cannot_follow_an_optional_parameter: DiagnosticMessage; - An_index_signature_cannot_have_a_rest_parameter: DiagnosticMessage; - An_index_signature_parameter_cannot_have_an_accessibility_modifier: DiagnosticMessage; - An_index_signature_parameter_cannot_have_a_question_mark: DiagnosticMessage; - An_index_signature_parameter_cannot_have_an_initializer: DiagnosticMessage; - An_index_signature_must_have_a_type_annotation: DiagnosticMessage; - An_index_signature_parameter_must_have_a_type_annotation: DiagnosticMessage; - An_index_signature_parameter_type_must_be_string_or_number: DiagnosticMessage; - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: DiagnosticMessage; - Accessibility_modifier_already_seen: DiagnosticMessage; - _0_modifier_must_precede_1_modifier: DiagnosticMessage; - _0_modifier_already_seen: DiagnosticMessage; - _0_modifier_cannot_appear_on_a_class_element: DiagnosticMessage; - super_must_be_followed_by_an_argument_list_or_member_access: DiagnosticMessage; - Only_ambient_modules_can_use_quoted_names: DiagnosticMessage; - Statements_are_not_allowed_in_ambient_contexts: DiagnosticMessage; - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: DiagnosticMessage; - Initializers_are_not_allowed_in_ambient_contexts: DiagnosticMessage; - _0_modifier_cannot_be_used_in_an_ambient_context: DiagnosticMessage; - _0_modifier_cannot_be_used_with_a_class_declaration: DiagnosticMessage; - _0_modifier_cannot_be_used_here: DiagnosticMessage; - _0_modifier_cannot_appear_on_a_data_property: DiagnosticMessage; - _0_modifier_cannot_appear_on_a_module_or_namespace_element: DiagnosticMessage; - A_0_modifier_cannot_be_used_with_an_interface_declaration: DiagnosticMessage; - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: DiagnosticMessage; - A_rest_parameter_cannot_be_optional: DiagnosticMessage; - A_rest_parameter_cannot_have_an_initializer: DiagnosticMessage; - A_set_accessor_must_have_exactly_one_parameter: DiagnosticMessage; - A_set_accessor_cannot_have_an_optional_parameter: DiagnosticMessage; - A_set_accessor_parameter_cannot_have_an_initializer: DiagnosticMessage; - A_set_accessor_cannot_have_rest_parameter: DiagnosticMessage; - A_get_accessor_cannot_have_parameters: DiagnosticMessage; - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: DiagnosticMessage; - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: DiagnosticMessage; - An_async_function_or_method_must_have_a_valid_awaitable_return_type: DiagnosticMessage; - The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: DiagnosticMessage; - A_promise_must_have_a_then_method: DiagnosticMessage; - The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: DiagnosticMessage; - Enum_member_must_have_initializer: DiagnosticMessage; - Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: DiagnosticMessage; - An_export_assignment_cannot_be_used_in_a_namespace: DiagnosticMessage; - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: DiagnosticMessage; - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: DiagnosticMessage; - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: DiagnosticMessage; - Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: DiagnosticMessage; - _0_modifier_cannot_appear_on_a_type_member: DiagnosticMessage; - _0_modifier_cannot_appear_on_an_index_signature: DiagnosticMessage; - A_0_modifier_cannot_be_used_with_an_import_declaration: DiagnosticMessage; - Invalid_reference_directive_syntax: DiagnosticMessage; - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: DiagnosticMessage; - An_accessor_cannot_be_declared_in_an_ambient_context: DiagnosticMessage; - _0_modifier_cannot_appear_on_a_constructor_declaration: DiagnosticMessage; - _0_modifier_cannot_appear_on_a_parameter: DiagnosticMessage; - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: DiagnosticMessage; - Type_parameters_cannot_appear_on_a_constructor_declaration: DiagnosticMessage; - Type_annotation_cannot_appear_on_a_constructor_declaration: DiagnosticMessage; - An_accessor_cannot_have_type_parameters: DiagnosticMessage; - A_set_accessor_cannot_have_a_return_type_annotation: DiagnosticMessage; - An_index_signature_must_have_exactly_one_parameter: DiagnosticMessage; - _0_list_cannot_be_empty: DiagnosticMessage; - Type_parameter_list_cannot_be_empty: DiagnosticMessage; - Type_argument_list_cannot_be_empty: DiagnosticMessage; - Invalid_use_of_0_in_strict_mode: DiagnosticMessage; - with_statements_are_not_allowed_in_strict_mode: DiagnosticMessage; - delete_cannot_be_called_on_an_identifier_in_strict_mode: DiagnosticMessage; - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: DiagnosticMessage; - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: DiagnosticMessage; - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: DiagnosticMessage; - Jump_target_cannot_cross_function_boundary: DiagnosticMessage; - A_return_statement_can_only_be_used_within_a_function_body: DiagnosticMessage; - Expression_expected: DiagnosticMessage; - Type_expected: DiagnosticMessage; - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: DiagnosticMessage; - Duplicate_label_0: DiagnosticMessage; - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: DiagnosticMessage; - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: DiagnosticMessage; - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: DiagnosticMessage; - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: DiagnosticMessage; - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: DiagnosticMessage; - An_export_assignment_cannot_have_modifiers: DiagnosticMessage; - Octal_literals_are_not_allowed_in_strict_mode: DiagnosticMessage; - Variable_declaration_list_cannot_be_empty: DiagnosticMessage; - Digit_expected: DiagnosticMessage; - Hexadecimal_digit_expected: DiagnosticMessage; - Unexpected_end_of_text: DiagnosticMessage; - Invalid_character: DiagnosticMessage; - Declaration_or_statement_expected: DiagnosticMessage; - Statement_expected: DiagnosticMessage; - case_or_default_expected: DiagnosticMessage; - Property_or_signature_expected: DiagnosticMessage; - Enum_member_expected: DiagnosticMessage; - Variable_declaration_expected: DiagnosticMessage; - Argument_expression_expected: DiagnosticMessage; - Property_assignment_expected: DiagnosticMessage; - Expression_or_comma_expected: DiagnosticMessage; - Parameter_declaration_expected: DiagnosticMessage; - Type_parameter_declaration_expected: DiagnosticMessage; - Type_argument_expected: DiagnosticMessage; - String_literal_expected: DiagnosticMessage; - Line_break_not_permitted_here: DiagnosticMessage; - or_expected: DiagnosticMessage; - Declaration_expected: DiagnosticMessage; - Import_declarations_in_a_namespace_cannot_reference_a_module: DiagnosticMessage; - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: DiagnosticMessage; - File_name_0_differs_from_already_included_file_name_1_only_in_casing: DiagnosticMessage; - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: DiagnosticMessage; - const_declarations_must_be_initialized: DiagnosticMessage; - const_declarations_can_only_be_declared_inside_a_block: DiagnosticMessage; - let_declarations_can_only_be_declared_inside_a_block: DiagnosticMessage; - Unterminated_template_literal: DiagnosticMessage; - Unterminated_regular_expression_literal: DiagnosticMessage; - An_object_member_cannot_be_declared_optional: DiagnosticMessage; - A_yield_expression_is_only_allowed_in_a_generator_body: DiagnosticMessage; - Computed_property_names_are_not_allowed_in_enums: DiagnosticMessage; - A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: DiagnosticMessage; - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: DiagnosticMessage; - A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: DiagnosticMessage; - A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: DiagnosticMessage; - A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: DiagnosticMessage; - A_comma_expression_is_not_allowed_in_a_computed_property_name: DiagnosticMessage; - extends_clause_already_seen: DiagnosticMessage; - extends_clause_must_precede_implements_clause: DiagnosticMessage; - Classes_can_only_extend_a_single_class: DiagnosticMessage; - implements_clause_already_seen: DiagnosticMessage; - Interface_declaration_cannot_have_implements_clause: DiagnosticMessage; - Binary_digit_expected: DiagnosticMessage; - Octal_digit_expected: DiagnosticMessage; - Unexpected_token_expected: DiagnosticMessage; - Property_destructuring_pattern_expected: DiagnosticMessage; - Array_element_destructuring_pattern_expected: DiagnosticMessage; - A_destructuring_declaration_must_have_an_initializer: DiagnosticMessage; - An_implementation_cannot_be_declared_in_ambient_contexts: DiagnosticMessage; - Modifiers_cannot_appear_here: DiagnosticMessage; - Merge_conflict_marker_encountered: DiagnosticMessage; - A_rest_element_cannot_have_an_initializer: DiagnosticMessage; - A_parameter_property_may_not_be_declared_using_a_binding_pattern: DiagnosticMessage; - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: DiagnosticMessage; - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: DiagnosticMessage; - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: DiagnosticMessage; - An_import_declaration_cannot_have_modifiers: DiagnosticMessage; - Module_0_has_no_default_export: DiagnosticMessage; - An_export_declaration_cannot_have_modifiers: DiagnosticMessage; - Export_declarations_are_not_permitted_in_a_namespace: DiagnosticMessage; - Catch_clause_variable_cannot_have_a_type_annotation: DiagnosticMessage; - Catch_clause_variable_cannot_have_an_initializer: DiagnosticMessage; - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: DiagnosticMessage; - Unterminated_Unicode_escape_sequence: DiagnosticMessage; - Line_terminator_not_permitted_before_arrow: DiagnosticMessage; - Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: DiagnosticMessage; - Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: DiagnosticMessage; - Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: DiagnosticMessage; - Decorators_are_not_valid_here: DiagnosticMessage; - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: DiagnosticMessage; - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: DiagnosticMessage; - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: DiagnosticMessage; - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: DiagnosticMessage; - A_class_declaration_without_the_default_modifier_must_have_a_name: DiagnosticMessage; - Identifier_expected_0_is_a_reserved_word_in_strict_mode: DiagnosticMessage; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: DiagnosticMessage; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: DiagnosticMessage; - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: DiagnosticMessage; - Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: DiagnosticMessage; - Export_assignment_is_not_supported_when_module_flag_is_system: DiagnosticMessage; - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: DiagnosticMessage; - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: DiagnosticMessage; - Generators_are_not_allowed_in_an_ambient_context: DiagnosticMessage; - An_overload_signature_cannot_be_declared_as_a_generator: DiagnosticMessage; - _0_tag_already_specified: DiagnosticMessage; - Signature_0_must_be_a_type_predicate: DiagnosticMessage; - Cannot_find_parameter_0: DiagnosticMessage; - Type_predicate_0_is_not_assignable_to_1: DiagnosticMessage; - Parameter_0_is_not_in_the_same_position_as_parameter_1: DiagnosticMessage; - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: DiagnosticMessage; - A_type_predicate_cannot_reference_a_rest_parameter: DiagnosticMessage; - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: DiagnosticMessage; - An_export_assignment_can_only_be_used_in_a_module: DiagnosticMessage; - An_import_declaration_can_only_be_used_in_a_namespace_or_module: DiagnosticMessage; - An_export_declaration_can_only_be_used_in_a_module: DiagnosticMessage; - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: DiagnosticMessage; - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: DiagnosticMessage; - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: DiagnosticMessage; - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: DiagnosticMessage; - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: DiagnosticMessage; - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: DiagnosticMessage; - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: DiagnosticMessage; - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: DiagnosticMessage; - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: DiagnosticMessage; - _0_modifier_cannot_be_used_with_1_modifier: DiagnosticMessage; - Abstract_methods_can_only_appear_within_an_abstract_class: DiagnosticMessage; - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: DiagnosticMessage; - An_interface_property_cannot_have_an_initializer: DiagnosticMessage; - A_type_literal_property_cannot_have_an_initializer: DiagnosticMessage; - A_class_member_cannot_have_the_0_keyword: DiagnosticMessage; - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: DiagnosticMessage; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: DiagnosticMessage; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: DiagnosticMessage; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: DiagnosticMessage; - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: DiagnosticMessage; - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: DiagnosticMessage; - A_definite_assignment_assertion_is_not_permitted_in_this_context: DiagnosticMessage; - A_rest_element_must_be_last_in_a_tuple_type: DiagnosticMessage; - A_required_element_cannot_follow_an_optional_element: DiagnosticMessage; - with_statements_are_not_allowed_in_an_async_function_block: DiagnosticMessage; - await_expression_is_only_allowed_within_an_async_function: DiagnosticMessage; - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: DiagnosticMessage; - The_body_of_an_if_statement_cannot_be_the_empty_statement: DiagnosticMessage; - Global_module_exports_may_only_appear_in_module_files: DiagnosticMessage; - Global_module_exports_may_only_appear_in_declaration_files: DiagnosticMessage; - Global_module_exports_may_only_appear_at_top_level: DiagnosticMessage; - A_parameter_property_cannot_be_declared_using_a_rest_parameter: DiagnosticMessage; - An_abstract_accessor_cannot_have_an_implementation: DiagnosticMessage; - A_default_export_can_only_be_used_in_an_ECMAScript_style_module: DiagnosticMessage; - Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: DiagnosticMessage; - Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: DiagnosticMessage; - Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: DiagnosticMessage; - Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext: DiagnosticMessage; - Dynamic_import_must_have_one_specifier_as_an_argument: DiagnosticMessage; - Specifier_of_dynamic_import_cannot_be_spread_element: DiagnosticMessage; - Dynamic_import_cannot_have_type_arguments: DiagnosticMessage; - String_literal_with_double_quotes_expected: DiagnosticMessage; - Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: DiagnosticMessage; - _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: DiagnosticMessage; - A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: DiagnosticMessage; - A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: DiagnosticMessage; - A_variable_whose_type_is_a_unique_symbol_type_must_be_const: DiagnosticMessage; - unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: DiagnosticMessage; - unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: DiagnosticMessage; - unique_symbol_types_are_not_allowed_here: DiagnosticMessage; - An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: DiagnosticMessage; - An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: DiagnosticMessage; - infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: DiagnosticMessage; - Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: DiagnosticMessage; - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here: DiagnosticMessage; - Type_arguments_cannot_be_used_here: DiagnosticMessage; - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: DiagnosticMessage; - Duplicate_identifier_0: DiagnosticMessage; - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: DiagnosticMessage; - Static_members_cannot_reference_class_type_parameters: DiagnosticMessage; - Circular_definition_of_import_alias_0: DiagnosticMessage; - Cannot_find_name_0: DiagnosticMessage; - Module_0_has_no_exported_member_1: DiagnosticMessage; - File_0_is_not_a_module: DiagnosticMessage; - Cannot_find_module_0: DiagnosticMessage; - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: DiagnosticMessage; - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: DiagnosticMessage; - Type_0_recursively_references_itself_as_a_base_type: DiagnosticMessage; - A_class_may_only_extend_another_class: DiagnosticMessage; - An_interface_may_only_extend_a_class_or_another_interface: DiagnosticMessage; - Type_parameter_0_has_a_circular_constraint: DiagnosticMessage; - Generic_type_0_requires_1_type_argument_s: DiagnosticMessage; - Type_0_is_not_generic: DiagnosticMessage; - Global_type_0_must_be_a_class_or_interface_type: DiagnosticMessage; - Global_type_0_must_have_1_type_parameter_s: DiagnosticMessage; - Cannot_find_global_type_0: DiagnosticMessage; - Named_property_0_of_types_1_and_2_are_not_identical: DiagnosticMessage; - Interface_0_cannot_simultaneously_extend_types_1_and_2: DiagnosticMessage; - Excessive_stack_depth_comparing_types_0_and_1: DiagnosticMessage; - Type_0_is_not_assignable_to_type_1: DiagnosticMessage; - Cannot_redeclare_exported_variable_0: DiagnosticMessage; - Property_0_is_missing_in_type_1: DiagnosticMessage; - Property_0_is_private_in_type_1_but_not_in_type_2: DiagnosticMessage; - Types_of_property_0_are_incompatible: DiagnosticMessage; - Property_0_is_optional_in_type_1_but_required_in_type_2: DiagnosticMessage; - Types_of_parameters_0_and_1_are_incompatible: DiagnosticMessage; - Index_signature_is_missing_in_type_0: DiagnosticMessage; - Index_signatures_are_incompatible: DiagnosticMessage; - this_cannot_be_referenced_in_a_module_or_namespace_body: DiagnosticMessage; - this_cannot_be_referenced_in_current_location: DiagnosticMessage; - this_cannot_be_referenced_in_constructor_arguments: DiagnosticMessage; - this_cannot_be_referenced_in_a_static_property_initializer: DiagnosticMessage; - super_can_only_be_referenced_in_a_derived_class: DiagnosticMessage; - super_cannot_be_referenced_in_constructor_arguments: DiagnosticMessage; - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: DiagnosticMessage; - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: DiagnosticMessage; - Property_0_does_not_exist_on_type_1: DiagnosticMessage; - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: DiagnosticMessage; - Property_0_is_private_and_only_accessible_within_class_1: DiagnosticMessage; - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: DiagnosticMessage; - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: DiagnosticMessage; - Type_0_does_not_satisfy_the_constraint_1: DiagnosticMessage; - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: DiagnosticMessage; - Call_target_does_not_contain_any_signatures: DiagnosticMessage; - Untyped_function_calls_may_not_accept_type_arguments: DiagnosticMessage; - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: DiagnosticMessage; - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures: DiagnosticMessage; - Only_a_void_function_can_be_called_with_the_new_keyword: DiagnosticMessage; - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: DiagnosticMessage; - Type_0_cannot_be_converted_to_type_1: DiagnosticMessage; - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: DiagnosticMessage; - This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: DiagnosticMessage; - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: DiagnosticMessage; - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: DiagnosticMessage; - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: DiagnosticMessage; - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: DiagnosticMessage; - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: DiagnosticMessage; - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: DiagnosticMessage; - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: DiagnosticMessage; - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: DiagnosticMessage; - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: DiagnosticMessage; - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: DiagnosticMessage; - Operator_0_cannot_be_applied_to_types_1_and_2: DiagnosticMessage; - Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: DiagnosticMessage; - Type_parameter_name_cannot_be_0: DiagnosticMessage; - A_parameter_property_is_only_allowed_in_a_constructor_implementation: DiagnosticMessage; - A_rest_parameter_must_be_of_an_array_type: DiagnosticMessage; - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: DiagnosticMessage; - Parameter_0_cannot_be_referenced_in_its_initializer: DiagnosticMessage; - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: DiagnosticMessage; - Duplicate_string_index_signature: DiagnosticMessage; - Duplicate_number_index_signature: DiagnosticMessage; - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: DiagnosticMessage; - Constructors_for_derived_classes_must_contain_a_super_call: DiagnosticMessage; - A_get_accessor_must_return_a_value: DiagnosticMessage; - Getter_and_setter_accessors_do_not_agree_in_visibility: DiagnosticMessage; - get_and_set_accessor_must_have_the_same_type: DiagnosticMessage; - A_signature_with_an_implementation_cannot_use_a_string_literal_type: DiagnosticMessage; - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: DiagnosticMessage; - Overload_signatures_must_all_be_exported_or_non_exported: DiagnosticMessage; - Overload_signatures_must_all_be_ambient_or_non_ambient: DiagnosticMessage; - Overload_signatures_must_all_be_public_private_or_protected: DiagnosticMessage; - Overload_signatures_must_all_be_optional_or_required: DiagnosticMessage; - Function_overload_must_be_static: DiagnosticMessage; - Function_overload_must_not_be_static: DiagnosticMessage; - Function_implementation_name_must_be_0: DiagnosticMessage; - Constructor_implementation_is_missing: DiagnosticMessage; - Function_implementation_is_missing_or_not_immediately_following_the_declaration: DiagnosticMessage; - Multiple_constructor_implementations_are_not_allowed: DiagnosticMessage; - Duplicate_function_implementation: DiagnosticMessage; - Overload_signature_is_not_compatible_with_function_implementation: DiagnosticMessage; - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: DiagnosticMessage; - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: DiagnosticMessage; - Declaration_name_conflicts_with_built_in_global_identifier_0: DiagnosticMessage; - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: DiagnosticMessage; - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: DiagnosticMessage; - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: DiagnosticMessage; - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: DiagnosticMessage; - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: DiagnosticMessage; - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: DiagnosticMessage; - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: DiagnosticMessage; - The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: DiagnosticMessage; - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0: DiagnosticMessage; - Setters_cannot_return_a_value: DiagnosticMessage; - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: DiagnosticMessage; - The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: DiagnosticMessage; - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: DiagnosticMessage; - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: DiagnosticMessage; - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: DiagnosticMessage; - Class_name_cannot_be_0: DiagnosticMessage; - Class_0_incorrectly_extends_base_class_1: DiagnosticMessage; - Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: DiagnosticMessage; - Class_static_side_0_incorrectly_extends_base_class_static_side_1: DiagnosticMessage; - Class_0_incorrectly_implements_interface_1: DiagnosticMessage; - A_class_may_only_implement_another_class_or_interface: DiagnosticMessage; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: DiagnosticMessage; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: DiagnosticMessage; - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: DiagnosticMessage; - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: DiagnosticMessage; - Interface_name_cannot_be_0: DiagnosticMessage; - All_declarations_of_0_must_have_identical_type_parameters: DiagnosticMessage; - Interface_0_incorrectly_extends_interface_1: DiagnosticMessage; - Enum_name_cannot_be_0: DiagnosticMessage; - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: DiagnosticMessage; - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: DiagnosticMessage; - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: DiagnosticMessage; - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: DiagnosticMessage; - Ambient_module_declaration_cannot_specify_relative_module_name: DiagnosticMessage; - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: DiagnosticMessage; - Import_name_cannot_be_0: DiagnosticMessage; - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: DiagnosticMessage; - Import_declaration_conflicts_with_local_declaration_of_0: DiagnosticMessage; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: DiagnosticMessage; - Types_have_separate_declarations_of_a_private_property_0: DiagnosticMessage; - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: DiagnosticMessage; - Property_0_is_protected_in_type_1_but_public_in_type_2: DiagnosticMessage; - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: DiagnosticMessage; - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: DiagnosticMessage; - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: DiagnosticMessage; - Block_scoped_variable_0_used_before_its_declaration: DiagnosticMessage; - Class_0_used_before_its_declaration: DiagnosticMessage; - Enum_0_used_before_its_declaration: DiagnosticMessage; - Cannot_redeclare_block_scoped_variable_0: DiagnosticMessage; - An_enum_member_cannot_have_a_numeric_name: DiagnosticMessage; - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: DiagnosticMessage; - Variable_0_is_used_before_being_assigned: DiagnosticMessage; - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: DiagnosticMessage; - Type_alias_0_circularly_references_itself: DiagnosticMessage; - Type_alias_name_cannot_be_0: DiagnosticMessage; - An_AMD_module_cannot_have_multiple_name_assignments: DiagnosticMessage; - Type_0_has_no_property_1_and_no_string_index_signature: DiagnosticMessage; - Type_0_has_no_property_1: DiagnosticMessage; - Type_0_is_not_an_array_type: DiagnosticMessage; - A_rest_element_must_be_last_in_a_destructuring_pattern: DiagnosticMessage; - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: DiagnosticMessage; - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: DiagnosticMessage; - this_cannot_be_referenced_in_a_computed_property_name: DiagnosticMessage; - super_cannot_be_referenced_in_a_computed_property_name: DiagnosticMessage; - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: DiagnosticMessage; - Cannot_find_global_value_0: DiagnosticMessage; - The_0_operator_cannot_be_applied_to_type_symbol: DiagnosticMessage; - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: DiagnosticMessage; - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: DiagnosticMessage; - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: DiagnosticMessage; - Enum_declarations_must_all_be_const_or_non_const: DiagnosticMessage; - In_const_enum_declarations_member_initializer_must_be_constant_expression: DiagnosticMessage; - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query: DiagnosticMessage; - A_const_enum_member_can_only_be_accessed_using_a_string_literal: DiagnosticMessage; - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: DiagnosticMessage; - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: DiagnosticMessage; - Property_0_does_not_exist_on_const_enum_1: DiagnosticMessage; - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: DiagnosticMessage; - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: DiagnosticMessage; - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: DiagnosticMessage; - Export_declaration_conflicts_with_exported_declaration_of_0: DiagnosticMessage; - The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: DiagnosticMessage; - Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator: DiagnosticMessage; - An_iterator_must_have_a_next_method: DiagnosticMessage; - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: DiagnosticMessage; - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: DiagnosticMessage; - Cannot_redeclare_identifier_0_in_catch_clause: DiagnosticMessage; - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: DiagnosticMessage; - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: DiagnosticMessage; - Type_0_is_not_an_array_type_or_a_string_type: DiagnosticMessage; - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: DiagnosticMessage; - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: DiagnosticMessage; - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: DiagnosticMessage; - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: DiagnosticMessage; - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: DiagnosticMessage; - A_rest_element_cannot_contain_a_binding_pattern: DiagnosticMessage; - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: DiagnosticMessage; - Cannot_find_namespace_0: DiagnosticMessage; - Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: DiagnosticMessage; - A_generator_cannot_have_a_void_type_annotation: DiagnosticMessage; - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: DiagnosticMessage; - Type_0_is_not_a_constructor_function_type: DiagnosticMessage; - No_base_constructor_has_the_specified_number_of_type_arguments: DiagnosticMessage; - Base_constructor_return_type_0_is_not_a_class_or_interface_type: DiagnosticMessage; - Base_constructors_must_all_have_the_same_return_type: DiagnosticMessage; - Cannot_create_an_instance_of_an_abstract_class: DiagnosticMessage; - Overload_signatures_must_all_be_abstract_or_non_abstract: DiagnosticMessage; - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: DiagnosticMessage; - Classes_containing_abstract_methods_must_be_marked_abstract: DiagnosticMessage; - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: DiagnosticMessage; - All_declarations_of_an_abstract_method_must_be_consecutive: DiagnosticMessage; - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: DiagnosticMessage; - A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: DiagnosticMessage; - An_async_iterator_must_have_a_next_method: DiagnosticMessage; - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: DiagnosticMessage; - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: DiagnosticMessage; - The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: DiagnosticMessage; - yield_expressions_cannot_be_used_in_a_parameter_initializer: DiagnosticMessage; - await_expressions_cannot_be_used_in_a_parameter_initializer: DiagnosticMessage; - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: DiagnosticMessage; - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: DiagnosticMessage; - The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary: DiagnosticMessage; - A_module_cannot_have_multiple_default_exports: DiagnosticMessage; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: DiagnosticMessage; - Property_0_is_incompatible_with_index_signature: DiagnosticMessage; - Object_is_possibly_null: DiagnosticMessage; - Object_is_possibly_undefined: DiagnosticMessage; - Object_is_possibly_null_or_undefined: DiagnosticMessage; - A_function_returning_never_cannot_have_a_reachable_end_point: DiagnosticMessage; - Enum_type_0_has_members_with_initializers_that_are_not_literals: DiagnosticMessage; - Type_0_cannot_be_used_to_index_type_1: DiagnosticMessage; - Type_0_has_no_matching_index_signature_for_type_1: DiagnosticMessage; - Type_0_cannot_be_used_as_an_index_type: DiagnosticMessage; - Cannot_assign_to_0_because_it_is_not_a_variable: DiagnosticMessage; - Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: DiagnosticMessage; - The_target_of_an_assignment_must_be_a_variable_or_a_property_access: DiagnosticMessage; - Index_signature_in_type_0_only_permits_reading: DiagnosticMessage; - Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: DiagnosticMessage; - Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: DiagnosticMessage; - A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: DiagnosticMessage; - Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: DiagnosticMessage; - The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: DiagnosticMessage; - Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: DiagnosticMessage; - Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: DiagnosticMessage; - Generic_type_instantiation_is_excessively_deep_and_possibly_infinite: DiagnosticMessage; - Property_0_does_not_exist_on_type_1_Did_you_mean_2: DiagnosticMessage; - Cannot_find_name_0_Did_you_mean_1: DiagnosticMessage; - Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: DiagnosticMessage; - Expected_0_arguments_but_got_1: DiagnosticMessage; - Expected_at_least_0_arguments_but_got_1: DiagnosticMessage; - Expected_0_arguments_but_got_1_or_more: DiagnosticMessage; - Expected_at_least_0_arguments_but_got_1_or_more: DiagnosticMessage; - Expected_0_type_arguments_but_got_1: DiagnosticMessage; - Type_0_has_no_properties_in_common_with_type_1: DiagnosticMessage; - Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: DiagnosticMessage; - Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: DiagnosticMessage; - Base_class_expressions_cannot_reference_class_type_parameters: DiagnosticMessage; - The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: DiagnosticMessage; - Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: DiagnosticMessage; - Property_0_is_used_before_being_assigned: DiagnosticMessage; - A_rest_element_cannot_have_a_property_name: DiagnosticMessage; - Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: DiagnosticMessage; - Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: DiagnosticMessage; - Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: DiagnosticMessage; - Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: DiagnosticMessage; - Object_is_of_type_unknown: DiagnosticMessage; - Rest_signatures_are_incompatible: DiagnosticMessage; - Property_0_is_incompatible_with_rest_element_type: DiagnosticMessage; - A_rest_element_type_must_be_an_array_type: DiagnosticMessage; - JSX_element_attributes_type_0_may_not_be_a_union_type: DiagnosticMessage; - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: DiagnosticMessage; - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: DiagnosticMessage; - Property_0_in_type_1_is_not_assignable_to_type_2: DiagnosticMessage; - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: DiagnosticMessage; - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: DiagnosticMessage; - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: DiagnosticMessage; - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: DiagnosticMessage; - The_global_type_JSX_0_may_not_have_more_than_one_property: DiagnosticMessage; - JSX_spread_child_must_be_an_array_type: DiagnosticMessage; - Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: DiagnosticMessage; - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: DiagnosticMessage; - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: DiagnosticMessage; - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: DiagnosticMessage; - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: DiagnosticMessage; - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: DiagnosticMessage; - JSX_expressions_must_have_one_parent_element: DiagnosticMessage; - Type_0_provides_no_match_for_the_signature_1: DiagnosticMessage; - super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: DiagnosticMessage; - super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: DiagnosticMessage; - Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: DiagnosticMessage; - Cannot_find_name_0_Did_you_mean_the_static_member_1_0: DiagnosticMessage; - Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: DiagnosticMessage; - Invalid_module_name_in_augmentation_module_0_cannot_be_found: DiagnosticMessage; - Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: DiagnosticMessage; - Exports_and_export_assignments_are_not_permitted_in_module_augmentations: DiagnosticMessage; - Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: DiagnosticMessage; - export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: DiagnosticMessage; - Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: DiagnosticMessage; - Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: DiagnosticMessage; - Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: DiagnosticMessage; - Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: DiagnosticMessage; - Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: DiagnosticMessage; - Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: DiagnosticMessage; - Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: DiagnosticMessage; - Accessors_must_both_be_abstract_or_non_abstract: DiagnosticMessage; - A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: DiagnosticMessage; - Type_0_is_not_comparable_to_type_1: DiagnosticMessage; - A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: DiagnosticMessage; - A_0_parameter_must_be_the_first_parameter: DiagnosticMessage; - A_constructor_cannot_have_a_this_parameter: DiagnosticMessage; - get_and_set_accessor_must_have_the_same_this_type: DiagnosticMessage; - this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: DiagnosticMessage; - The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: DiagnosticMessage; - The_this_types_of_each_signature_are_incompatible: DiagnosticMessage; - _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: DiagnosticMessage; - All_declarations_of_0_must_have_identical_modifiers: DiagnosticMessage; - Cannot_find_type_definition_file_for_0: DiagnosticMessage; - Cannot_extend_an_interface_0_Did_you_mean_implements: DiagnosticMessage; - An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: DiagnosticMessage; - _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: DiagnosticMessage; - _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: DiagnosticMessage; - Namespace_0_has_no_exported_member_1: DiagnosticMessage; - Left_side_of_comma_operator_is_unused_and_has_no_side_effects: DiagnosticMessage; - The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: DiagnosticMessage; - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: DiagnosticMessage; - Spread_types_may_only_be_created_from_object_types: DiagnosticMessage; - Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: DiagnosticMessage; - Rest_types_may_only_be_created_from_object_types: DiagnosticMessage; - The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: DiagnosticMessage; - _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: DiagnosticMessage; - The_operand_of_a_delete_operator_must_be_a_property_reference: DiagnosticMessage; - The_operand_of_a_delete_operator_cannot_be_a_read_only_property: DiagnosticMessage; - 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: DiagnosticMessage; - Required_type_parameters_may_not_follow_optional_type_parameters: DiagnosticMessage; - Generic_type_0_requires_between_1_and_2_type_arguments: DiagnosticMessage; - Cannot_use_namespace_0_as_a_value: DiagnosticMessage; - Cannot_use_namespace_0_as_a_type: DiagnosticMessage; - _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: DiagnosticMessage; - A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: DiagnosticMessage; - A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: DiagnosticMessage; - Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: DiagnosticMessage; - The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: DiagnosticMessage; - Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: DiagnosticMessage; - Type_parameter_0_has_a_circular_default: DiagnosticMessage; - Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2: DiagnosticMessage; - Duplicate_declaration_0: DiagnosticMessage; - Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: DiagnosticMessage; - Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass: DiagnosticMessage; - Cannot_invoke_an_object_which_is_possibly_null: DiagnosticMessage; - Cannot_invoke_an_object_which_is_possibly_undefined: DiagnosticMessage; - Cannot_invoke_an_object_which_is_possibly_null_or_undefined: DiagnosticMessage; - Module_0_has_no_exported_member_1_Did_you_mean_2: DiagnosticMessage; - Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: DiagnosticMessage; - Cannot_find_lib_definition_for_0: DiagnosticMessage; - Cannot_find_lib_definition_for_0_Did_you_mean_1: DiagnosticMessage; - Import_declaration_0_is_using_private_name_1: DiagnosticMessage; - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: DiagnosticMessage; - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: DiagnosticMessage; - extends_clause_of_exported_class_0_has_or_is_using_private_name_1: DiagnosticMessage; - extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: DiagnosticMessage; - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Exported_variable_0_has_or_is_using_private_name_1: DiagnosticMessage; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Public_property_0_of_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Property_0_of_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: DiagnosticMessage; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: DiagnosticMessage; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: DiagnosticMessage; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: DiagnosticMessage; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: DiagnosticMessage; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: DiagnosticMessage; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: DiagnosticMessage; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: DiagnosticMessage; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: DiagnosticMessage; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: DiagnosticMessage; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: DiagnosticMessage; - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: DiagnosticMessage; - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: DiagnosticMessage; - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: DiagnosticMessage; - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: DiagnosticMessage; - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: DiagnosticMessage; - Return_type_of_exported_function_has_or_is_using_private_name_0: DiagnosticMessage; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_0_of_exported_function_has_or_is_using_private_name_1: DiagnosticMessage; - Exported_type_alias_0_has_or_is_using_private_name_1: DiagnosticMessage; - Default_export_of_the_module_has_or_is_using_private_name_0: DiagnosticMessage; - Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: DiagnosticMessage; - Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: DiagnosticMessage; - Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - Property_0_of_exported_class_expression_may_not_be_private_or_protected: DiagnosticMessage; - Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Public_static_method_0_of_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: DiagnosticMessage; - Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Public_method_0_of_exported_class_has_or_is_using_private_name_1: DiagnosticMessage; - Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: DiagnosticMessage; - Method_0_of_exported_interface_has_or_is_using_private_name_1: DiagnosticMessage; - The_current_host_does_not_support_the_0_option: DiagnosticMessage; - Cannot_find_the_common_subdirectory_path_for_the_input_files: DiagnosticMessage; - File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: DiagnosticMessage; - Cannot_read_file_0_Colon_1: DiagnosticMessage; - Failed_to_parse_file_0_Colon_1: DiagnosticMessage; - Unknown_compiler_option_0: DiagnosticMessage; - Compiler_option_0_requires_a_value_of_type_1: DiagnosticMessage; - Could_not_write_file_0_Colon_1: DiagnosticMessage; - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: DiagnosticMessage; - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: DiagnosticMessage; - Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: DiagnosticMessage; - Option_0_cannot_be_specified_without_specifying_option_1: DiagnosticMessage; - Option_0_cannot_be_specified_with_option_1: DiagnosticMessage; - A_tsconfig_json_file_is_already_defined_at_Colon_0: DiagnosticMessage; - Cannot_write_file_0_because_it_would_overwrite_input_file: DiagnosticMessage; - Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: DiagnosticMessage; - Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: DiagnosticMessage; - The_specified_path_does_not_exist_Colon_0: DiagnosticMessage; - Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: DiagnosticMessage; - Option_paths_cannot_be_used_without_specifying_baseUrl_option: DiagnosticMessage; - Pattern_0_can_have_at_most_one_Asterisk_character: DiagnosticMessage; - Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: DiagnosticMessage; - Substitutions_for_pattern_0_should_be_an_array: DiagnosticMessage; - Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: DiagnosticMessage; - File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: DiagnosticMessage; - Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: DiagnosticMessage; - Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: DiagnosticMessage; - 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: DiagnosticMessage; - Option_0_cannot_be_specified_without_specifying_option_1_or_option_2: DiagnosticMessage; - Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy: DiagnosticMessage; - Generates_a_sourcemap_for_each_corresponding_d_ts_file: DiagnosticMessage; - Concatenate_and_emit_output_to_single_file: DiagnosticMessage; - Generates_corresponding_d_ts_file: DiagnosticMessage; - Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: DiagnosticMessage; - Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: DiagnosticMessage; - Watch_input_files: DiagnosticMessage; - Redirect_output_structure_to_the_directory: DiagnosticMessage; - Do_not_erase_const_enum_declarations_in_generated_code: DiagnosticMessage; - Do_not_emit_outputs_if_any_errors_were_reported: DiagnosticMessage; - Do_not_emit_comments_to_output: DiagnosticMessage; - Do_not_emit_outputs: DiagnosticMessage; - Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: DiagnosticMessage; - Skip_type_checking_of_declaration_files: DiagnosticMessage; - Do_not_resolve_the_real_path_of_symlinks: DiagnosticMessage; - Only_emit_d_ts_declaration_files: DiagnosticMessage; - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_or_ESNEXT: DiagnosticMessage; - Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: DiagnosticMessage; - Print_this_message: DiagnosticMessage; - Print_the_compiler_s_version: DiagnosticMessage; - Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: DiagnosticMessage; - Syntax_Colon_0: DiagnosticMessage; - options: DiagnosticMessage; - file: DiagnosticMessage; - Examples_Colon_0: DiagnosticMessage; - Options_Colon: DiagnosticMessage; - Version_0: DiagnosticMessage; - Insert_command_line_options_and_files_from_a_file: DiagnosticMessage; - Starting_compilation_in_watch_mode: DiagnosticMessage; - File_change_detected_Starting_incremental_compilation: DiagnosticMessage; - KIND: DiagnosticMessage; - FILE: DiagnosticMessage; - VERSION: DiagnosticMessage; - LOCATION: DiagnosticMessage; - DIRECTORY: DiagnosticMessage; - STRATEGY: DiagnosticMessage; - FILE_OR_DIRECTORY: DiagnosticMessage; - Generates_corresponding_map_file: DiagnosticMessage; - Compiler_option_0_expects_an_argument: DiagnosticMessage; - Unterminated_quoted_string_in_response_file_0: DiagnosticMessage; - Argument_for_0_option_must_be_Colon_1: DiagnosticMessage; - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: DiagnosticMessage; - Unsupported_locale_0: DiagnosticMessage; - Unable_to_open_file_0: DiagnosticMessage; - Corrupted_locale_file_0: DiagnosticMessage; - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: DiagnosticMessage; - File_0_not_found: DiagnosticMessage; - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: DiagnosticMessage; - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: DiagnosticMessage; - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: DiagnosticMessage; - Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: DiagnosticMessage; - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: DiagnosticMessage; - Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: DiagnosticMessage; - NEWLINE: DiagnosticMessage; - Option_0_can_only_be_specified_in_tsconfig_json_file: DiagnosticMessage; - Enables_experimental_support_for_ES7_decorators: DiagnosticMessage; - Enables_experimental_support_for_emitting_type_metadata_for_decorators: DiagnosticMessage; - Enables_experimental_support_for_ES7_async_functions: DiagnosticMessage; - Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: DiagnosticMessage; - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: DiagnosticMessage; - Successfully_created_a_tsconfig_json_file: DiagnosticMessage; - Suppress_excess_property_checks_for_object_literals: DiagnosticMessage; - Stylize_errors_and_messages_using_color_and_context_experimental: DiagnosticMessage; - Do_not_report_errors_on_unused_labels: DiagnosticMessage; - Report_error_when_not_all_code_paths_in_function_return_a_value: DiagnosticMessage; - Report_errors_for_fallthrough_cases_in_switch_statement: DiagnosticMessage; - Do_not_report_errors_on_unreachable_code: DiagnosticMessage; - Disallow_inconsistently_cased_references_to_the_same_file: DiagnosticMessage; - Specify_library_files_to_be_included_in_the_compilation: DiagnosticMessage; - Specify_JSX_code_generation_Colon_preserve_react_native_or_react: DiagnosticMessage; - File_0_has_an_unsupported_extension_so_skipping_it: DiagnosticMessage; - Only_amd_and_system_modules_are_supported_alongside_0: DiagnosticMessage; - Base_directory_to_resolve_non_absolute_module_names: DiagnosticMessage; - Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: DiagnosticMessage; - Enable_tracing_of_the_name_resolution_process: DiagnosticMessage; - Resolving_module_0_from_1: DiagnosticMessage; - Explicitly_specified_module_resolution_kind_Colon_0: DiagnosticMessage; - Module_resolution_kind_is_not_specified_using_0: DiagnosticMessage; - Module_name_0_was_successfully_resolved_to_1: DiagnosticMessage; - Module_name_0_was_not_resolved: DiagnosticMessage; - paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: DiagnosticMessage; - Module_name_0_matched_pattern_1: DiagnosticMessage; - Trying_substitution_0_candidate_module_location_Colon_1: DiagnosticMessage; - Resolving_module_name_0_relative_to_base_url_1_2: DiagnosticMessage; - Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: DiagnosticMessage; - File_0_does_not_exist: DiagnosticMessage; - File_0_exist_use_it_as_a_name_resolution_result: DiagnosticMessage; - Loading_module_0_from_node_modules_folder_target_file_type_1: DiagnosticMessage; - Found_package_json_at_0: DiagnosticMessage; - package_json_does_not_have_a_0_field: DiagnosticMessage; - package_json_has_0_field_1_that_references_2: DiagnosticMessage; - Allow_javascript_files_to_be_compiled: DiagnosticMessage; - Option_0_should_have_array_of_strings_as_a_value: DiagnosticMessage; - Checking_if_0_is_the_longest_matching_prefix_for_1_2: DiagnosticMessage; - Expected_type_of_0_field_in_package_json_to_be_string_got_1: DiagnosticMessage; - baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: DiagnosticMessage; - rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: DiagnosticMessage; - Longest_matching_prefix_for_0_is_1: DiagnosticMessage; - Loading_0_from_the_root_dir_1_candidate_location_2: DiagnosticMessage; - Trying_other_entries_in_rootDirs: DiagnosticMessage; - Module_resolution_using_rootDirs_has_failed: DiagnosticMessage; - Do_not_emit_use_strict_directives_in_module_output: DiagnosticMessage; - Enable_strict_null_checks: DiagnosticMessage; - Unknown_option_excludes_Did_you_mean_exclude: DiagnosticMessage; - Raise_error_on_this_expressions_with_an_implied_any_type: DiagnosticMessage; - Resolving_type_reference_directive_0_containing_file_1_root_directory_2: DiagnosticMessage; - Resolving_using_primary_search_paths: DiagnosticMessage; - Resolving_from_node_modules_folder: DiagnosticMessage; - Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: DiagnosticMessage; - Type_reference_directive_0_was_not_resolved: DiagnosticMessage; - Resolving_with_primary_search_path_0: DiagnosticMessage; - Root_directory_cannot_be_determined_skipping_primary_search_paths: DiagnosticMessage; - Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: DiagnosticMessage; - Type_declaration_files_to_be_included_in_compilation: DiagnosticMessage; - Looking_up_in_node_modules_folder_initial_location_0: DiagnosticMessage; - Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: DiagnosticMessage; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: DiagnosticMessage; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: DiagnosticMessage; - Resolving_real_path_for_0_result_1: DiagnosticMessage; - Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: DiagnosticMessage; - File_name_0_has_a_1_extension_stripping_it: DiagnosticMessage; - _0_is_declared_but_its_value_is_never_read: DiagnosticMessage; - Report_errors_on_unused_locals: DiagnosticMessage; - Report_errors_on_unused_parameters: DiagnosticMessage; - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: DiagnosticMessage; - Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: DiagnosticMessage; - Property_0_is_declared_but_its_value_is_never_read: DiagnosticMessage; - Import_emit_helpers_from_tslib: DiagnosticMessage; - Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: DiagnosticMessage; - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: DiagnosticMessage; - Module_0_was_resolved_to_1_but_jsx_is_not_set: DiagnosticMessage; - Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: DiagnosticMessage; - Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: DiagnosticMessage; - Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: DiagnosticMessage; - Resolution_for_module_0_was_found_in_cache_from_location_1: DiagnosticMessage; - Directory_0_does_not_exist_skipping_all_lookups_in_it: DiagnosticMessage; - Show_diagnostic_information: DiagnosticMessage; - Show_verbose_diagnostic_information: DiagnosticMessage; - Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: DiagnosticMessage; - Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: DiagnosticMessage; - Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: DiagnosticMessage; - Print_names_of_generated_files_part_of_the_compilation: DiagnosticMessage; - Print_names_of_files_part_of_the_compilation: DiagnosticMessage; - The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: DiagnosticMessage; - Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: DiagnosticMessage; - Do_not_include_the_default_library_file_lib_d_ts: DiagnosticMessage; - Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: DiagnosticMessage; - Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: DiagnosticMessage; - List_of_folders_to_include_type_definitions_from: DiagnosticMessage; - Disable_size_limitations_on_JavaScript_projects: DiagnosticMessage; - The_character_set_of_the_input_files: DiagnosticMessage; - Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: DiagnosticMessage; - Do_not_truncate_error_messages: DiagnosticMessage; - Output_directory_for_generated_declaration_files: DiagnosticMessage; - A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: DiagnosticMessage; - List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: DiagnosticMessage; - Show_all_compiler_options: DiagnosticMessage; - Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: DiagnosticMessage; - Command_line_Options: DiagnosticMessage; - Basic_Options: DiagnosticMessage; - Strict_Type_Checking_Options: DiagnosticMessage; - Module_Resolution_Options: DiagnosticMessage; - Source_Map_Options: DiagnosticMessage; - Additional_Checks: DiagnosticMessage; - Experimental_Options: DiagnosticMessage; - Advanced_Options: DiagnosticMessage; - Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: DiagnosticMessage; - Enable_all_strict_type_checking_options: DiagnosticMessage; - List_of_language_service_plugins: DiagnosticMessage; - Scoped_package_detected_looking_in_0: DiagnosticMessage; - Reusing_resolution_of_module_0_to_file_1_from_old_program: DiagnosticMessage; - Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: DiagnosticMessage; - Disable_strict_checking_of_generic_signatures_in_function_types: DiagnosticMessage; - Enable_strict_checking_of_function_types: DiagnosticMessage; - Enable_strict_checking_of_property_initialization_in_classes: DiagnosticMessage; - Numeric_separators_are_not_allowed_here: DiagnosticMessage; - Multiple_consecutive_numeric_separators_are_not_permitted: DiagnosticMessage; - Found_package_json_at_0_Package_ID_is_1: DiagnosticMessage; - Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: DiagnosticMessage; - All_imports_in_import_declaration_are_unused: DiagnosticMessage; - Found_1_error_Watching_for_file_changes: DiagnosticMessage; - Found_0_errors_Watching_for_file_changes: DiagnosticMessage; - Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols: DiagnosticMessage; - _0_is_declared_but_never_used: DiagnosticMessage; - Include_modules_imported_with_json_extension: DiagnosticMessage; - All_destructured_elements_are_unused: DiagnosticMessage; - All_variables_are_unused: DiagnosticMessage; - Projects_to_reference: DiagnosticMessage; - Enable_project_compilation: DiagnosticMessage; - Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: DiagnosticMessage; - Composite_projects_may_not_disable_declaration_emit: DiagnosticMessage; - Output_file_0_has_not_been_built_from_source_file_1: DiagnosticMessage; - Referenced_project_0_must_have_setting_composite_Colon_true: DiagnosticMessage; - File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern: DiagnosticMessage; - Cannot_prepend_project_0_because_it_does_not_have_outFile_set: DiagnosticMessage; - Output_file_0_from_project_1_does_not_exist: DiagnosticMessage; - Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2: DiagnosticMessage; - Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2: DiagnosticMessage; - Project_0_is_out_of_date_because_output_file_1_does_not_exist: DiagnosticMessage; - Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date: DiagnosticMessage; - Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies: DiagnosticMessage; - Projects_in_this_build_Colon_0: DiagnosticMessage; - A_non_dry_build_would_delete_the_following_files_Colon_0: DiagnosticMessage; - A_non_dry_build_would_build_project_0: DiagnosticMessage; - Building_project_0: DiagnosticMessage; - Updating_output_timestamps_of_project_0: DiagnosticMessage; - delete_this_Project_0_is_up_to_date_because_it_was_previously_built: DiagnosticMessage; - Project_0_is_up_to_date: DiagnosticMessage; - Skipping_build_of_project_0_because_its_dependency_1_has_errors: DiagnosticMessage; - Project_0_can_t_be_built_because_its_dependency_1_has_errors: DiagnosticMessage; - Build_one_or_more_projects_and_their_dependencies_if_out_of_date: DiagnosticMessage; - Delete_the_outputs_of_all_projects: DiagnosticMessage; - Enable_verbose_logging: DiagnosticMessage; - Show_what_would_be_built_or_deleted_if_specified_with_clean: DiagnosticMessage; - Build_all_projects_including_those_that_appear_to_be_up_to_date: DiagnosticMessage; - Option_build_must_be_the_first_command_line_argument: DiagnosticMessage; - Options_0_and_1_cannot_be_combined: DiagnosticMessage; - Skipping_clean_because_not_all_projects_could_be_located: DiagnosticMessage; - Variable_0_implicitly_has_an_1_type: DiagnosticMessage; - Parameter_0_implicitly_has_an_1_type: DiagnosticMessage; - Member_0_implicitly_has_an_1_type: DiagnosticMessage; - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: DiagnosticMessage; - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: DiagnosticMessage; - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: DiagnosticMessage; - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: DiagnosticMessage; - Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: DiagnosticMessage; - Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: DiagnosticMessage; - Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: DiagnosticMessage; - Object_literal_s_property_0_implicitly_has_an_1_type: DiagnosticMessage; - Rest_parameter_0_implicitly_has_an_any_type: DiagnosticMessage; - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: DiagnosticMessage; - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: DiagnosticMessage; - _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: DiagnosticMessage; - 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: DiagnosticMessage; - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: DiagnosticMessage; - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: DiagnosticMessage; - Unreachable_code_detected: DiagnosticMessage; - Unused_label: DiagnosticMessage; - Fallthrough_case_in_switch: DiagnosticMessage; - Not_all_code_paths_return_a_value: DiagnosticMessage; - Binding_element_0_implicitly_has_an_1_type: DiagnosticMessage; - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: DiagnosticMessage; - Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: DiagnosticMessage; - Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: DiagnosticMessage; - Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: DiagnosticMessage; - Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0: DiagnosticMessage; - Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: DiagnosticMessage; - Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: DiagnosticMessage; - Mapped_object_type_implicitly_has_an_any_template_type: DiagnosticMessage; - If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_0: DiagnosticMessage; - You_cannot_rename_this_element: DiagnosticMessage; - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: DiagnosticMessage; - import_can_only_be_used_in_a_ts_file: DiagnosticMessage; - export_can_only_be_used_in_a_ts_file: DiagnosticMessage; - type_parameter_declarations_can_only_be_used_in_a_ts_file: DiagnosticMessage; - implements_clauses_can_only_be_used_in_a_ts_file: DiagnosticMessage; - interface_declarations_can_only_be_used_in_a_ts_file: DiagnosticMessage; - module_declarations_can_only_be_used_in_a_ts_file: DiagnosticMessage; - type_aliases_can_only_be_used_in_a_ts_file: DiagnosticMessage; - _0_can_only_be_used_in_a_ts_file: DiagnosticMessage; - types_can_only_be_used_in_a_ts_file: DiagnosticMessage; - type_arguments_can_only_be_used_in_a_ts_file: DiagnosticMessage; - parameter_modifiers_can_only_be_used_in_a_ts_file: DiagnosticMessage; - non_null_assertions_can_only_be_used_in_a_ts_file: DiagnosticMessage; - enum_declarations_can_only_be_used_in_a_ts_file: DiagnosticMessage; - type_assertion_expressions_can_only_be_used_in_a_ts_file: DiagnosticMessage; - Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: DiagnosticMessage; - Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: DiagnosticMessage; - Report_errors_in_js_files: DiagnosticMessage; - JSDoc_types_can_only_be_used_inside_documentation_comments: DiagnosticMessage; - JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: DiagnosticMessage; - JSDoc_0_is_not_attached_to_a_class: DiagnosticMessage; - JSDoc_0_1_does_not_match_the_extends_2_clause: DiagnosticMessage; - JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: DiagnosticMessage; - Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: DiagnosticMessage; - Expected_0_type_arguments_provide_these_with_an_extends_tag: DiagnosticMessage; - Expected_0_1_type_arguments_provide_these_with_an_extends_tag: DiagnosticMessage; - JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: DiagnosticMessage; - JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type: DiagnosticMessage; - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: DiagnosticMessage; - class_expressions_are_not_currently_supported: DiagnosticMessage; - Language_service_is_disabled: DiagnosticMessage; - JSX_attributes_must_only_be_assigned_a_non_empty_expression: DiagnosticMessage; - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: DiagnosticMessage; - Expected_corresponding_JSX_closing_tag_for_0: DiagnosticMessage; - JSX_attribute_expected: DiagnosticMessage; - Cannot_use_JSX_unless_the_jsx_flag_is_provided: DiagnosticMessage; - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: DiagnosticMessage; - 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: DiagnosticMessage; - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: DiagnosticMessage; - JSX_element_0_has_no_corresponding_closing_tag: DiagnosticMessage; - super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: DiagnosticMessage; - Unknown_type_acquisition_option_0: DiagnosticMessage; - super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: DiagnosticMessage; - _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: DiagnosticMessage; - Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: DiagnosticMessage; - JSX_fragment_has_no_corresponding_closing_tag: DiagnosticMessage; - Expected_corresponding_closing_tag_for_JSX_fragment: DiagnosticMessage; - JSX_fragment_is_not_supported_when_using_jsxFactory: DiagnosticMessage; - JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma: DiagnosticMessage; - Circularity_detected_while_resolving_configuration_Colon_0: DiagnosticMessage; - A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: DiagnosticMessage; - The_files_list_in_config_file_0_is_empty: DiagnosticMessage; - No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: DiagnosticMessage; - File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module: DiagnosticMessage; - This_constructor_function_may_be_converted_to_a_class_declaration: DiagnosticMessage; - Import_may_be_converted_to_a_default_import: DiagnosticMessage; - JSDoc_types_may_be_moved_to_TypeScript_types: DiagnosticMessage; - require_call_may_be_converted_to_an_import: DiagnosticMessage; - Add_missing_super_call: DiagnosticMessage; - Make_super_call_the_first_statement_in_the_constructor: DiagnosticMessage; - Change_extends_to_implements: DiagnosticMessage; - Remove_declaration_for_Colon_0: DiagnosticMessage; - Remove_import_from_0: DiagnosticMessage; - Implement_interface_0: DiagnosticMessage; - Implement_inherited_abstract_class: DiagnosticMessage; - Add_0_to_unresolved_variable: DiagnosticMessage; - Remove_destructuring: DiagnosticMessage; - Remove_variable_statement: DiagnosticMessage; - Import_0_from_module_1: DiagnosticMessage; - Change_0_to_1: DiagnosticMessage; - Add_0_to_existing_import_declaration_from_1: DiagnosticMessage; - Declare_property_0: DiagnosticMessage; - Add_index_signature_for_property_0: DiagnosticMessage; - Disable_checking_for_this_file: DiagnosticMessage; - Ignore_this_error_message: DiagnosticMessage; - Initialize_property_0_in_the_constructor: DiagnosticMessage; - Initialize_static_property_0: DiagnosticMessage; - Change_spelling_to_0: DiagnosticMessage; - Declare_method_0: DiagnosticMessage; - Declare_static_method_0: DiagnosticMessage; - Prefix_0_with_an_underscore: DiagnosticMessage; - Rewrite_as_the_indexed_access_type_0: DiagnosticMessage; - Declare_static_property_0: DiagnosticMessage; - Call_decorator_expression: DiagnosticMessage; - Add_async_modifier_to_containing_function: DiagnosticMessage; - Convert_function_to_an_ES2015_class: DiagnosticMessage; - Convert_function_0_to_class: DiagnosticMessage; - Extract_to_0_in_1: DiagnosticMessage; - Extract_function: DiagnosticMessage; - Extract_constant: DiagnosticMessage; - Extract_to_0_in_enclosing_scope: DiagnosticMessage; - Extract_to_0_in_1_scope: DiagnosticMessage; - Annotate_with_type_from_JSDoc: DiagnosticMessage; - Annotate_with_types_from_JSDoc: DiagnosticMessage; - Infer_type_of_0_from_usage: DiagnosticMessage; - Infer_parameter_types_from_usage: DiagnosticMessage; - Convert_to_default_import: DiagnosticMessage; - Install_0: DiagnosticMessage; - Replace_import_with_0: DiagnosticMessage; - Use_synthetic_default_member: DiagnosticMessage; - Convert_to_ES6_module: DiagnosticMessage; - Add_undefined_type_to_property_0: DiagnosticMessage; - Add_initializer_to_property_0: DiagnosticMessage; - Add_definite_assignment_assertion_to_property_0: DiagnosticMessage; - Add_all_missing_members: DiagnosticMessage; - Infer_all_types_from_usage: DiagnosticMessage; - Delete_all_unused_declarations: DiagnosticMessage; - Prefix_all_unused_declarations_with_where_possible: DiagnosticMessage; - Fix_all_detected_spelling_errors: DiagnosticMessage; - Add_initializers_to_all_uninitialized_properties: DiagnosticMessage; - Add_definite_assignment_assertions_to_all_uninitialized_properties: DiagnosticMessage; - Add_undefined_type_to_all_uninitialized_properties: DiagnosticMessage; - Change_all_jsdoc_style_types_to_TypeScript: DiagnosticMessage; - Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types: DiagnosticMessage; - Implement_all_unimplemented_interfaces: DiagnosticMessage; - Install_all_missing_types_packages: DiagnosticMessage; - Rewrite_all_as_indexed_access_types: DiagnosticMessage; - Convert_all_to_default_imports: DiagnosticMessage; - Make_all_super_calls_the_first_statement_in_their_constructor: DiagnosticMessage; - Add_qualifier_to_all_unresolved_variables_matching_a_member_name: DiagnosticMessage; - Change_all_extended_interfaces_to_implements: DiagnosticMessage; - Add_all_missing_super_calls: DiagnosticMessage; - Implement_all_inherited_abstract_classes: DiagnosticMessage; - Add_all_missing_async_modifiers: DiagnosticMessage; - Add_ts_ignore_to_all_error_messages: DiagnosticMessage; - Annotate_everything_with_types_from_JSDoc: DiagnosticMessage; - Add_to_all_uncalled_decorators: DiagnosticMessage; - Convert_all_constructor_functions_to_classes: DiagnosticMessage; - Generate_get_and_set_accessors: DiagnosticMessage; - Convert_require_to_import: DiagnosticMessage; - Convert_all_require_to_import: DiagnosticMessage; - Move_to_a_new_file: DiagnosticMessage; - Remove_unreachable_code: DiagnosticMessage; - Remove_all_unreachable_code: DiagnosticMessage; - Add_missing_typeof: DiagnosticMessage; - Remove_unused_label: DiagnosticMessage; - Remove_all_unused_labels: DiagnosticMessage; - Convert_0_to_mapped_object_type: DiagnosticMessage; - Convert_namespace_import_to_named_imports: DiagnosticMessage; - Convert_named_imports_to_namespace_import: DiagnosticMessage; - Add_or_remove_braces_in_an_arrow_function: DiagnosticMessage; - Add_braces_to_arrow_function: DiagnosticMessage; - Remove_braces_from_arrow_function: DiagnosticMessage; - Convert_default_export_to_named_export: DiagnosticMessage; - Convert_named_export_to_default_export: DiagnosticMessage; - }; -} declare namespace ts { type ErrorCallback = (message: DiagnosticMessage, length: number) => void; - function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean; - function tokenIsIdentifierOrKeywordOrGreaterThan(token: SyntaxKind): boolean; interface Scanner { getStartPos(): number; getToken(): SyntaxKind; @@ -5962,7 +3063,6 @@ declare namespace ts { isIdentifier(): boolean; isReservedWord(): boolean; isUnterminated(): boolean; - getTokenFlags(): TokenFlags; reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; reScanTemplateToken(): SyntaxKind; @@ -5982,25 +3082,14 @@ declare namespace ts { scanRange(start: number, length: number, callback: () => T): T; tryScan(callback: () => T): T; } - function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget | undefined): boolean; function tokenToString(t: SyntaxKind): string | undefined; - function stringToToken(s: string): SyntaxKind | undefined; - function computeLineStarts(text: string): number[]; function getPositionOfLineAndCharacter(sourceFile: SourceFileLike, line: number, character: number): number; - function computePositionOfLineAndCharacter(lineStarts: ReadonlyArray, line: number, character: number, debugText?: string): number; - function getLineStarts(sourceFile: SourceFileLike): ReadonlyArray; - /** - * We assume the first line starts at position 0 and 'position' is non-negative. - */ - function computeLineAndCharacterOfPosition(lineStarts: ReadonlyArray, position: number): LineAndCharacter; function getLineAndCharacterOfPosition(sourceFile: SourceFileLike, position: number): LineAndCharacter; function isWhiteSpaceLike(ch: number): boolean; /** Does not include line breaks. For that, see isWhiteSpaceLike. */ 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: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; @@ -6013,7 +3102,6 @@ declare namespace ts { function getShebang(text: string): string | undefined; function isIdentifierStart(ch: number, languageVersion: ScriptTarget | undefined): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined): boolean; - function isIdentifierText(name: string, languageVersion: ScriptTarget | undefined): boolean; function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, textInitial?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } /** Non-internal stuff goes here */ @@ -6021,624 +3109,6 @@ declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): T[]; } -declare namespace ts { - const emptyArray: never[]; - const resolvingEmptyArray: never[]; - const emptyMap: ReadonlyMap; - const emptyUnderscoreEscapedMap: ReadonlyUnderscoreEscapedMap; - const externalHelpersModuleNameText = "tslib"; - function getDeclarationOfKind(symbol: Symbol, kind: T["kind"]): T | undefined; - /** Create a new escaped identifier map. */ - function createUnderscoreEscapedMap(): UnderscoreEscapedMap; - function hasEntries(map: ReadonlyUnderscoreEscapedMap | undefined): map is ReadonlyUnderscoreEscapedMap; - function createSymbolTable(symbols?: ReadonlyArray): SymbolTable; - function toPath(fileName: string, basePath: string | undefined, getCanonicalFileName: (path: string) => string): Path; - function changesAffectModuleResolution(oldOptions: CompilerOptions, newOptions: CompilerOptions): boolean; - /** - * Iterates through the parent chain of a node and performs the callback on each parent until the callback - * returns a truthy value, then returns that value. - * If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit" - * At that point findAncestor returns undefined. - */ - function findAncestor(node: Node | undefined, callback: (element: Node) => element is T): T | undefined; - function findAncestor(node: Node | undefined, callback: (element: Node) => boolean | "quit"): Node | undefined; - /** - * Calls `callback` for each entry in the map, returning the first truthy result. - * Use `map.forEach` instead for normal iteration. - */ - function forEachEntry(map: ReadonlyUnderscoreEscapedMap, callback: (value: T, key: __String) => U | undefined): U | undefined; - function forEachEntry(map: ReadonlyMap, callback: (value: T, key: string) => U | undefined): U | undefined; - /** `forEachEntry` for just keys. */ - function forEachKey(map: ReadonlyUnderscoreEscapedMap<{}>, callback: (key: __String) => T | undefined): T | undefined; - function forEachKey(map: ReadonlyMap<{}>, callback: (key: string) => T | undefined): T | undefined; - /** Copy entries from `source` to `target`. */ - function copyEntries(source: ReadonlyUnderscoreEscapedMap, target: UnderscoreEscapedMap): void; - function copyEntries(source: ReadonlyMap, target: Map): void; - /** - * Creates a set from the elements of an array. - * - * @param array the array of input elements. - */ - function arrayToSet(array: ReadonlyArray): Map; - function arrayToSet(array: ReadonlyArray, makeKey: (value: T) => string | undefined): Map; - function arrayToSet(array: ReadonlyArray, makeKey: (value: T) => __String | undefined): UnderscoreEscapedMap; - function cloneMap(map: SymbolTable): SymbolTable; - function cloneMap(map: ReadonlyMap): Map; - function cloneMap(map: ReadonlyUnderscoreEscapedMap): UnderscoreEscapedMap; - function usingSingleLineStringWriter(action: (writer: EmitTextWriter) => void): string; - function getFullWidth(node: Node): number; - function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull | undefined; - 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 packageIdToString({ name, subModuleName, version }: PackageId): string; - function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean; - function hasChangesInResolutions(names: ReadonlyArray, newResolutions: ReadonlyArray, oldResolutions: ReadonlyMap | undefined, comparer: (oldResolution: T, newResolution: T) => boolean): boolean; - function containsParseError(node: Node): boolean; - function getSourceFileOfNode(node: Node): SourceFile; - function getSourceFileOfNode(node: Node | undefined): SourceFile | undefined; - function isStatementWithLocals(node: Node): boolean; - function getStartPositionOfLine(line: number, sourceFile: SourceFileLike): number; - function nodePosToString(node: Node): string; - function getEndLinePosition(line: number, sourceFile: SourceFileLike): number; - /** - * Returns a value indicating whether a name is unique globally or within the current file. - * Note: This does not consider whether a name appears as a free identifier or not, so at the expression `x.y` this includes both `x` and `y`. - */ - function isFileLevelUniqueName(sourceFile: SourceFile, name: string, hasGlobalName?: PrintHandlers["hasGlobalName"]): boolean; - function nodeIsMissing(node: Node | undefined): boolean; - function nodeIsPresent(node: Node | undefined): boolean; - /** - * Appends a range of value to begin of an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - */ - function prependStatements(to: T[], from: ReadonlyArray | undefined): T[] | undefined; - /** - * Determine if the given comment is a triple-slash - * - * @return true if the comment is a triple-slash comment else false - */ - function isRecognizedTripleSlashComment(text: string, commentPos: number, commentEnd: number): boolean; - function isPinnedComment(text: string, start: number): boolean; - function getTokenPosOfNode(node: Node, sourceFile?: SourceFileLike, includeJsDoc?: boolean): number; - function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number; - function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia?: boolean): string; - function getTextOfNodeFromSourceText(sourceText: string, node: Node, includeTrivia?: boolean): string; - function getTextOfNode(node: Node, includeTrivia?: boolean): string; - /** - * Note: it is expected that the `nodeArray` and the `node` are within the same file. - * For example, searching for a `SourceFile` in a `SourceFile[]` wouldn't work. - */ - function indexOfNode(nodeArray: ReadonlyArray, node: Node): number; - /** - * Gets flags that control emit behavior of a node. - */ - function getEmitFlags(node: Node): EmitFlags; - function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile): string; - function getTextOfConstantValue(value: string | number): string; - function escapeLeadingUnderscores(identifier: string): __String; - /** - * @deprecated Use `id.escapedText` to get the escaped text of an Identifier. - * @param identifier The identifier to escape - */ - function escapeIdentifier(identifier: string): string; - function makeIdentifierFromModuleName(moduleName: string): string; - function isBlockOrCatchScoped(declaration: Declaration): boolean; - function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration): boolean; - function isAmbientModule(node: Node): node is AmbientModuleDeclaration; - function isModuleWithStringLiteralName(node: Node): node is ModuleDeclaration; - function isNonGlobalAmbientModule(node: Node): node is ModuleDeclaration & { - name: StringLiteral; - }; - /** - * An effective module (namespace) declaration is either - * 1. An actual declaration: namespace X { ... } - * 2. A Javascript declaration, which is: - * An identifier in a nested property access expression: Y in `X.Y.Z = { ... }` - */ - function isEffectiveModuleDeclaration(node: Node): boolean; - /** Given a symbol for a module, checks that it is a shorthand ambient module. */ - function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean; - function isBlockScopedContainerTopLevel(node: Node): boolean; - function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean; - function isExternalModuleAugmentation(node: Node): node is AmbientModuleDeclaration; - function isModuleAugmentationExternal(node: AmbientModuleDeclaration): boolean; - function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions): boolean; - function isBlockScope(node: Node, parentNode: Node): boolean; - function isDeclarationWithTypeParameters(node: Node): node is DeclarationWithTypeParameters; - function isAnyImportSyntax(node: Node): node is AnyImportSyntax; - function isLateVisibilityPaintedStatement(node: Node): node is LateVisibilityPaintedStatement; - function isAnyImportOrReExport(node: Node): node is AnyImportOrReExport; - function getEnclosingBlockScopeContainer(node: Node): Node; - function declarationNameToString(name: DeclarationName | QualifiedName | undefined): string; - function getNameFromIndexInfo(info: IndexInfo): string | undefined; - 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, arg3?: string | number): DiagnosticWithLocation; - function createDiagnosticForNodeArray(sourceFile: SourceFile, nodes: NodeArray, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic; - function createDiagnosticForNodeInSourceFile(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): DiagnosticWithLocation; - function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, relatedInformation?: DiagnosticRelatedInformation[]): DiagnosticWithLocation; - function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan; - function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan; - function isExternalOrCommonJsModule(file: SourceFile): boolean; - function isJsonSourceFile(file: SourceFile): file is JsonSourceFile; - function isConstEnumDeclaration(node: Node): boolean; - function isConst(node: Node): boolean; - function isLet(node: Node): boolean; - function isSuperCall(n: Node): n is SuperCall; - function isImportCall(n: Node): n is ImportCall; - function isLiteralImportTypeNode(n: Node): n is LiteralImportTypeNode; - function isPrologueDirective(node: Node): node is PrologueDirective; - function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[] | undefined; - function getJSDocCommentRanges(node: Node, text: string): CommentRange[] | undefined; - const fullTripleSlashReferencePathRegEx: RegExp; - const fullTripleSlashAMDReferencePathRegEx: RegExp; - function isPartOfTypeNode(node: Node): boolean; - function isChildOfNodeWithKind(node: Node, kind: SyntaxKind): boolean; - function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T | undefined; - function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void; - /** - * Gets the most likely element type for a TypeNode. This is not an exhaustive test - * as it assumes a rest argument can only be an array type (either T[], or Array). - * - * @param node The type node. - */ - function getRestParameterElementType(node: TypeNode | undefined): TypeNode | undefined; - function getMembersOfDeclaration(node: Declaration): NodeArray | undefined; - function isVariableLike(node: Node): node is VariableLikeDeclaration; - function isVariableLikeOrAccessor(node: Node): node is AccessorDeclaration | VariableLikeDeclaration; - function isVariableDeclarationInVariableStatement(node: VariableDeclaration): boolean; - function isValidESSymbolDeclaration(node: Node): node is VariableDeclaration | PropertyDeclaration | SignatureDeclaration; - function introducesArgumentsExoticObject(node: Node): boolean; - function unwrapInnermostStatementOfLabel(node: LabeledStatement, beforeUnwrapLabelCallback?: (node: LabeledStatement) => void): Statement; - 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 getPropertyAssignment(objectLiteral: ObjectLiteralExpression, key: string, key2?: string): ReadonlyArray; - function getTsConfigObjectLiteralExpression(tsConfigSourceFile: TsConfigSourceFile | undefined): ObjectLiteralExpression | undefined; - function getTsConfigPropArrayElementValue(tsConfigSourceFile: TsConfigSourceFile | undefined, propKey: string, elementValue: string): StringLiteral | undefined; - function getTsConfigPropArray(tsConfigSourceFile: TsConfigSourceFile | undefined, propKey: string): ReadonlyArray; - function getContainingFunction(node: Node): SignatureDeclaration | undefined; - function getContainingClass(node: Node): ClassLikeDeclaration | undefined; - function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; - function getNewTargetContainer(node: Node): Node | undefined; - /** - * Given an super call/property node, returns the closest node where - * - a super call/property access is legal in the node and not legal in the parent node the node. - * i.e. super call is legal in constructor but not legal in the class body. - * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) - * - a super call/property is definitely illegal in the container (but might be legal in some subnode) - * i.e. super property access is illegal in function declaration but can be legal in the statement list - */ - function getSuperContainer(node: Node, stopOnFunctions: boolean): Node; - function getImmediatelyInvokedFunctionExpression(func: Node): CallExpression | undefined; - /** - * Determines whether a node is a property or element access expression for `super`. - */ - function isSuperProperty(node: Node): node is SuperProperty; - /** - * Determines whether a node is a property or element access expression for `this`. - */ - function isThisProperty(node: Node): boolean; - function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression | undefined; - function getInvokedExpression(node: CallLikeExpression): Expression; - function nodeCanBeDecorated(node: ClassDeclaration): true; - function nodeCanBeDecorated(node: ClassElement, parent: Node): boolean; - function nodeCanBeDecorated(node: Node, parent: Node, grandparent: Node): boolean; - function nodeIsDecorated(node: ClassDeclaration): boolean; - function nodeIsDecorated(node: ClassElement, parent: Node): boolean; - function nodeIsDecorated(node: Node, parent: Node, grandparent: Node): boolean; - function nodeOrChildIsDecorated(node: ClassDeclaration): boolean; - function nodeOrChildIsDecorated(node: ClassElement, parent: Node): boolean; - function nodeOrChildIsDecorated(node: Node, parent: Node, grandparent: Node): boolean; - function childIsDecorated(node: ClassDeclaration): boolean; - function childIsDecorated(node: Node, parent: Node): boolean; - function isJSXTagName(node: Node): boolean; - function isExpressionNode(node: Node): boolean; - function isInExpressionContext(node: Node): boolean; - function isExternalModuleImportEqualsDeclaration(node: Node): boolean; - function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression; - function isInternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isSourceFileJavaScript(file: SourceFile): boolean; - function isSourceFileNotJavaScript(file: SourceFile): boolean; - function isInJavaScriptFile(node: Node | undefined): boolean; - function isInJsonFile(node: Node | undefined): boolean; - function isInJSDoc(node: Node | undefined): boolean; - function isJSDocIndexSignature(node: TypeReferenceNode | ExpressionWithTypeArguments): boolean | undefined; - /** - * Returns true if the node is a CallExpression to the identifier 'require' with - * exactly one argument (of the form 'require("name")'). - * This function does not test if the node is in a JavaScript file or not. - */ - function isRequireCall(callExpression: Node, checkArgumentIsStringLiteralLike: true): callExpression is RequireOrImportCall & { - expression: Identifier; - arguments: [StringLiteralLike]; - }; - function isRequireCall(callExpression: Node, checkArgumentIsStringLiteralLike: boolean): callExpression is CallExpression; - function isSingleOrDoubleQuote(charCode: number): boolean; - function isStringDoubleQuoted(str: StringLiteralLike, sourceFile: SourceFile): boolean; - function getDeclarationOfJSInitializer(node: Node): Node | undefined; - /** Get the initializer, taking into account defaulted Javascript initializers */ - function getEffectiveInitializer(node: HasExpressionInitializer): Expression | undefined; - /** Get the declaration initializer when it is container-like (See getJavascriptInitializer). */ - function getDeclaredJavascriptInitializer(node: HasExpressionInitializer): Expression | undefined; - /** - * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getJavascriptInitializer). - * We treat the right hand side of assignments with container-like initalizers as declarations. - */ - function getAssignedJavascriptInitializer(node: Node): Expression | undefined; - /** - * Recognized Javascript container-like initializers are: - * 1. (function() {})() -- IIFEs - * 2. function() { } -- Function expressions - * 3. class { } -- Class expressions - * 4. {} -- Empty object literals - * 5. { ... } -- Non-empty object literals, when used to initialize a prototype, like `C.prototype = { m() { } }` - * - * This function returns the provided initializer, or undefined if it is not valid. - */ - function getJavascriptInitializer(initializer: Node, isPrototypeAssignment: boolean): Expression | undefined; - function isDefaultedJavascriptInitializer(node: BinaryExpression): boolean | undefined; - /** Given a Javascript initializer, return the outer name. That is, the lhs of the assignment or the declaration name. */ - function getOuterNameOfJsInitializer(node: Declaration): DeclarationName | undefined; - function getRightMostAssignedExpression(node: Expression): Expression; - function isExportsIdentifier(node: Node): boolean; - function isModuleExportsPropertyAccessExpression(node: Node): boolean; - function getSpecialPropertyAssignmentKind(expr: BinaryExpression): SpecialPropertyAssignmentKind; - function getSpecialPropertyAccessKind(lhs: PropertyAccessExpression): SpecialPropertyAssignmentKind; - function getInitializerOfBinaryExpression(expr: BinaryExpression): Expression; - function isPrototypePropertyAssignment(node: Node): boolean; - function isSpecialPropertyDeclaration(expr: PropertyAccessExpression): boolean; - function importFromModuleSpecifier(node: StringLiteralLike): AnyValidImportOrReExport; - function tryGetImportFromModuleSpecifier(node: StringLiteralLike): AnyValidImportOrReExport | undefined; - function getExternalModuleName(node: AnyImportOrReExport | ImportTypeNode): Expression | undefined; - function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport | undefined; - function isDefaultImport(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean; - function hasQuestionToken(node: Node): boolean; - function isJSDocConstructSignature(node: Node): boolean; - function isJSDocTypeAlias(node: Node): node is JSDocTypedefTag | JSDocCallbackTag; - function isTypeAlias(node: Node): node is JSDocTypedefTag | JSDocCallbackTag | TypeAliasDeclaration; - function getJSDocCommentsAndTags(hostNode: Node): ReadonlyArray; - /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ - function getParameterSymbolFromJSDoc(node: JSDocParameterTag): Symbol | undefined; - function getHostSignatureFromJSDoc(node: Node): SignatureDeclaration | undefined; - function getHostSignatureFromJSDocHost(host: HasJSDoc): SignatureDeclaration | undefined; - function getJSDocHost(node: Node): HasJSDoc; - function getTypeParameterFromJsDoc(node: TypeParameterDeclaration & { - parent: JSDocTemplateTag; - }): TypeParameterDeclaration | undefined; - function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean; - function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean; - enum AssignmentKind { - None = 0, - Definite = 1, - Compound = 2 - } - function getAssignmentTargetKind(node: Node): AssignmentKind; - function isAssignmentTarget(node: Node): boolean; - type NodeWithPossibleHoistedDeclaration = Block | VariableStatement | WithStatement | IfStatement | SwitchStatement | CaseBlock | CaseClause | DefaultClause | LabeledStatement | ForStatement | ForInStatement | ForOfStatement | DoStatement | WhileStatement | TryStatement | CatchClause; - /** - * Indicates whether a node could contain a `var` VariableDeclarationList that contributes to - * the same `var` declaration scope as the node's parent. - */ - function isNodeWithPossibleHoistedDeclaration(node: Node): node is NodeWithPossibleHoistedDeclaration; - type ValueSignatureDeclaration = FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; - function isValueSignatureDeclaration(node: Node): node is ValueSignatureDeclaration; - function walkUpParenthesizedTypes(node: Node): Node; - function walkUpParenthesizedExpressions(node: Node): Node; - function skipParentheses(node: Expression): Expression; - function skipParentheses(node: Node): Node; - function isDeleteTarget(node: Node): boolean; - function isNodeDescendantOf(node: Node, ancestor: Node): boolean; - function isDeclarationName(name: Node): boolean; - function isAnyDeclarationName(name: Node): boolean; - function isLiteralComputedPropertyDeclarationName(node: Node): boolean; - function isIdentifierName(node: Identifier): boolean; - function isAliasSymbolDeclaration(node: Node): boolean; - function exportAssignmentIsAlias(node: ExportAssignment | BinaryExpression): boolean; - function getEffectiveBaseTypeNode(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments | undefined; - function getClassExtendsHeritageElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments | undefined; - function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray | undefined; - /** Returns the node in an `extends` or `implements` clause of a class or interface. */ - function getAllSuperTypeNodes(node: Node): ReadonlyArray; - function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray | undefined; - function getHeritageClause(clauses: NodeArray | undefined, kind: SyntaxKind): HeritageClause | undefined; - function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile | undefined; - function getAncestor(node: Node | undefined, kind: SyntaxKind): Node | undefined; - function isKeyword(token: SyntaxKind): boolean; - function isContextualKeyword(token: SyntaxKind): boolean; - function isNonContextualKeyword(token: SyntaxKind): boolean; - function isStringANonContextualKeyword(name: string): boolean; - type TriviaKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; - function isTrivia(token: SyntaxKind): token is TriviaKind; - enum FunctionFlags { - Normal = 0, - Generator = 1, - Async = 2, - Invalid = 4, - AsyncGenerator = 3 - } - function getFunctionFlags(node: SignatureDeclaration | undefined): FunctionFlags; - function isAsyncFunction(node: Node): boolean; - function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral; - /** - * A declaration has a dynamic name if both of the following are true: - * 1. The declaration has a computed property name - * 2. The computed name is *not* expressed as Symbol., where name - * is a property of the Symbol constructor that denotes a built in - * Symbol. - */ - function hasDynamicName(declaration: Declaration): declaration is DynamicNamedDeclaration; - function isDynamicName(name: DeclarationName): boolean; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node: Expression): boolean; - function getPropertyNameForPropertyNameNode(name: DeclarationName): __String | undefined; - type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral; - function isPropertyNameLiteral(node: Node): node is PropertyNameLiteral; - function getTextOfIdentifierOrLiteral(node: PropertyNameLiteral): string; - function getEscapedTextOfIdentifierOrLiteral(node: PropertyNameLiteral): __String; - function getPropertyNameForKnownSymbolName(symbolName: string): __String; - function isKnownSymbol(symbol: Symbol): boolean; - /** - * Includes the word "Symbol" with unicode escapes - */ - function isESSymbolIdentifier(node: Node): boolean; - function isPushOrUnshiftIdentifier(node: Identifier): boolean; - function isParameterDeclaration(node: VariableLikeDeclaration): boolean; - function getRootDeclaration(node: Node): Node; - function nodeStartsNewLexicalEnvironment(node: Node): boolean; - function nodeIsSynthesized(range: TextRange): boolean; - function getOriginalSourceFile(sourceFile: SourceFile): SourceFile; - enum Associativity { - Left = 0, - Right = 1 - } - function getExpressionAssociativity(expression: Expression): Associativity; - function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; - function getExpressionPrecedence(expression: Expression): number; - function getOperator(expression: Expression): SyntaxKind; - function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): number; - function getBinaryOperatorPrecedence(kind: SyntaxKind): number; - function createDiagnosticCollection(): DiagnosticCollection; - /** - * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), - * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) - * Note that this doesn't actually wrap the input in double quotes. - */ - function escapeString(s: string, quoteChar?: CharacterCodes.doubleQuote | CharacterCodes.singleQuote | CharacterCodes.backtick): string; - function isIntrinsicJsxName(name: __String | string): boolean; - function escapeNonAsciiString(s: string, quoteChar?: CharacterCodes.doubleQuote | CharacterCodes.singleQuote | CharacterCodes.backtick): string; - function getIndentString(level: number): string; - function getIndentSize(): number; - function createTextWriter(newLine: string): EmitTextWriter; - function getResolvedExternalModuleName(host: EmitHost, file: SourceFile, referenceFile?: SourceFile): string; - function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string | undefined; - /** - * Resolves a local path to a path which is absolute to the base of the emit - */ - function getExternalModuleNameFromPath(host: EmitHost, fileName: string, referencePath?: string): string; - function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; - function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost): string; - interface EmitFileNames { - jsFilePath: string; - sourceMapFilePath: string | undefined; - declarationFilePath: string | undefined; - declarationMapPath: string | undefined; - bundleInfoPath: string | undefined; - } - /** - * Gets the source files that are expected to have an emit output. - * - * Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support - * transformations. - * - * @param host An EmitHost. - * @param targetSourceFile An optional target source file to emit. - */ - function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): ReadonlyArray; - /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ - function sourceFileMayBeEmitted(sourceFile: SourceFile, options: CompilerOptions, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean): boolean; - function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; - function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: ReadonlyArray): void; - function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; - function getLineOfLocalPositionFromLineMap(lineMap: ReadonlyArray, pos: number): number; - function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration | undefined; - /** Get the type annotation for the value parameter. */ - function getSetAccessorTypeAnnotationNode(accessor: SetAccessorDeclaration): TypeNode | undefined; - function getThisParameter(signature: SignatureDeclaration | JSDocSignature): ParameterDeclaration | undefined; - function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean; - function isThisIdentifier(node: Node | undefined): boolean; - function identifierIsThisKeyword(id: Identifier): boolean; - function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): AllAccessorDeclarations; - /** - * Gets the effective type annotation of a variable, parameter, or property. If the node was - * parsed in a JavaScript file, gets the type annotation from JSDoc. - */ - function getEffectiveTypeAnnotationNode(node: Node): TypeNode | undefined; - function getTypeAnnotationNode(node: Node): TypeNode | undefined; - /** - * Gets the effective return type annotation of a signature. If the node was parsed in a - * JavaScript file, gets the return type annotation from JSDoc. - */ - function getEffectiveReturnTypeNode(node: SignatureDeclaration | JSDocSignature): TypeNode | undefined; - /** - * Gets the effective type parameters. If the node was parsed in a - * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. - */ - function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; - function getJSDocTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; - /** - * Gets the effective type annotation of the value parameter of a set accessor. If the node - * was parsed in a JavaScript file, gets the type annotation from JSDoc. - */ - function getEffectiveSetAccessorTypeAnnotationNode(node: SetAccessorDeclaration): TypeNode | undefined; - function emitNewLineBeforeLeadingComments(lineMap: ReadonlyArray, writer: EmitTextWriter, node: TextRange, leadingComments: ReadonlyArray | undefined): void; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: ReadonlyArray, writer: EmitTextWriter, pos: number, leadingComments: ReadonlyArray | undefined): void; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap: ReadonlyArray, writer: EmitTextWriter, pos: number, commentPos: number): void; - function emitComments(text: string, lineMap: ReadonlyArray, writer: EmitTextWriter, comments: ReadonlyArray | undefined, leadingSeparator: boolean, trailingSeparator: boolean, newLine: string, writeComment: (text: string, lineMap: ReadonlyArray, writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void): void; - /** - * Detached comment is a comment at the top of file or function body that is separated from - * the next statement by space. - */ - function emitDetachedComments(text: string, lineMap: ReadonlyArray, writer: EmitTextWriter, writeComment: (text: string, lineMap: ReadonlyArray, writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void, node: TextRange, newLine: string, removeComments: boolean): { - nodePos: number; - detachedCommentEndPos: number; - } | undefined; - function writeCommentRange(text: string, lineMap: ReadonlyArray, writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string): void; - function hasModifiers(node: Node): boolean; - function hasModifier(node: Node, flags: ModifierFlags): boolean; - function hasStaticModifier(node: Node): boolean; - function hasReadonlyModifier(node: Node): boolean; - function getSelectedModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags; - function getModifierFlags(node: Node): ModifierFlags; - function getModifierFlagsNoCache(node: Node): ModifierFlags; - function modifierToFlag(token: SyntaxKind): ModifierFlags; - function isLogicalOperator(token: SyntaxKind): boolean; - function isAssignmentOperator(token: SyntaxKind): boolean; - /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ - 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 isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean; - function isExpressionWithTypeArgumentsInClassImplementsClause(node: Node): node is ExpressionWithTypeArguments; - function isEntityNameExpression(node: Node): node is EntityNameExpression; - function isPropertyAccessEntityNameExpression(node: Node): node is PropertyAccessEntityNameExpression; - function isPrototypeAccess(node: Node): node is PropertyAccessExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean; - function isEmptyObjectLiteral(expression: Node): boolean; - function isEmptyArrayLiteral(expression: Node): boolean; - function getLocalSymbolForExportDefault(symbol: Symbol): Symbol | undefined; - /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ - function tryExtractTypeScriptExtension(fileName: string): string | undefined; - /** - * Converts a string to a base-64 encoded ASCII string. - */ - function convertToBase64(input: string): string; - function base64encode(host: { - base64encode?(input: string): string; - } | undefined, input: string): string; - function base64decode(host: { - base64decode?(input: string): string; - } | undefined, input: string): string; - function getNewLineCharacter(options: CompilerOptions | PrinterOptions, getNewLine?: () => string): string; - function formatSyntaxKind(kind: SyntaxKind | undefined): string; - function formatModifierFlags(flags: ModifierFlags | undefined): string; - function formatTransformFlags(flags: TransformFlags | undefined): string; - function formatEmitFlags(flags: EmitFlags | undefined): string; - function formatSymbolFlags(flags: SymbolFlags | undefined): string; - function formatTypeFlags(flags: TypeFlags | undefined): string; - function formatObjectFlags(flags: ObjectFlags | undefined): string; - /** - * Creates a new TextRange from the provided pos and end. - * - * @param pos The start position. - * @param end The end position. - */ - function createRange(pos: number, end: number): TextRange; - /** - * Creates a new TextRange from a provided range with a new end position. - * - * @param range A TextRange. - * @param end The new end position. - */ - function moveRangeEnd(range: TextRange, end: number): TextRange; - /** - * Creates a new TextRange from a provided range with a new start position. - * - * @param range A TextRange. - * @param pos The new Start position. - */ - function moveRangePos(range: TextRange, pos: number): TextRange; - /** - * Moves the start position of a range past any decorators. - */ - function moveRangePastDecorators(node: Node): TextRange; - /** - * Moves the start position of a range past any decorators or modifiers. - */ - function moveRangePastModifiers(node: Node): TextRange; - /** - * Determines whether a TextRange has the same start and end positions. - * - * @param range A TextRange. - */ - function isCollapsedRange(range: TextRange): boolean; - /** - * Creates a new TextRange for a token at the provides start position. - * - * @param pos The start position. - * @param token The token. - */ - 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; - /** - * Determines whether a name was originally the declaration name of an enum or namespace - * declaration. - */ - function isDeclarationNameOfEnumOrNamespace(node: Identifier): boolean; - function getInitializedVariables(node: VariableDeclarationList): ReadonlyArray; - function isWatchSet(options: CompilerOptions): boolean | undefined; - function closeFileWatcher(watcher: FileWatcher): void; - function getCheckFlags(symbol: Symbol): CheckFlags; - function getDeclarationModifierFlagsFromSymbol(s: Symbol): ModifierFlags; - function skipAlias(symbol: Symbol, checker: TypeChecker): Symbol; - /** See comment on `declareModuleMember` in `binder.ts`. */ - function getCombinedLocalAndExportSymbolFlags(symbol: Symbol): SymbolFlags; - function isWriteOnlyAccess(node: Node): boolean; - function isWriteAccess(node: Node): boolean; - function compareDataObjects(dst: any, src: any): boolean; - /** - * clears already present map by calling onDeleteExistingValue callback before deleting that key/value - */ - function clearMap(map: Map, onDeleteValue: (valueInMap: T, key: string) => void): void; - interface MutateMapOptions { - createNewValue(key: string, valueInNewMap: U): T; - onDeleteValue(existingValue: T, key: string): void; - /** - * If present this is called with the key when there is value for that key both in new map as well as existing map provided - * Caller can then decide to update or remove this key. - * If the key is removed, caller will get callback of createNewValue for that key. - * If this callback is not provided, the value of such keys is not updated. - */ - onExistingValue?(existingValue: T, valueInNewMap: U, key: string): void; - } - /** - * Mutates the map with newMap such that keys in map will be same as newMap. - */ - function mutateMap(map: Map, newMap: ReadonlyMap, options: MutateMapOptions): void; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ - function forEachAncestorDirectory(directory: string, callback: (directory: string) => T | undefined): T | undefined; - function isAbstractConstructorType(type: Type): boolean; - function isAbstractConstructorSymbol(symbol: Symbol): boolean; - function getClassLikeDeclarationOfSymbol(symbol: Symbol): ClassLikeDeclaration | undefined; - function getObjectFlags(type: Type): ObjectFlags; - function typeHasCallOrConstructSignatures(type: Type, checker: TypeChecker): boolean; - function forSomeAncestorDirectory(directory: string, callback: (directory: string) => boolean): boolean; - function isUMDExportSymbol(symbol: Symbol | undefined): boolean | undefined; - function showModuleSpecifier({ moduleSpecifier }: ImportDeclaration): string; - function getLastChild(node: Node): Node | undefined; - /** Add a value to a set, and return true if it wasn't already present. */ - function addToSeen(seen: Map, key: string | number): boolean; - function addToSeen(seen: Map, key: string | number, value: T): boolean; - function isObjectTypeDeclaration(node: Node): node is ObjectTypeDeclaration; -} declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; function textSpanEnd(span: TextSpan): number; @@ -6653,7 +3123,6 @@ declare namespace ts { function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan | undefined; function createTextSpan(start: number, length: number): TextSpan; - function createTextRange(pos: number, end?: number): TextRange; function createTextSpanFromBounds(start: number, end: number): TextSpan; function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; function textChangeRangeIsUnchanged(range: TextChangeRange): boolean; @@ -6676,7 +3145,8 @@ declare namespace ts { function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; + function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; + function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** * Checks to see if the locale is in the appropriate format, @@ -6722,18 +3192,7 @@ declare namespace ts { function unescapeLeadingUnderscores(identifier: __String): string; function idText(identifier: Identifier): string; function symbolName(symbol: Symbol): string; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; - /** @internal */ - function isNamedDeclaration(node: Node): node is NamedDeclaration & { - name: DeclarationName; - }; function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. @@ -6781,16 +3240,21 @@ declare namespace ts { */ function getJSDocType(node: Node): TypeNode | undefined; /** - * Gets the return type node for the node if provided via JSDoc's return tag. + * Gets the return type node for the node if provided via JSDoc return tag or type tag. * * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function - * gets the type from inside the braces. + * gets the type from inside the braces, after the fat arrow, etc. */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ function getJSDocTags(node: Node): ReadonlyArray; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + /** + * Gets the effective type parameters. If the node was parsed in a + * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + */ + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; } declare namespace ts { function isNumericLiteral(node: Node): node is NumericLiteral; @@ -6817,7 +3281,6 @@ declare namespace ts { function isCallSignatureDeclaration(node: Node): node is CallSignatureDeclaration; function isConstructSignatureDeclaration(node: Node): node is ConstructSignatureDeclaration; function isIndexSignatureDeclaration(node: Node): node is IndexSignatureDeclaration; - function isGetOrSetAccessorDeclaration(node: Node): node is AccessorDeclaration; function isTypePredicateNode(node: Node): node is TypePredicateNode; function isTypeReferenceNode(node: Node): node is TypeReferenceNode; function isFunctionTypeNode(node: Node): node is FunctionTypeNode; @@ -6961,39 +3424,25 @@ declare namespace ts { function isJSDocSignature(node: Node): node is JSDocSignature; } declare namespace ts { - function isSyntaxList(n: Node): n is SyntaxList; - function isNode(node: Node): boolean; - function isNodeKind(kind: SyntaxKind): boolean; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n: Node): boolean; - function isNodeArray(array: ReadonlyArray): array is NodeArray; - function isLiteralKind(kind: SyntaxKind): boolean; function isLiteralExpression(node: Node): node is LiteralExpression; - function isTemplateLiteralKind(kind: SyntaxKind): boolean; type TemplateLiteralToken = NoSubstitutionTemplateLiteral | TemplateHead | TemplateMiddle | TemplateTail; function isTemplateLiteralToken(node: Node): node is TemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken; - function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier; - function isModifierKind(token: SyntaxKind): token is Modifier["kind"]; - function isParameterPropertyModifier(kind: SyntaxKind): boolean; - function isClassMemberModifier(idToken: SyntaxKind): boolean; function isModifier(node: Node): node is Modifier; function isEntityName(node: Node): node is EntityName; function isPropertyName(node: Node): node is PropertyName; function isBindingName(node: Node): node is BindingName; function isFunctionLike(node: Node): node is SignatureDeclaration; - function isFunctionLikeDeclaration(node: Node): node is FunctionLikeDeclaration; - function isFunctionLikeKind(kind: SyntaxKind): boolean; - function isFunctionOrModuleBlock(node: Node): boolean; function isClassElement(node: Node): node is ClassElement; function isClassLike(node: Node): node is ClassLikeDeclaration; function isAccessor(node: Node): node is AccessorDeclaration; - function isMethodOrAccessor(node: Node): node is MethodDeclaration | AccessorDeclaration; function isTypeElement(node: Node): node is TypeElement; function isClassOrTypeElement(node: Node): node is ClassElement | TypeElement; function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike; @@ -7004,405 +3453,24 @@ declare namespace ts { */ function isTypeNode(node: Node): node is TypeNode; function isFunctionOrConstructorTypeNode(node: Node): node is FunctionTypeNode | ConstructorTypeNode; - function isBindingPattern(node: Node | undefined): node is BindingPattern; - function isAssignmentPattern(node: Node): node is AssignmentPattern; - function isArrayBindingElement(node: Node): node is ArrayBindingElement; - /** - * Determines whether the BindingOrAssignmentElement is a BindingElement-like declaration - */ - function isDeclarationBindingElement(bindingElement: BindingOrAssignmentElement): bindingElement is VariableDeclaration | ParameterDeclaration | BindingElement; - /** - * Determines whether a node is a BindingOrAssignmentPattern - */ - function isBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is BindingOrAssignmentPattern; - /** - * Determines whether a node is an ObjectBindingOrAssignmentPattern - */ - function isObjectBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ObjectBindingOrAssignmentPattern; - /** - * Determines whether a node is an ArrayBindingOrAssignmentPattern - */ - function isArrayBindingOrAssignmentPattern(node: BindingOrAssignmentElementTarget): node is ArrayBindingOrAssignmentPattern; - function isPropertyAccessOrQualifiedNameOrImportTypeNode(node: Node): node is PropertyAccessExpression | QualifiedName | ImportTypeNode; function isPropertyAccessOrQualifiedName(node: Node): node is PropertyAccessExpression | QualifiedName; function isCallLikeExpression(node: Node): node is CallLikeExpression; function isCallOrNewExpression(node: Node): node is CallExpression | NewExpression; function isTemplateLiteral(node: Node): node is TemplateLiteral; - function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression; - function isUnaryExpression(node: Node): node is UnaryExpression; - function isUnaryExpressionWithWrite(expr: Node): expr is PrefixUnaryExpression | PostfixUnaryExpression; - /** - * Determines whether a node is an expression based only on its kind. - * Use `isExpressionNode` if not in transforms. - */ - 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 isIterationStatement(node: Node, lookInLabeledStatements: false): node is IterationStatement; function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement | LabeledStatement; - function isForInOrOfStatement(node: Node): node is ForInOrOfStatement; - function isConciseBody(node: Node): node is ConciseBody; - function isFunctionBody(node: Node): node is FunctionBody; - function isForInitializer(node: Node): node is ForInitializer; - function isModuleBody(node: Node): node is ModuleBody; - function isNamespaceBody(node: Node): node is NamespaceBody; - function isJSDocNamespaceBody(node: Node): node is JSDocNamespaceBody; - function isNamedImportBindings(node: Node): node is NamedImportBindings; - function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration; - function isDeclaration(node: Node): node is NamedDeclaration; - function isDeclarationStatement(node: Node): node is DeclarationStatement; - /** - * Determines whether the node is a statement that is not also a declaration - */ - function isStatementButNotDeclaration(node: Node): node is Statement; - function isStatement(node: Node): node is Statement; - function isModuleReference(node: Node): node is ModuleReference; - function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression; - function isJsxChild(node: Node): node is JsxChild; - function isJsxAttributeLike(node: Node): node is JsxAttributeLike; - function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression; function isJsxOpeningLikeElement(node: Node): node is JsxOpeningLikeElement; function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause; - /** True if node is of some JSDoc syntax kind. */ - function isJSDocNode(node: Node): boolean; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node: Node): boolean; - function isJSDocTag(node: Node): boolean; function isSetAccessor(node: Node): node is SetAccessorDeclaration; function isGetAccessor(node: Node): node is GetAccessorDeclaration; - /** True if has jsdoc nodes attached to it. */ - function hasJSDocNodes(node: Node): node is HasJSDoc; - /** True if has type node attached to it. */ - function hasType(node: Node): node is HasType; - function couldHaveType(node: Node): node is HasType; - /** True if has initializer node attached to it. */ - function hasInitializer(node: Node): node is HasInitializer; - /** True if has initializer node attached to it. */ - function hasOnlyExpressionInitializer(node: Node): node is HasExpressionInitializer; function isObjectLiteralElement(node: Node): node is ObjectLiteralElement; - function isTypeReferenceType(node: Node): node is TypeReferenceType; - function guessIndentation(lines: string[]): number | undefined; function isStringLiteralLike(node: Node): node is StringLiteralLike; } -declare namespace ts { - /** @internal */ - function isNamedImportsOrExports(node: Node): node is NamedImportsOrExports; - 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; - getSourceMapSourceConstructor(): new (fileName: string, text: string, skipTrivia?: (pos: number) => number) => SourceMapSource; - } - let objectAllocator: ObjectAllocator; - function formatStringFromArgs(text: string, args: ArrayLike, baseIndex?: number): string; - let localizedDiagnosticMessages: MapLike | undefined; - function getLocaleSpecificMessage(message: DiagnosticMessage): string; - function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number | undefined)[]): DiagnosticWithLocation; - function formatMessage(_dummy: any, message: DiagnosticMessage): string; - function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number | undefined)[]): Diagnostic; - function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic; - function chainDiagnosticMessages(details: DiagnosticMessageChain | undefined, message: DiagnosticMessage, ...args: (string | undefined)[]): DiagnosticMessageChain; - function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; - function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison; - function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; - function getEmitModuleKind(compilerOptions: { - module?: CompilerOptions["module"]; - target?: CompilerOptions["target"]; - }): ModuleKind; - function getEmitModuleResolutionKind(compilerOptions: CompilerOptions): ModuleResolutionKind; - function unreachableCodeIsError(options: CompilerOptions): boolean; - function unusedLabelIsError(options: CompilerOptions): boolean; - function getAreDeclarationMapsEnabled(options: CompilerOptions): boolean; - function getAllowSyntheticDefaultImports(compilerOptions: CompilerOptions): boolean; - function getEmitDeclarations(compilerOptions: CompilerOptions): boolean; - type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "strictPropertyInitialization" | "alwaysStrict"; - function getStrictOptionValue(compilerOptions: CompilerOptions, flag: StrictOptionName): boolean; - function hasZeroOrOneAsteriskCharacter(str: string): boolean; - /** - * Internally, we represent paths as strings with '/' as the directory separator. - * When we make system calls (eg: LanguageServiceHost.getDirectory()), - * we expect the host to correctly handle paths in our specified format. - */ - const directorySeparator = "/"; - /** - * Normalize path separators. - */ - function normalizeSlashes(path: string): string; - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * - * For example: - * ```ts - * getRootLength("a") === 0 // "" - * getRootLength("/") === 1 // "/" - * getRootLength("c:") === 2 // "c:" - * getRootLength("c:d") === 0 // "" - * getRootLength("c:/") === 3 // "c:/" - * getRootLength("c:\\") === 3 // "c:\\" - * getRootLength("//server") === 7 // "//server" - * getRootLength("//server/share") === 8 // "//server/" - * getRootLength("\\\\server") === 7 // "\\\\server" - * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" - * getRootLength("file:///path") === 8 // "file:///" - * getRootLength("file:///c:") === 10 // "file:///c:" - * getRootLength("file:///c:d") === 8 // "file:///" - * getRootLength("file:///c:/path") === 11 // "file:///c:/" - * getRootLength("file://server") === 13 // "file://server" - * getRootLength("file://server/path") === 14 // "file://server/" - * getRootLength("http://server") === 13 // "http://server" - * getRootLength("http://server/path") === 14 // "http://server/" - * ``` - */ - function getRootLength(path: string): number; - function normalizePath(path: string): string; - function normalizePathAndParts(path: string): { - path: string; - parts: string[]; - }; - /** - * Returns the path except for its basename. Semantics align with NodeJS's `path.dirname` - * except that we support URL's as well. - * - * ```ts - * getDirectoryPath("/path/to/file.ext") === "/path/to" - * getDirectoryPath("/path/to/") === "/path" - * getDirectoryPath("/") === "/" - * ``` - */ - function getDirectoryPath(path: Path): Path; - /** - * Returns the path except for its basename. Semantics align with NodeJS's `path.dirname` - * except that we support URL's as well. - * - * ```ts - * getDirectoryPath("/path/to/file.ext") === "/path/to" - * getDirectoryPath("/path/to/") === "/path" - * getDirectoryPath("/") === "/" - * ``` - */ - function getDirectoryPath(path: string): string; - function isUrl(path: string): boolean; - function pathIsRelative(path: string): boolean; - /** - * Determines whether a path is an absolute path (e.g. starts with `/`, or a dos path - * like `c:`, `c:\` or `c:/`). - */ - function isRootedDiskPath(path: string): boolean; - /** - * Determines whether a path consists only of a path root. - */ - function isDiskPathRoot(path: string): boolean; - function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string; - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is not normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getPathComponents(path: string, currentDirectory?: string): string[]; - /** - * Reduce an array of path components to a more simplified path by navigating any - * `"."` or `".."` entries in the path. - */ - function reducePathComponents(components: ReadonlyArray): string[]; - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getNormalizedPathComponents(path: string, currentDirectory: string | undefined): string[]; - function getNormalizedAbsolutePath(fileName: string, currentDirectory: string | undefined): string; - /** - * Formats a parsed path consisting of a root component (at index 0) and zero or more path - * segments (at indices > 0). - */ - function getPathFromPathComponents(pathComponents: ReadonlyArray): string; -} -declare namespace ts { - function getPathComponentsRelativeTo(from: string, to: string, stringEqualityComparer: (a: string, b: string) => boolean, getCanonicalFileName: GetCanonicalFileName): string[]; - function getRelativePathFromFile(from: string, to: string, getCanonicalFileName: GetCanonicalFileName): string; - /** - * Gets a relative path that can be used to traverse between `from` and `to`. - */ - function getRelativePathFromDirectory(from: string, to: string, ignoreCase: boolean): string; - /** - * Gets a relative path that can be used to traverse between `from` and `to`. - */ - function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileName: GetCanonicalFileName): string; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: GetCanonicalFileName, isAbsolutePathAnUrl: boolean): string; - /** - * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed - * with `./` or `../`) so as not to be confused with an unprefixed module name. - */ - function ensurePathIsNonModuleName(path: string): string; - /** - * Returns the path except for its containing directory name. - * Semantics align with NodeJS's `path.basename` except that we support URL's as well. - * - * ```ts - * getBaseFileName("/path/to/file.ext") === "file.ext" - * getBaseFileName("/path/to/") === "to" - * getBaseFileName("/") === "" - * ``` - */ - function getBaseFileName(path: string): string; - /** - * Gets the portion of a path following the last (non-terminal) separator (`/`). - * Semantics align with NodeJS's `path.basename` except that we support URL's as well. - * If the base name has any one of the provided extensions, it is removed. - * - * ```ts - * getBaseFileName("/path/to/file.ext", ".ext", true) === "file" - * getBaseFileName("/path/to/file.js", ".ext", true) === "file.js" - * ``` - */ - function getBaseFileName(path: string, extensions: string | ReadonlyArray, ignoreCase: boolean): string; - /** - * Combines paths. If a path is absolute, it replaces any previous path. - */ - function combinePaths(path: string, ...paths: (string | undefined)[]): string; - /** - * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any - * `.` and `..` path components are resolved. - */ - function resolvePath(path: string, ...paths: (string | undefined)[]): string; - /** - * Determines whether a path has a trailing separator (`/` or `\\`). - */ - function hasTrailingDirectorySeparator(path: string): boolean; - /** - * Removes a trailing directory separator from a path. - * @param path The path. - */ - function removeTrailingDirectorySeparator(path: Path): Path; - function removeTrailingDirectorySeparator(path: string): string; - /** - * Adds a trailing directory separator to a path, if it does not already have one. - * @param path The path. - */ - function ensureTrailingDirectorySeparator(path: Path): Path; - function ensureTrailingDirectorySeparator(path: string): string; - /** - * Performs a case-sensitive comparison of two paths. - */ - function comparePathsCaseSensitive(a: string, b: string): Comparison; - /** - * Performs a case-insensitive comparison of two paths. - */ - function comparePathsCaseInsensitive(a: string, b: string): Comparison; - function comparePaths(a: string, b: string, ignoreCase?: boolean): Comparison; - function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; - function containsPath(parent: string, child: string, ignoreCase?: boolean): boolean; - function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; - function tryRemoveDirectoryPrefix(path: string, dirPath: string, getCanonicalFileName: GetCanonicalFileName): string | undefined; - function hasExtension(fileName: string): boolean; - const commonPackageFolders: ReadonlyArray; - function getRegularExpressionForWildcard(specs: ReadonlyArray | undefined, basePath: string, usage: "files" | "directories" | "exclude"): string | undefined; - /** - * 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. - */ - function isImplicitGlob(lastPathComponent: string): boolean; - interface FileSystemEntries { - readonly files: ReadonlyArray; - readonly directories: ReadonlyArray; - } - interface FileMatcherPatterns { - /** One pattern for each "include" spec. */ - includeFilePatterns: ReadonlyArray | undefined; - /** One pattern matching one of any of the "include" specs. */ - includeFilePattern: string | undefined; - includeDirectoryPattern: string | undefined; - excludePattern: string | undefined; - basePaths: ReadonlyArray; - } - /** @param path directory of the tsconfig.json */ - function getFileMatcherPatterns(path: string, excludes: ReadonlyArray | undefined, includes: ReadonlyArray | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns; - function getRegexFromPattern(pattern: string, useCaseSensitiveFileNames: boolean): RegExp; - /** @param path directory of the tsconfig.json */ - function matchFiles(path: string, extensions: ReadonlyArray | undefined, excludes: ReadonlyArray | undefined, includes: ReadonlyArray | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries): string[]; - function ensureScriptKind(fileName: string, scriptKind: ScriptKind | undefined): ScriptKind; - function getScriptKindFromFileName(fileName: string): ScriptKind; - /** - * List of supported extensions in order of file resolution precedence. - */ - const supportedTypeScriptExtensions: ReadonlyArray; - /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - const supportedTypescriptExtensionsForExtractExtension: ReadonlyArray; - const supportedJavascriptExtensions: ReadonlyArray; - function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: ReadonlyArray): ReadonlyArray; - function hasJavaScriptFileExtension(fileName: string): boolean; - function hasTypeScriptFileExtension(fileName: string): boolean; - function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: ReadonlyArray): boolean; - /** - * Extension boundaries by priority. Lower numbers indicate higher priorities, and are - * aligned to the offset of the highest priority extension in the - * allSupportedExtensions array. - */ - enum ExtensionPriority { - TypeScriptFiles = 0, - DeclarationAndJavaScriptFiles = 2, - Highest = 0, - Lowest = 2 - } - function getExtensionPriority(path: string, supportedExtensions: ReadonlyArray): ExtensionPriority; - /** - * Adjusts an extension priority to be the highest priority within the same range. - */ - function adjustExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: ReadonlyArray): ExtensionPriority; - /** - * Gets the next lowest extension priority for a given priority. - */ - function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: ReadonlyArray): 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; - function changeAnyExtension(path: string, ext: string): string; - function changeAnyExtension(path: string, ext: string, extensions: string | ReadonlyArray, ignoreCase: boolean): string; - namespace Debug { - function showSymbol(symbol: Symbol): string; - function showSyntaxKind(node: Node): string; - } - function tryParsePattern(pattern: string): Pattern | undefined; - function positionIsSynthesized(pos: number): boolean; - /** True if an extension is one of the supported TypeScript extensions. */ - function extensionIsTypeScript(ext: Extension): boolean; - function resolutionExtensionIsTypeScriptOrJson(ext: Extension): boolean; - /** - * Gets the extension from a path. - * Path must have a valid extension. - */ - function extensionFromPath(path: string): Extension; - function isAnySupportedFileExtension(path: string): boolean; - function tryGetExtensionFromPath(path: string): Extension | undefined; - /** - * Gets the file extension for a path. - */ - function getAnyExtensionFromPath(path: string): string; - /** - * Gets the file extension for a path, provided it is one of the provided extensions. - */ - function getAnyExtensionFromPath(path: string, extensions: string | ReadonlyArray, ignoreCase: boolean): string; - function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean | undefined; - const emptyFileSystemEntries: FileSystemEntries; - /** - * patternStrings contains both pattern strings (containing "*") and regular strings. - * Return an exact match if possible, or a pattern match, or undefined. - * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) - */ - function matchPatternOrExact(patternStrings: ReadonlyArray, candidate: string): string | Pattern | undefined; -} declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; - function isJSDocLikeText(text: string, start: number): boolean; /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, @@ -7427,60 +3495,9 @@ declare namespace ts { function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; 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[]; - } | undefined; - function parseJSDocTypeExpressionForTests(content: string, start?: number, length?: number): { - jsDocTypeExpression: JSDocTypeExpression; - diagnostics: Diagnostic[]; - } | undefined; - interface PragmaContext { - languageVersion: ScriptTarget; - pragmas?: PragmaMap; - checkJsDirective?: CheckJsDirective; - referencedFiles: FileReference[]; - typeReferenceDirectives: FileReference[]; - libReferenceDirectives: FileReference[]; - amdDependencies: AmdDependency[]; - hasNoDefaultLib?: boolean; - moduleName?: string; - } - function processCommentPragmas(context: PragmaContext, sourceText: string): void; - type PragmaDiagnosticReporter = (pos: number, length: number, message: DiagnosticMessage) => void; - function processPragmasIntoFields(context: PragmaContext, reportDiagnostic: PragmaDiagnosticReporter): void; - /** @internal */ - function tagNamesAreEquivalent(lhs: JsxTagNameExpression, rhs: JsxTagNameExpression): boolean; } declare namespace ts { - const compileOnSaveCommandLineOption: CommandLineOption; - /** - * An array of supported "lib" reference file names used to determine the order for inclusion - * when referenced, as well as for spelling suggestions. This ensures the correct ordering for - * overload resolution when a type declared in one lib is extended by another. - */ - const libs: string[]; - /** - * A map of lib names to lib files. This map is used both for parsing the "lib" command line - * option as well as for resolving lib reference directives. - */ - const libMap: Map; - const optionDeclarations: CommandLineOption[]; - const typeAcquisitionDeclarations: CommandLineOption[]; - interface OptionNameMap { - optionNameMap: Map; - shortOptionNames: Map; - } - const defaultInitCompilerOptions: CompilerOptions; - function convertEnableAutoDiscoveryToEnable(typeAcquisition: TypeAcquisition): TypeAcquisition; - function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic; - function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Push): string | number | undefined; - function parseListTypeOption(opt: CommandLineOptionOfListType, value: string | undefined, errors: Push): (string | number)[] | undefined; function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; - /** @internal */ - function getOptionFromName(optionName: string, allowShort?: boolean): CommandLineOption | undefined; - function printVersion(): void; - function printHelp(optionsList: CommandLineOption[], syntaxPrefix?: string): void; type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics @@ -7523,49 +3540,10 @@ declare namespace ts { * @param fileName The path to the config file */ function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; - interface JsonConversionNotifier { - /** - * Notifies parent option object is being set with the optionKey and a valid optionValue - * Currently it notifies only if there is element with type object (parentOption) and - * has element's option declarations map associated with it - * @param parentOption parent option name in which the option and value are being set - * @param option option declaration which is being set with the value - * @param value value of the option - */ - onSetValidOptionKeyValueInParent(parentOption: string, option: CommandLineOption, value: CompilerOptionsValue): void; - /** - * Notify when valid root key value option is being set - * @param key option key - * @param keyNode node corresponding to node in the source file - * @param value computed value of the key - * @param ValueNode node corresponding to value in the source file - */ - onSetValidOptionKeyValueInRoot(key: string, keyNode: PropertyName, value: CompilerOptionsValue, valueNode: Expression): void; - /** - * Notify when unknown root key value option is being set - * @param key option key - * @param keyNode node corresponding to node in the source file - * @param value computed value of the key - * @param ValueNode node corresponding to value in the source file - */ - onSetUnknownOptionKeyValueInRoot(key: string, keyNode: PropertyName, value: CompilerOptionsValue, valueNode: Expression): void; - } /** * Convert the json syntax tree into the json value */ function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; - /** - * Convert the json syntax tree into the json value and report errors - * This returns the json value (apart from checking errors) only if returnValue provided is true. - * Otherwise it just checks the errors and returns undefined - */ - function convertToObjectWorker(sourceFile: JsonSourceFile, errors: Push, returnValue: boolean, knownRootOptions: CommandLineOption | undefined, jsonConversionNotifier: JsonConversionNotifier | undefined): any; - /** - * Generate tsconfig configuration when running command line "--init" - * @param options commandlineOptions to be generated into tsconfig.json - * @param fileNames array of filenames to be generated into tsconfig.json - */ - function generateTSConfig(options: CompilerOptions, fileNames: ReadonlyArray, newLine: string): string; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -7582,9 +3560,6 @@ declare namespace ts { * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; - function setConfigFileInOptions(options: CompilerOptions, configFile: TsConfigSourceFile | undefined): void; - function isErrorNoInputFiles(error: Diagnostic): boolean; - function getErrorForNoInputFiles({ includeSpecs, excludeSpecs }: ConfigFileSpecs, configFileName: string | undefined): Diagnostic; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; @@ -7593,32 +3568,8 @@ declare namespace ts { options: TypeAcquisition; errors: Diagnostic[]; }; - /** - * Gets the file names from the provided config file specs that contain, files, include, exclude and - * other properties needed to resolve the file names - * @param spec The config file specs extracted with file names to include, wildcards to include/exclude and other details - * @param basePath The base path for any relative file specifications. - * @param options Compiler options. - * @param host The host used to resolve files and directories. - * @param extraFileExtensions optionaly file extra file extension information from host - */ - function getFileNamesFromConfigSpecs(spec: ConfigFileSpecs, basePath: string, options: CompilerOptions, host: ParseConfigHost, extraFileExtensions?: ReadonlyArray): ExpandResult; - /** - * Produces a cleaned version of compiler options with personally identifiying info (aka, paths) removed. - * Also converts enum values back to strings. - */ - function convertCompilerOptionsForTelemetry(opts: CompilerOptions): CompilerOptions; } declare namespace ts { - function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; - function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; - /** Array that is only intended to be pushed to, never read. */ - interface Push { - push(value: T): void; - } - function readJson(path: string, host: { - readFile(fileName: string): string | undefined; - }): object; function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -7654,78 +3605,13 @@ declare namespace ts { set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; - function createModuleResolutionCacheWithMaps(directoryToModuleNameMap: Map>, moduleNameToDirectoryMap: Map, currentDirectory: string, getCanonicalFileName: GetCanonicalFileName): ModuleResolutionCache; function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; 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; - /** - * Expose resolution logic to allow us to use Node module resolution logic from arbitrary locations. - * No way to do this with `require()`: https://github.com/nodejs/node/issues/5963 - * Throws an error if the module can't be resolved. - */ - function resolveJavaScriptModule(moduleName: string, initialDir: string, host: ModuleResolutionHost): string; - function directoryProbablyExists(directoryName: string, host: { - directoryExists?: (directoryName: string) => boolean; - }): boolean; - function getPackageName(moduleName: string): { - packageName: string; - rest: string; - }; - function getTypesPackageName(packageName: string): string; - function getMangledNameForScopedPackage(packageName: string): string; - function getPackageNameFromAtTypesDirectory(mangledName: string): string; - function getUnmangledNameForScopedPackage(typesPackageName: string): string; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; - /** - * LSHost may load a module from a global cache of typings. - * This is the minumum code needed to expose that functionality; the rest is in LSHost. - */ - function loadModuleFromGlobalCache(moduleName: string, projectName: string | undefined, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string): ResolvedModuleWithFailedLookupLocations; -} -declare namespace ts { - enum ModuleInstanceState { - NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2 - } - function getModuleInstanceState(node: ModuleDeclaration): ModuleInstanceState; - function bindSourceFile(file: SourceFile, options: CompilerOptions): void; - function isExportsOrModuleExportsOrAlias(sourceFile: SourceFile, node: Expression): boolean; - /** - * Computes the transform flags for a node, given the transform flags of its subtree - * - * @param node The node to analyze - * @param subtreeFlags Transform flags computed for this node's subtree - */ - function computeTransformFlagsForNode(node: Node, subtreeFlags: TransformFlags): TransformFlags; - /** - * Gets the transform flags to exclude when unioning the transform flags of a subtree. - * - * NOTE: This needs to be kept up-to-date with the exclusions used in `computeTransformFlagsForNode`. - * For performance reasons, `computeTransformFlagsForNode` uses local constant values rather - * than calling this function. - */ - function getTransformFlagsSubtreeExclusions(kind: SyntaxKind): TransformFlags; -} -/** @internal */ -declare namespace ts { - function createGetSymbolWalker(getRestTypeOfSignature: (sig: Signature) => Type, getTypePredicateOfSignature: (sig: Signature) => TypePredicate | undefined, getReturnTypeOfSignature: (sig: Signature) => Type, getBaseTypes: (type: Type) => Type[], resolveStructuredTypeMembers: (type: ObjectType) => ResolvedType, getTypeOfSymbol: (sym: Symbol) => Type, getResolvedSymbol: (node: Node) => Symbol, getIndexTypeOfStructuredType: (type: Type, kind: IndexKind) => Type | undefined, getConstraintFromTypeParameter: (typeParameter: TypeParameter) => Type | undefined, getFirstIdentifier: (node: EntityNameOrEntityNameExpression) => Identifier): (accept?: (symbol: Symbol) => boolean) => SymbolWalker; -} -declare namespace ts { - function getNodeId(node: Node): number; - function getSymbolId(symbol: Symbol): number; - function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; - function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker; } declare namespace ts { - function updateNode(updated: T, original: T): T; - function createNodeArray(elements?: T[], hasTrailingComma?: boolean): MutableNodeArray; function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; - /** - * Creates a shallow, memberwise clone of a node with no source map location. - */ - function getSynthesizedClone(node: T): T; - function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier, isSingleQuote: boolean): StringLiteral; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; function createLiteral(value: number): NumericLiteral; @@ -7735,24 +3621,19 @@ declare namespace ts { function createStringLiteral(text: string): StringLiteral; function createRegularExpressionLiteral(text: string): RegularExpressionLiteral; function createIdentifier(text: string): Identifier; - function createIdentifier(text: string, typeArguments: ReadonlyArray | undefined): Identifier; function updateIdentifier(node: Identifier): Identifier; - function updateIdentifier(node: Identifier, typeArguments: NodeArray | undefined): Identifier; /** Create a unique temporary variable. */ function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; - function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes: boolean): GeneratedIdentifier; /** 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; - function createOptimisticUniqueName(text: string): GeneratedIdentifier; /** Create a unique name based on the supplied text. */ function createOptimisticUniqueName(text: string): Identifier; /** Create a unique name based on the supplied text. This does not consider names injected by the transformer. */ function createFileLevelUniqueName(text: string): Identifier; /** Create a unique name generated for a node. */ function getGeneratedNameForNode(node: Node | undefined): Identifier; - function getGeneratedNameForNode(node: Node | undefined, flags: GeneratedIdentifierFlags): Identifier; function createToken(token: TKind): Token; function createSuper(): SuperExpression; function createThis(): ThisExpression & Token; @@ -7791,7 +3672,6 @@ declare namespace ts { function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function createSignatureDeclaration(kind: SyntaxKind, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, typeArguments?: ReadonlyArray | undefined): SignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; @@ -7856,8 +3736,6 @@ declare namespace ts { function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; - /** @internal */ - function createTaggedTemplate(tag: Expression, typeArgumentsOrTemplate: ReadonlyArray | TemplateLiteral | undefined, template?: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; @@ -7867,7 +3745,7 @@ declare namespace ts { function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + /** @deprecated */ function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; @@ -7885,7 +3763,7 @@ declare namespace ts { function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): 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; + /** @deprecated */ function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; @@ -7913,13 +3791,16 @@ declare namespace ts { function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function createExpressionStatement(expression: Expression): ExpressionStatement; function updateBlock(node: Block, statements: ReadonlyArray): Block; function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; - function createStatement(expression: Expression): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createExpressionStatement(expression: Expression): ExpressionStatement; + function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + const createStatement: typeof createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + const updateStatement: typeof updateExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; @@ -8039,16 +3920,6 @@ declare namespace ts { * @param original The original statement. */ function createNotEmittedStatement(original: Node): NotEmittedStatement; - /** - * Creates a synthetic element to act as a placeholder for the end of an emitted declaration in - * order to properly emit exports. - */ - function createEndOfDeclarationMarker(original: Node): EndOfDeclarationMarker; - /** - * Creates a synthetic element to act as a placeholder for the beginning of a merged declaration in - * order to properly emit exports. - */ - function createMergeDeclarationMarker(original: Node): MergeDeclarationMarker; /** * Creates a synthetic expression to act as a placeholder for a not-emitted expression in * order to preserve comments or sourcemap positions. @@ -8091,20 +3962,11 @@ declare namespace ts { * @param sourceFile A source file. */ function disposeEmitNodes(sourceFile: SourceFile): void; - /** - * Associates a node with the current transformation, initializing - * various transient transformation properties. - */ - function getOrCreateEmitNode(node: Node): EmitNode; function setTextRange(range: T, location: TextRange | undefined): T; /** * Sets flags that control emit behavior of a node. */ function setEmitFlags(node: T, emitFlags: EmitFlags): T; - /** - * Sets flags that control emit behavior of a node. - */ - function addEmitFlags(node: T, emitFlags: EmitFlags): T; /** * Gets a custom text range to use when emitting source maps. */ @@ -8125,14 +3987,6 @@ declare namespace ts { * Sets the TextRange to use for source maps for a token of a node. */ function setTokenSourceMapRange(node: T, token: SyntaxKind, range: SourceMapRange | undefined): T; - /** - * Gets a custom text range to use when emitting comments. - */ - function getStartsOnNewLine(node: Node): boolean | undefined; - /** - * Sets a custom text range to use when emitting comments. - */ - function setStartsOnNewLine(node: T, newLine: boolean): T; /** * Gets a custom text range to use when emitting comments. */ @@ -8176,262 +4030,8 @@ declare namespace ts { * Moves matching emit helpers from a source node to a target node. */ function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; - function compareEmitHelpers(x: EmitHelper, y: EmitHelper): Comparison; function setOriginalNode(node: T, original: Node | undefined): T; } -declare namespace ts { - const nullTransformationContext: TransformationContext; - 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: ReadonlyArray, 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: ReadonlyArray): CallExpression; - function createMathPow(left: Expression, right: Expression, location?: TextRange): CallExpression; - function createExpressionForJsxElement(jsxFactoryEntity: EntityName | undefined, reactNamespace: string, tagName: Expression, props: Expression, children: ReadonlyArray, parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression; - function createExpressionForJsxFragment(jsxFactoryEntity: EntityName | undefined, reactNamespace: string, children: ReadonlyArray, parentElement: JsxOpeningFragment, location: TextRange): LeftHandSideExpression; - function getHelperName(name: string): Identifier; - function createValuesHelper(context: TransformationContext, expression: Expression, location?: TextRange): CallExpression; - function createReadHelper(context: TransformationContext, iteratorRecord: Expression, count: number | undefined, location?: TextRange): CallExpression; - function createSpreadHelper(context: TransformationContext, argumentList: ReadonlyArray, location?: TextRange): CallExpression; - function createForOfBindingStatement(node: ForInitializer, boundValue: Expression): Statement; - function insertLeadingStatement(dest: Statement, source: Statement): Block; - function restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement | undefined, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement; - interface CallBinding { - target: LeftHandSideExpression; - thisArg: Expression; - } - function createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding; - function inlineExpressions(expressions: ReadonlyArray): Expression; - function createExpressionFromEntityName(node: EntityName | Expression): Expression; - function createExpressionForPropertyName(memberName: PropertyName): Expression; - function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression | undefined; - /** - * Gets the internal name of a declaration. This is primarily used for declarations that can be - * referred to by name in the body of an ES5 class function body. An internal name will *never* - * be prefixed with an module or namespace export modifier like "exports." when emitted as an - * expression. An internal name will also *never* be renamed due to a collision with a block - * scoped variable. - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - */ - function getInternalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - /** - * Gets whether an identifier should only be referred to by its internal name. - */ - function isInternalName(node: Identifier): boolean; - /** - * Gets the local name of a declaration. This is primarily used for declarations that can be - * referred to by name in the declaration's immediate scope (classes, enums, namespaces). A - * local name will *never* be prefixed with an module or namespace export modifier like - * "exports." when emitted as an expression. - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - */ - function getLocalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - /** - * Gets whether an identifier should only be referred to by its local name. - */ - function isLocalName(node: Identifier): boolean; - /** - * Gets the export name of a declaration. This is primarily used for declarations that can be - * referred to by name in the declaration's immediate scope (classes, enums, namespaces). An - * export name will *always* be prefixed with an module or namespace export modifier like - * `"exports."` when emitted as an expression if the name points to an exported symbol. - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - */ - function getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - /** - * Gets whether an identifier should only be referred to by its export representation if the - * name points to an exported symbol. - */ - function isExportName(node: Identifier): boolean; - /** - * Gets the name of a declaration for use in declarations. - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - */ - function getDeclarationName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; - /** - * Gets the exported name of a declaration for use in expressions. - * - * An exported name will *always* be prefixed with an module or namespace export modifier like - * "exports." if the name points to an exported symbol. - * - * @param ns The namespace identifier. - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - */ - function getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression; - /** - * Gets a namespace-qualified name for use in expressions. - * - * @param ns The namespace identifier. - * @param name The name. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - */ - function getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression; - function convertToFunctionBody(node: ConciseBody, multiLine?: boolean): Block; - function convertFunctionDeclarationToExpression(node: FunctionDeclaration): FunctionExpression; - /** - * Add any necessary prologue-directives into target statement-array. - * The function needs to be called during each transformation step. - * This function needs to be called whenever we transform the statement - * list of a source file, namespace, or function-like body. - * - * @param target: result statements array - * @param source: origin statements array - * @param ensureUseStrict: boolean determining whether the function need to add prologue-directives - * @param visitor: Optional callback used to visit any custom prologue directives. - */ - function addPrologue(target: Statement[], source: ReadonlyArray, ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; - /** - * Add just the standard (string-expression) prologue-directives into target statement-array. - * The function needs to be called during each transformation step. - * This function needs to be called whenever we transform the statement - * list of a source file, namespace, or function-like body. - */ - function addStandardPrologue(target: Statement[], source: ReadonlyArray, ensureUseStrict?: boolean): number; - /** - * Add just the custom prologue-directives into target statement-array. - * The function needs to be called during each transformation step. - * This function needs to be called whenever we transform the statement - * list of a source file, namespace, or function-like body. - */ - function addCustomPrologue(target: Statement[], source: ReadonlyArray, statementOffset: number, visitor?: (node: Node) => VisitResult): number; - function addCustomPrologue(target: Statement[], source: ReadonlyArray, statementOffset: number | undefined, visitor?: (node: Node) => VisitResult): number | undefined; - function startsWithUseStrict(statements: ReadonlyArray): boolean; - /** - * Ensures "use strict" directive is added - * - * @param statements An array of statements - */ - function ensureUseStrict(statements: NodeArray): NodeArray; - /** - * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended - * order of operations. - * - * @param binaryOperator The operator for the BinaryExpression. - * @param operand The operand for the BinaryExpression. - * @param isLeftSideOfBinary A value indicating whether the operand is the left side of the - * BinaryExpression. - */ - function parenthesizeBinaryOperand(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand?: Expression): Expression; - function parenthesizeForConditionalHead(condition: Expression): Expression; - function parenthesizeSubexpressionOfConditionalExpression(e: Expression): Expression; - /** - * [Per the spec](https://tc39.github.io/ecma262/#prod-ExportDeclaration), `export default` accepts _AssigmentExpression_ but - * has a lookahead restriction for `function`, `async function`, and `class`. - * - * Basically, that means we need to parenthesize in the following cases: - * - * - BinaryExpression of CommaToken - * - CommaList (synthetic list of multiple comma expressions) - * - FunctionExpression - * - ClassExpression - */ - function parenthesizeDefaultExpression(e: Expression): Expression; - /** - * Wraps an expression in parentheses if it is needed in order to use the expression - * as the expression of a NewExpression node. - * - * @param expression The Expression node. - */ - function parenthesizeForNew(expression: Expression): LeftHandSideExpression; - /** - * Wraps an expression in parentheses if it is needed in order to use the expression for - * property or element access. - * - * @param expr The expression node. - */ - function parenthesizeForAccess(expression: Expression): LeftHandSideExpression; - function parenthesizePostfixOperand(operand: Expression): LeftHandSideExpression; - function parenthesizePrefixOperand(operand: Expression): UnaryExpression; - function parenthesizeListElements(elements: NodeArray): NodeArray; - function parenthesizeExpressionForList(expression: Expression): Expression; - function parenthesizeExpressionForExpressionStatement(expression: Expression): Expression; - function parenthesizeConditionalTypeMember(member: TypeNode): TypeNode; - function parenthesizeElementTypeMember(member: TypeNode): TypeNode; - function parenthesizeArrayTypeMember(member: TypeNode): TypeNode; - function parenthesizeElementTypeMembers(members: ReadonlyArray): NodeArray; - function parenthesizeTypeParameters(typeParameters: ReadonlyArray | undefined): MutableNodeArray | undefined; - function parenthesizeConciseBody(body: ConciseBody): ConciseBody; - enum OuterExpressionKinds { - Parentheses = 1, - Assertions = 2, - PartiallyEmittedExpressions = 4, - All = 7 - } - type OuterExpression = ParenthesizedExpression | TypeAssertion | AsExpression | NonNullExpression | PartiallyEmittedExpression; - function isOuterExpression(node: Node, kinds?: OuterExpressionKinds): node is OuterExpression; - function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; - function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node; - function skipAssertions(node: Expression): Expression; - function skipAssertions(node: Node): Node; - function recreateOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds?: OuterExpressionKinds): Expression; - function startOnNewLine(node: T): T; - function getExternalHelpersModuleName(node: SourceFile): Identifier | undefined; - function getOrCreateExternalHelpersModuleNameIfNeeded(node: SourceFile, compilerOptions: CompilerOptions, hasExportStarsToExportValues?: boolean, hasImportStarOrImportDefault?: boolean): Identifier | undefined; - /** - * Get the name of that target module from an import or export declaration - */ - function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile): Identifier | undefined; - /** - * Get the name of a target module from an import/export declaration as should be written in the emitted output. - * The emitted output name can be different from the input if: - * 1. The module has a /// - * 2. --out or --outFile is used, making the name relative to the rootDir - * 3- The containing SourceFile has an entry in renamedDependencies for the import as requested by some module loaders (e.g. System). - * Otherwise, a new StringLiteral node representing the module name will be returned. - */ - function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions): StringLiteral | undefined; - /** - * Get the name of a module as should be written in the emitted output. - * The emitted output name can be different from the input if: - * 1. The module has a /// - * 2. --out or --outFile is used, making the name relative to the rootDir - * Otherwise, a new StringLiteral node representing the module name will be returned. - */ - function tryGetModuleNameFromFile(file: SourceFile | undefined, host: EmitHost, options: CompilerOptions): StringLiteral | undefined; - /** - * Gets the initializer of an BindingOrAssignmentElement. - */ - function getInitializerOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): Expression | undefined; - /** - * Gets the name of an BindingOrAssignmentElement. - */ - function getTargetOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementTarget | undefined; - /** - * Determines whether an BindingOrAssignmentElement is a rest element. - */ - function getRestIndicatorOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementRestIndicator | undefined; - /** - * Gets the property name of a BindingOrAssignmentElement - */ - function getPropertyNameOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | undefined; - /** - * Gets the elements of a BindingOrAssignmentPattern - */ - function getElementsOfBindingOrAssignmentPattern(name: BindingOrAssignmentPattern): ReadonlyArray; - 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; -} declare namespace ts { /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. @@ -8514,413 +4114,11 @@ declare namespace ts { function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } declare namespace ts { - /** - * Similar to `reduceLeft`, performs a reduction against each child of a node. - * 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 - */ - function reduceEachChild(node: Node | undefined, initial: T, cbNode: (memo: T, node: Node) => T, cbNodeArray?: (memo: T, nodes: NodeArray) => T): T; - /** - * Merges generated lexical declarations into a new statement list. - */ - function mergeLexicalEnvironment(statements: NodeArray, declarations: ReadonlyArray | undefined): NodeArray; - /** - * Appends generated lexical declarations to an array of statements. - */ - function mergeLexicalEnvironment(statements: Statement[], declarations: ReadonlyArray | undefined): Statement[]; - /** - * Lifts a NodeArray containing only Statement nodes to a block. - * - * @param nodes The NodeArray. - */ - function liftToBlock(nodes: ReadonlyArray): Statement; - /** - * Aggregates the TransformFlags for a Node and its subtree. - */ - function aggregateTransformFlags(node: T): T; - namespace Debug { - function failBadSyntaxKind(node: Node, message?: string): never; - const assertEachNode: (nodes: Node[], test: (node: Node) => boolean, message?: string | undefined) => void; - const assertNode: (node: Node | undefined, test: ((node: Node | undefined) => boolean) | undefined, message?: string | undefined) => void; - const assertOptionalNode: (node: Node, test: (node: Node) => boolean, message?: string | undefined) => void; - const assertOptionalToken: (node: Node, kind: SyntaxKind, message?: string | undefined) => void; - const assertMissingNode: typeof noop; - /** - * Injects debug information into frequently used types. - */ - function enableDebugInfo(): void; - } -} -declare namespace ts { - interface SourceFileLikeCache { - get(path: Path): SourceFileLike | undefined; - } - function createSourceFileLikeCache(host: { - readFile?: (path: string) => string | undefined; - fileExists?: (path: string) => boolean; - }): SourceFileLikeCache; -} -declare namespace ts.sourcemaps { - interface SourceMapData { - version?: number; - file?: string; - sourceRoot?: string; - sources: string[]; - sourcesContent?: (string | null)[]; - names?: string[]; - mappings: string; - } - interface SourceMappableLocation { - fileName: string; - position: number; - } - interface SourceMapper { - getOriginalPosition(input: SourceMappableLocation): SourceMappableLocation; - getGeneratedPosition(input: SourceMappableLocation): SourceMappableLocation; - } - const identitySourceMapper: { - getOriginalPosition: typeof identity; - getGeneratedPosition: typeof identity; - }; - interface SourceMapDecodeHost { - readFile(path: string): string | undefined; - fileExists(path: string): boolean; - getCanonicalFileName(path: string): string; - log(text: string): void; - } - function decode(host: SourceMapDecodeHost, mapPath: string, map: SourceMapData, program?: Program, fallbackCache?: SourceFileLikeCache): SourceMapper; - interface MappingsDecoder extends Iterator { - readonly decodingIndex: number; - readonly error: string | undefined; - readonly lastSpan: SourceMapSpan; - } - function decodeMappings(map: SourceMapData): MappingsDecoder; - function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { - log?(s: string): void; - }): T[]; - interface RawSourceMapPosition { - emittedLine: number; - emittedColumn: number; - sourceLine: number; - sourceColumn: number; - sourceIndex: number; - nameIndex?: number; - } -} -declare namespace ts { - function getOriginalNodeId(node: Node): number; - interface ExternalModuleInfo { - externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; - externalHelpersImportDeclaration: ImportDeclaration | undefined; - exportSpecifiers: Map; - exportedBindings: Identifier[][]; - exportedNames: Identifier[] | undefined; - exportEquals: ExportAssignment | undefined; - hasExportStarsToExportValues: boolean; - } - function chainBundle(transformSourceFile: (x: SourceFile) => SourceFile): (x: SourceFile | Bundle) => SourceFile | Bundle; - function getImportNeedsImportStarHelper(node: ImportDeclaration): boolean; - function getImportNeedsImportDefaultHelper(node: ImportDeclaration): boolean; - function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo; - /** - * Used in the module transformer to check if an expression is reasonably without sideeffect, - * and thus better to copy into multiple places rather than to cache in a temporary variable - * - this is mostly subjective beyond the requirement that the expression not be sideeffecting - */ - function isSimpleCopiableExpression(expression: Expression): boolean; - /** - * @param input Template string input strings - * @param args Names which need to be made file-level unique - */ - function helperString(input: TemplateStringsArray, ...args: string[]): (uniqueName: EmitHelperUniqueNameCallback) => string; -} -declare namespace ts { - enum FlattenLevel { - All = 0, - ObjectRest = 1 - } - /** - * Flattens a DestructuringAssignment or a VariableDeclaration to an expression. - * - * @param node The node to flatten. - * @param visitor An optional visitor used to visit initializers. - * @param context The transformation context. - * @param level Indicates the extent to which flattening should occur. - * @param needsValue An optional value indicating whether the value from the right-hand-side of - * the destructuring assignment is needed as part of a larger expression. - * @param createAssignmentCallback An optional callback used to create the assignment expression. - */ - 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; - /** - * Flattens a VariableDeclaration or ParameterDeclaration to one or more variable declarations. - * - * @param node The node to flatten. - * @param visitor An optional visitor used to visit initializers. - * @param context The transformation context. - * @param boundValue The value bound to the declaration. - * @param skipInitializer A value indicating whether to ignore the initializer of `node`. - * @param hoistTempVariables Indicates whether temporary variables should not be recorded in-line. - * @param level Indicates the extent to which flattening should occur. - */ - 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 | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - function transformES2017(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; - const asyncSuperHelper: EmitHelper; - const advancedAsyncSuperHelper: EmitHelper; -} -declare namespace ts { - function transformESNext(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; - function createAssignHelper(context: TransformationContext, attributesSegments: Expression[]): CallExpression; -} -declare namespace ts { - function transformJsx(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - function transformES2016(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - function transformES2015(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - /** - * Transforms ES5 syntax into ES3 syntax. - * - * @param context Context and state information for the transformation. - */ - function transformES5(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - function transformGenerators(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - function transformModule(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - function transformSystemModule(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - function transformES2015Module(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle; -} -declare namespace ts { - type GetSymbolAccessibilityDiagnostic = (symbolAccessibilityResult: SymbolAccessibilityResult) => (SymbolAccessibilityDiagnostic | undefined); - interface SymbolAccessibilityDiagnostic { - errorNode: Node; - diagnosticMessage: DiagnosticMessage; - typeName?: DeclarationName | QualifiedName; - } - type DeclarationDiagnosticProducing = VariableDeclaration | PropertyDeclaration | PropertySignature | BindingElement | SetAccessorDeclaration | GetAccessorDeclaration | ConstructSignatureDeclaration | CallSignatureDeclaration | MethodDeclaration | MethodSignature | FunctionDeclaration | ParameterDeclaration | TypeParameterDeclaration | ExpressionWithTypeArguments | ImportEqualsDeclaration | TypeAliasDeclaration | ConstructorDeclaration | IndexSignatureDeclaration; - function canProduceDiagnostics(node: Node): node is DeclarationDiagnosticProducing; - function createGetSymbolAccessibilityDiagnosticForNodeName(node: DeclarationDiagnosticProducing): (symbolAccessibilityResult: SymbolAccessibilityResult) => SymbolAccessibilityDiagnostic | undefined; - function createGetSymbolAccessibilityDiagnosticForNode(node: DeclarationDiagnosticProducing): (symbolAccessibilityResult: SymbolAccessibilityResult) => SymbolAccessibilityDiagnostic | undefined; -} -declare namespace ts { - function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, file: SourceFile | undefined): DiagnosticWithLocation[] | undefined; - /** - * Transforms a ts file into a .d.ts file - * This process requires type information, which is retrieved through the emit resolver. Because of this, - * in many places this transformer assumes it will be operating on parse tree nodes directly. - * This means that _no transforms should be allowed to occur before this one_. - */ - function transformDeclarations(context: TransformationContext): { - (node: Bundle): Bundle; - (node: SourceFile): SourceFile; - (node: SourceFile | Bundle): SourceFile | Bundle; - }; -} -declare namespace ts { - function getTransformers(compilerOptions: CompilerOptions, customTransformers?: CustomTransformers): TransformerFactory[]; - /** - * 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 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. - */ - function transformNodes(resolver: EmitResolver | undefined, host: EmitHost | undefined, options: CompilerOptions, nodes: ReadonlyArray, transformers: ReadonlyArray>, allowDtsFiles: boolean): TransformationResult; -} -declare namespace ts { - interface SourceMapWriter { - /** - * Initialize the SourceMapWriter for a new output file. - * - * @param filePath The path to the generated output file. - * @param sourceMapFilePath The path to the output source map file. - * @param sourceFileOrBundle The input source file or bundle for the program. - */ - initialize(filePath: string, sourceMapFilePath: string | undefined, sourceFileOrBundle: SourceFile | Bundle, sourceMapOutput?: SourceMapData[]): void; - /** - * Reset the SourceMapWriter to an empty state. - */ - reset(): void; - /** - * Set the current source file. - * - * @param sourceFile The source file. - */ - setSourceFile(sourceFile: SourceMapSource): void; - /** - * Emits a mapping. - * - * If the position is synthetic (undefined or a negative value), no mapping will be - * created. - * - * @param pos The position. - */ - emitPos(pos: number): void; - /** - * Emits a node with possible leading and trailing source maps. - * - * @param hint The current emit context - * @param node The node to emit. - * @param emitCallback The callback used to emit the node. - */ - 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. - * - * @param node The node containing the token. - * @param token The token to emit. - * @param tokenStartPos The start pos of the token. - * @param emitCallback The callback used to emit the token. - */ - emitTokenWithSourceMap(node: Node, token: SyntaxKind, writer: (s: string) => void, tokenStartPos: number, emitCallback: (token: SyntaxKind, writer: (s: string) => void, tokenStartPos: number) => number): number; - /** - * Gets the text for the source map. - */ - getText(): string; - /** - * Gets the SourceMappingURL for the source map. - */ - getSourceMappingURL(): string; - } - interface SourceMapOptions { - sourceMap?: boolean; - inlineSourceMap?: boolean; - inlineSources?: boolean; - sourceRoot?: string; - mapRoot?: string; - extendedDiagnostics?: boolean; - } - function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter, compilerOptions?: SourceMapOptions): SourceMapWriter; -} -declare namespace ts { - interface CommentWriter { - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - setWriter(writer: EmitTextWriter | undefined): void; - emitNodeWithComments(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node) => void): void; - emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void; - emitTrailingCommentsOfPosition(pos: number, prefixSpace?: boolean): void; - emitLeadingCommentsOfPosition(pos: number): void; - } - function createCommentWriter(printerOptions: PrinterOptions, emitPos: ((pos: number) => void) | undefined): CommentWriter; -} -declare namespace ts { - /** - * Iterates over the source files that are expected to have an emit output. - * - * @param host An EmitHost. - * @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 forEachEmittedFile(host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) => T, sourceFilesOrTargetSourceFile?: ReadonlyArray | SourceFile, emitOnlyDtsFiles?: boolean): T | undefined; - function getOutputPathsFor(sourceFile: SourceFile | Bundle, host: EmitHost, forceDtsPaths: boolean): EmitFileNames; - function getOutputExtension(sourceFile: SourceFile, options: CompilerOptions): Extension; - function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean, transformers?: TransformerFactory[], declarationTransformers?: TransformerFactory[]): EmitResult; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } -declare namespace ts { - /** - * Partial interface of the System thats needed to support the caching of directory structure - */ - interface DirectoryStructureHost { - fileExists(path: string): boolean; - readFile(path: string, encoding?: string): string | undefined; - directoryExists?(path: string): boolean; - getDirectories?(path: string): string[]; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; - createDirectory?(path: string): void; - writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void; - } - interface FileAndDirectoryExistence { - fileExists: boolean; - directoryExists: boolean; - } - interface CachedDirectoryStructureHost extends DirectoryStructureHost { - useCaseSensitiveFileNames: boolean; - getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; - /** Returns the queried result for the file exists and directory exists if at all it was done */ - addOrDeleteFileOrDirectory(fileOrDirectory: string, fileOrDirectoryPath: Path): FileAndDirectoryExistence | undefined; - addOrDeleteFile(fileName: string, filePath: Path, eventKind: FileWatcherEventKind): void; - clearCache(): void; - } - function createCachedDirectoryStructureHost(host: DirectoryStructureHost, currentDirectory: string, useCaseSensitiveFileNames: boolean): CachedDirectoryStructureHost | undefined; - enum ConfigFileProgramReloadLevel { - None = 0, - /** Update the file name list from the disk */ - Partial = 1, - /** Reload completely by re-reading contents of config file from disk and updating program */ - Full = 2 - } - /** - * Updates the existing missing file watches with the new set of missing files after new program is created - */ - function updateMissingFilePathsWatch(program: Program, missingFileWatches: Map, createMissingFileWatch: (missingFilePath: Path) => FileWatcher): void; - interface WildcardDirectoryWatcher { - watcher: FileWatcher; - flags: WatchDirectoryFlags; - } - /** - * Updates the existing wild card directory watches with the new set of wild card directories from the config file - * after new program is created because the config file was reloaded or program was created first time from the config file - * Note that there is no need to call this function when the program is updated with additional files without reloading config files, - * as wildcard directories wont change unless reloading config file - */ - function updateWatchingWildcardDirectories(existingWatchedForWildcards: Map, wildcardDirectories: Map, watchDirectory: (directory: string, flags: WatchDirectoryFlags) => FileWatcher): void; - function isEmittedFileOfProgram(program: Program | undefined, file: string): boolean; - enum WatchLogLevel { - None = 0, - TriggerOnly = 1, - Verbose = 2 - } - interface WatchFileHost { - watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; - } - interface WatchDirectoryHost { - watchDirectory(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; - } - type WatchFile = (host: WatchFileHost, file: string, callback: FileWatcherCallback, pollingInterval: PollingInterval, detailInfo1?: X, detailInfo2?: Y) => FileWatcher; - type FilePathWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, filePath: Path) => void; - type WatchFilePath = (host: WatchFileHost, file: string, callback: FilePathWatcherCallback, pollingInterval: PollingInterval, path: Path, detailInfo1?: X, detailInfo2?: Y) => FileWatcher; - type WatchDirectory = (host: WatchDirectoryHost, directory: string, callback: DirectoryWatcherCallback, flags: WatchDirectoryFlags, detailInfo1?: X, detailInfo2?: Y) => FileWatcher; - interface WatchFactory { - watchFile: WatchFile; - watchFilePath: WatchFilePath; - watchDirectory: WatchDirectory; - } - function getWatchFactory(watchLogLevel: WatchLogLevel, log: (s: string) => void, getDetailWatchInfo?: GetDetailWatchInfo): WatchFactory; - type GetDetailWatchInfo = (detailInfo1: X, detailInfo2: Y | undefined) => string; - function closeFileWatcherOf(objWithWatcher: T): void; -} declare namespace ts { function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: GetCanonicalFileName): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; interface FormatDiagnosticsHost { @@ -8930,22 +4128,8 @@ declare namespace ts { } function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - /** @internal */ - enum ForegroundColorEscapeSequences { - Grey = "\u001B[90m", - Red = "\u001B[91m", - Yellow = "\u001B[93m", - Blue = "\u001B[94m", - Cyan = "\u001B[96m" - } - /** @internal */ - function formatColorAndReset(text: string, formatStyle: string): string; function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain | undefined, newLine: string): string; - /** - * Determines if program structure is upto date or needs to be recreated - */ - function isProgramUptoDate(program: Program | undefined, rootFileNames: string[], newOptions: CompilerOptions, getSourceVersion: (path: Path) => string | undefined, fileExists: (fileName: string) => boolean, hasInvalidatedResolution: HasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames: boolean): boolean; function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' @@ -8973,17 +4157,14 @@ declare namespace ts { * @returns A 'Program' object. */ function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; - function parseConfigHostFromCompilerHost(host: CompilerHost): ParseConfigFileHost; - /** - * Returns the target config filename of a project reference - */ - function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName; + interface ResolveProjectReferencePathHost { + fileExists(fileName: string): boolean; + } /** - * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. - * The DiagnosticMessage's parameters are the imported module name, and the filename it resolved to. - * This returns a diagnostic even if the module will be an untyped module. + * Returns the target config filename of a project reference. + * Note: The file might not exist. */ - function getResolutionDiagnostic(options: CompilerOptions, { extension }: ResolvedModuleFull): DiagnosticMessage | undefined; + function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; } declare namespace ts { interface EmitOutput { @@ -8996,126 +4177,6 @@ declare namespace ts { text: string; } } -declare namespace ts { - function getFileEmitOutput(program: Program, sourceFile: SourceFile, emitOnlyDtsFiles: boolean, cancellationToken?: CancellationToken, customTransformers?: CustomTransformers): EmitOutput; - interface BuilderState { - /** - * Information of the file eg. its version, signature etc - */ - fileInfos: Map; - /** - * Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled - * Otherwise undefined - * Thus non undefined value indicates, module emit - */ - readonly referencedMap: ReadonlyMap | undefined; - /** - * Map of files that have already called update signature. - * That means hence forth these files are assumed to have - * no change in their signature for this version of the program - */ - hasCalledUpdateShapeSignature: Map; - /** - * Cache of all files excluding default library file for the current program - */ - allFilesExcludingDefaultLibraryFile: ReadonlyArray | undefined; - /** - * Cache of all the file names - */ - allFileNames: ReadonlyArray | undefined; - } -} -declare namespace ts.BuilderState { - /** - * Information about the source file: Its version and optional signature from last emit - */ - interface FileInfo { - readonly version: string; - signature: string | undefined; - } - /** - * Referenced files with values for the keys as referenced file's path to be true - */ - type ReferencedSet = ReadonlyMap; - /** - * Compute the hash to store the shape of the file - */ - type ComputeHash = (data: string) => string; - /** - * Returns true if oldState is reusable, that is the emitKind = module/non module has not changed - */ - function canReuseOldState(newReferencedMap: ReadonlyMap | undefined, oldState: Readonly | undefined): boolean | undefined; - /** - * Creates the state of file references and signature for the new program from oldState if it is safe - */ - function create(newProgram: Program, getCanonicalFileName: GetCanonicalFileName, oldState?: Readonly): BuilderState; - /** - * Gets the files affected by the path from the program - */ - function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: Map): ReadonlyArray; - /** - * Updates the signatures from the cache into state's fileinfo signatures - * This should be called whenever it is safe to commit the state of the builder - */ - function updateSignaturesFromCache(state: BuilderState, signatureCache: Map): void; - /** - * Get all the dependencies of the sourceFile - */ - function getAllDependencies(state: BuilderState, programOfThisState: Program, sourceFile: SourceFile): ReadonlyArray; -} -declare namespace ts { - /** - * State to store the changed files, affected files and cache semantic diagnostics - */ - interface BuilderProgramState extends BuilderState { - /** - * Cache of semantic diagnostics for files with their Path being the key - */ - semanticDiagnosticsPerFile: Map> | undefined; - /** - * The map has key by source file's path that has been changed - */ - changedFilesSet: Map; - /** - * Set of affected files being iterated - */ - affectedFiles: ReadonlyArray | undefined; - /** - * Current index to retrieve affected file from - */ - affectedFilesIndex: number | undefined; - /** - * Current changed file for iterating over affected files - */ - currentChangedFilePath: Path | undefined; - /** - * Map of file signatures, with key being file path, calculated while getting current changed file's affected files - * These will be commited whenever the iteration through affected files of current changed file is complete - */ - currentAffectedFilesSignatures: Map | undefined; - /** - * Already seen affected files - */ - seenAffectedFiles: Map | undefined; - /** - * program corresponding to this state - */ - program: Program; - } - enum BuilderProgramKind { - SemanticDiagnosticsBuilderProgram = 0, - EmitAndSemanticDiagnosticsBuilderProgram = 1 - } - interface BuilderCreationParameters { - newProgram: Program; - host: BuilderProgramHost; - oldProgram: BuilderProgram | undefined; - configFileParsingDiagnostics: ReadonlyArray; - } - function getBuilderCreationParameters(newProgramOrRootNames: Program | ReadonlyArray | undefined, hostOrOptions: BuilderProgramHost | CompilerOptions | undefined, oldProgramOrHost?: BuilderProgram | CompilerHost, configFileParsingDiagnosticsOrOldProgram?: ReadonlyArray | BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderCreationParameters; - function createBuilderProgram(kind: BuilderProgramKind.SemanticDiagnosticsBuilderProgram, builderCreationParameters: BuilderCreationParameters): SemanticDiagnosticsBuilderProgram; - function createBuilderProgram(kind: BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, builderCreationParameters: BuilderCreationParameters): EmitAndSemanticDiagnosticsBuilderProgram; -} declare namespace ts { type AffectedFileResult = { result: T; @@ -9140,7 +4201,6 @@ declare namespace ts { * Builder to manage the program state changes */ interface BuilderProgram { - getState(): BuilderProgramState; /** * Returns current program */ @@ -9242,99 +4302,6 @@ declare namespace ts { function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; } -declare namespace ts { - /** This is the cache of module/typedirectives resolution that can be retained across program */ - interface ResolutionCache { - startRecordingFilesWithChangedResolutions(): void; - finishRecordingFilesWithChangedResolutions(): Path[] | undefined; - resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined): ResolvedModuleFull[]; - getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): CachedResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - invalidateResolutionOfFile(filePath: Path): void; - removeResolutionsOfFile(filePath: Path): void; - setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: Map>): void; - createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution; - startCachingPerDirectoryResolution(): void; - finishCachingPerDirectoryResolution(): void; - updateTypeRootsWatch(): void; - closeTypeRootsWatch(): void; - clear(): void; - } - interface ResolutionWithFailedLookupLocations { - readonly failedLookupLocations: ReadonlyArray; - isInvalidated?: boolean; - refCount?: number; - } - interface CachedResolvedModuleWithFailedLookupLocations extends ResolvedModuleWithFailedLookupLocations, ResolutionWithFailedLookupLocations { - } - interface ResolutionCacheHost extends ModuleResolutionHost { - toPath(fileName: string): Path; - getCanonicalFileName: GetCanonicalFileName; - getCompilationSettings(): CompilerOptions; - watchDirectoryOfFailedLookupLocation(directory: string, cb: DirectoryWatcherCallback, flags: WatchDirectoryFlags): FileWatcher; - onInvalidatedResolution(): void; - watchTypeRootsDirectory(directory: string, cb: DirectoryWatcherCallback, flags: WatchDirectoryFlags): FileWatcher; - onChangedAutomaticTypeDirectiveNames(): void; - getCachedDirectoryStructureHost(): CachedDirectoryStructureHost | undefined; - projectName?: string; - getGlobalCache?(): string | undefined; - writeLog(s: string): void; - maxNumberOfFilesToIterateForInvalidation?: number; - getCurrentProgram(): Program; - } - const maxNumberOfFilesToIterateForInvalidation = 256; - function createResolutionCache(resolutionHost: ResolutionCacheHost, rootDirForResolution: string | undefined, logChangesWhenResolvingModule: boolean): ResolutionCache; -} -declare namespace ts.moduleSpecifiers { - interface ModuleSpecifierPreferences { - readonly importModuleSpecifierPreference?: "relative" | "non-relative"; - } - function getModuleSpecifier(compilerOptions: CompilerOptions, importingSourceFile: SourceFile, importingSourceFileName: string, toFileName: string, host: ModuleSpecifierResolutionHost, files: ReadonlyArray, preferences?: ModuleSpecifierPreferences): string; - function getModuleSpecifiers(moduleSymbol: Symbol, compilerOptions: CompilerOptions, importingSourceFile: SourceFile, host: ModuleSpecifierResolutionHost, files: ReadonlyArray, preferences: ModuleSpecifierPreferences): ReadonlyArray>; -} -declare namespace ts { - /** - * Create a function that reports error by writing to the system and handles the formating of the diagnostic - */ - function createDiagnosticReporter(system: System, pretty?: boolean): DiagnosticReporter; - /** @internal */ - const nonClearingMessageCodes: number[]; - /** @internal */ - const screenStartingMessageCodes: number[]; - /** - * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic - */ - function createWatchStatusReporter(system: System, pretty?: boolean): WatchStatusReporter; - /** Parses config file using System interface */ - function parseConfigFileWithSystem(configFileName: string, optionsToExtend: CompilerOptions, system: System, reportDiagnostic: DiagnosticReporter): ParsedCommandLine | undefined; - /** - * Program structure needed to emit the files and report diagnostics - */ - interface ProgramToEmitFilesAndReportErrors { - getCurrentDirectory(): string; - getCompilerOptions(): CompilerOptions; - getSourceFiles(): ReadonlyArray; - getSyntacticDiagnostics(): ReadonlyArray; - getOptionsDiagnostics(): ReadonlyArray; - getGlobalDiagnostics(): ReadonlyArray; - getSemanticDiagnostics(): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - emit(): EmitResult; - } - type ReportEmitErrorSummary = (errorCount: number) => void; - /** - * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options - */ - function emitFilesAndReportErrors(program: ProgramToEmitFilesAndReportErrors, reportDiagnostic: DiagnosticReporter, writeFileName?: (s: string) => void, reportSummary?: ReportEmitErrorSummary): ExitStatus; - /** - * Creates the watch compiler host from system for config file in watch mode - */ - function createWatchCompilerHostOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - /** - * Creates the watch compiler host from system for compiling root files and options in watch mode - */ - function createWatchCompilerHostOfFilesAndCompilerOptions(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfFilesAndCompilerOptions; -} declare namespace ts { type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ @@ -9348,7 +4315,6 @@ declare namespace ts { afterProgramCreate?(program: T): void; /** If provided, called with Diagnostic message that informs about change in watch status */ onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; - maxNumberOfFilesToIterateForInvalidation?: number; useCaseSensitiveFileNames(): boolean; getNewLine(): string; getCurrentDirectory(): string; @@ -9390,12 +4356,6 @@ declare namespace ts { /** If provided, will be used to reset existing delayed compilation */ clearTimeout?(timeoutId: any): void; } - /** Internal interface used to wire emit through same host */ - interface WatchCompilerHost { - createDirectory?(path: string): void; - writeFile?(path: string, data: string, writeByteOrderMark?: boolean): void; - onCachedDirectoryStructureHostCreate?(host: CachedDirectoryStructureHost): void; - } /** * Host to create watch with root files and options */ @@ -9419,18 +4379,9 @@ declare namespace ts { */ readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; } - /** - * Host to create watch with config file that is already parsed (from tsc) - */ - interface WatchCompilerHostOfConfigFile extends WatchCompilerHost { - optionsToExtend?: CompilerOptions; - configFileParsingResult?: ParsedCommandLine; - } interface Watch { /** Synchronize with host and get updated program */ getProgram(): T; - /** Gets the existing program without synchronizing with changes on host */ - getCurrentProgram(): T; } /** * Creates the watch what generates program using the config file @@ -9543,12 +4494,12 @@ declare namespace ts { */ interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** * One or more of the outputs of the project does not exist. @@ -9632,31 +4583,6 @@ declare namespace ts { function getAllProjectOutputs(project: ParsedCommandLine): ReadonlyArray; function formatUpToDateStatus(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T): T | undefined; } -//# sourceMappingURL=compiler.d.ts.map -declare namespace ts.server { - const ActionSet: ActionSet; - const ActionInvalidate: ActionInvalidate; - const ActionPackageInstalled: ActionPackageInstalled; - const EventTypesRegistry: EventTypesRegistry; - const EventBeginInstallTypes: EventBeginInstallTypes; - const EventEndInstallTypes: EventEndInstallTypes; - const EventInitializationFailed: EventInitializationFailed; - namespace Arguments { - const GlobalCacheLocation = "--globalTypingsCacheLocation"; - const LogFile = "--logFile"; - const EnableTelemetry = "--enableTelemetry"; - const TypingSafeListLocation = "--typingSafeListLocation"; - const TypesMapLocation = "--typesMapLocation"; - /** - * This argument specifies the location of the NPM executable. - * typingsInstaller will run the command with `${npmLocation} install ...`. - */ - const NpmLocation = "--npmLocation"; - } - function hasArgument(argumentName: string): boolean; - function findArgument(argumentName: string): string | undefined; - function nowString(): string; -} declare namespace ts.server { type ActionSet = "action::set"; type ActionInvalidate = "action::invalidate"; @@ -9674,7 +4600,6 @@ declare namespace ts.server { interface TypingInstallerRequestWithProjectName { readonly projectName: string; } - type TypingInstallerRequestUnion = DiscoverTypings | CloseProject | TypesRegistryRequest | InstallPackageRequest; interface DiscoverTypings extends TypingInstallerRequestWithProjectName { readonly fileNames: string[]; readonly projectRootPath: Path; @@ -9696,10 +4621,6 @@ declare namespace ts.server { readonly packageName: string; readonly projectRootPath: Path; } - interface TypesRegistryResponse extends TypingInstallerResponse { - readonly kind: EventTypesRegistry; - readonly typesRegistry: MapLike>; - } interface PackageInstalledResponse extends ProjectResponse { readonly kind: ActionPackageInstalled; readonly success: boolean; @@ -9728,13 +4649,6 @@ declare namespace ts.server { readonly kind: EventEndInstallTypes; readonly installSuccess: boolean; } - interface InstallTypingHost extends JsTyping.TypingResolutionHost { - useCaseSensitiveFileNames: boolean; - writeFile(path: string, content: string): void; - createDirectory(path: string): void; - watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; - watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; - } interface SetTypings extends ProjectResponse { readonly typeAcquisition: TypeAcquisition; readonly compilerOptions: CompilerOptions; @@ -9742,86 +4656,14 @@ declare namespace ts.server { readonly unresolvedImports: SortedReadonlyArray; readonly kind: ActionSet; } - type TypingInstallerResponseUnion = SetTypings | InvalidateCachedTypings | TypesRegistryResponse | PackageInstalledResponse | InstallTypes | InitializationFailedResponse; -} -declare namespace ts.JsTyping { - interface TypingResolutionHost { - directoryExists(path: string): boolean; - fileExists(fileName: string): boolean; - readFile(path: string, encoding?: string): string | undefined; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray | undefined, depth?: number): string[]; - } - interface CachedTyping { - typingLocation: string; - version: Semver; - } - function isTypingUpToDate(cachedTyping: CachedTyping, availableTypingVersions: MapLike): boolean; - const nodeCoreModuleList: ReadonlyArray; - const nodeCoreModules: Map; - /** - * A map of loose file names to library names that we are confident require typings - */ - type SafeList = ReadonlyMap; - function loadSafeList(host: TypingResolutionHost, safeListPath: Path): SafeList; - function loadTypesMap(host: TypingResolutionHost, typesMapPath: Path): SafeList | undefined; - /** - * @param host is the object providing I/O related operations. - * @param fileNames are the file names that belong to the same project - * @param projectRootPath is the path to the project root directory - * @param safeListPath is the path used to retrieve the safe list - * @param packageNameToTypingLocation is the map of package names to their cached typing locations and installed versions - * @param typeAcquisition is used to customize the typing acquisition process - * @param compilerOptions are used as a source for typing inference - */ - function discoverTypings(host: TypingResolutionHost, log: ((message: string) => void) | undefined, fileNames: string[], projectRootPath: Path, safeList: SafeList, packageNameToTypingLocation: ReadonlyMap, typeAcquisition: TypeAcquisition, unresolvedImports: ReadonlyArray, typesRegistry: ReadonlyMap>): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; - enum PackageNameValidationResult { - Ok = 0, - ScopedPackagesNotSupported = 1, - EmptyName = 2, - NameTooLong = 3, - NameStartsWithDot = 4, - NameStartsWithUnderscore = 5, - NameContainsNonURISafeCharacters = 6 - } - /** - * Validates package name using rules defined at https://docs.npmjs.com/files/package.json - */ - function validatePackageName(packageName: string): PackageNameValidationResult; - function renderPackageNameValidationFailure(result: PackageNameValidationResult, typing: string): string; -} -declare namespace ts { - class Semver { - readonly major: number; - readonly minor: number; - readonly patch: number; - /** - * If true, this is `major.minor.0-next.patch`. - * If false, this is `major.minor.patch`. - */ - readonly isPrerelease: boolean; - static parse(semver: string): Semver; - static fromRaw({ major, minor, patch, isPrerelease }: Semver): Semver; - private static tryParse; - private constructor(); - readonly versionString: string; - equals(sem: Semver): boolean; - greaterThan(sem: Semver): boolean; - } } -//# sourceMappingURL=jsTyping.d.ts.map declare namespace ts { interface Node { getSourceFile(): SourceFile; getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; - getChildren(sourceFile?: SourceFileLike): Node[]; getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; - getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; getWidth(sourceFile?: SourceFileLike): number; @@ -9878,20 +4720,14 @@ declare namespace ts { getJsDocTags(): JSDocTagInfo[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot | undefined; - nameTable: UnderscoreEscapedMap | undefined; - getNamedDeclarations(): Map; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; getLineStarts(): ReadonlyArray; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; - sourceMapper?: sourcemaps.SourceMapper; } interface SourceFileLike { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; - sourceMapper?: sourcemaps.SourceMapper; } interface SourceMapSource { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; @@ -9960,8 +4796,6 @@ declare namespace ts { resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - hasInvalidatedResolution?: HasInvalidatedResolution; - hasChangedAutomaticTypeDirectiveNames?: boolean; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -9978,7 +4812,6 @@ declare namespace ts { readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; } - const defaultPreferences: UserPreferences; interface LanguageService { cleanupSemanticCache(): void; getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; @@ -10002,7 +4835,7 @@ declare namespace ts { getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; @@ -10050,7 +4883,6 @@ declare namespace ts { getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program | undefined; - getNonBoundSourceFile(fileName: string): SourceFile; dispose(): void; } interface JsxClosingTagInfo { @@ -10063,13 +4895,54 @@ declare namespace ts { type OrganizeImportsScope = CombinedCodeFixScope; type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } interface ApplyCodeActionCommandResult { successMessage: string; } @@ -10161,9 +5034,6 @@ declare namespace ts { } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { - file: string; - type: "install package"; - packageName: string; } /** * A set of one or more available refactoring actions, grouped under a parent refactoring. @@ -10260,7 +5130,7 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; @@ -10675,273 +5545,8 @@ declare namespace ts { jsxAttributeStringLiteralValue = 24 } } -interface PromiseConstructor { - new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; - reject(reason: any): Promise; - all(values: (T | PromiseLike)[]): Promise; -} -declare var Promise: PromiseConstructor; -declare namespace ts { - const scanner: Scanner; - enum SemanticMeaning { - None = 0, - Value = 1, - Type = 2, - Namespace = 4, - All = 7 - } - function getMeaningFromDeclaration(node: Node): SemanticMeaning; - function getMeaningFromLocation(node: Node): SemanticMeaning; - function isInRightSideOfInternalImportEqualsDeclaration(node: Node): boolean; - function isCallExpressionTarget(node: Node): boolean; - function isNewExpressionTarget(node: Node): boolean; - function climbPastPropertyAccess(node: Node): Node; - function getTargetLabel(referenceNode: Node, labelName: string): Identifier | undefined; - function isJumpStatementTarget(node: Node): node is Identifier & { - parent: BreakOrContinueStatement; - }; - function isLabelOfLabeledStatement(node: Node): node is Identifier; - 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: StringLiteral | NumericLiteral): boolean; - function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node): boolean; - function getContainerNode(node: Node): Declaration | undefined; - function getNodeKind(node: Node): ScriptElementKind; - function isThis(node: Node): boolean; - interface ListItemInfo { - listItemIndex: number; - list: Node; - } - function getLineStartPositionForPosition(position: number, sourceFile: SourceFileLike): number; - function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; - function rangeContainsRangeExclusive(r1: TextRange, r2: TextRange): boolean; - function rangeContainsPosition(r: TextRange, pos: number): boolean; - function rangeContainsPositionExclusive(r: TextRange, pos: number): 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 nodeOverlapsWithStartEnd(node: Node, sourceFile: SourceFile, start: number, end: number): boolean; - function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; - /** - * Assumes `candidate.start <= position` holds. - */ - function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; - function findListItemInfo(node: Node): ListItemInfo | undefined; - function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile: SourceFile): boolean; - function findChildOfKind(n: Node, kind: T["kind"], sourceFile: SourceFileLike): T | undefined; - function findContainingList(node: Node): SyntaxList | undefined; - /** - * Gets the token whose text has range [start, end) and - * position >= start and (position < end or (position === end && token is literal or keyword or identifier)) - */ - function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node; - /** - * Returns the token if position is in [start, end). - * If position === end, returns the preceding token if includeItemAtEndPosition(previousToken) === true - */ - function getTouchingToken(sourceFile: SourceFile, position: number, includePrecedingTokenAtEndPosition?: (n: Node) => boolean): Node; - /** Returns a token if position is in [start-of-leading-trivia, end) */ - function getTokenAtPosition(sourceFile: SourceFile, position: number): Node; - /** - * The token on the left of the position is the token that strictly includes the position - * or sits to the left of the cursor if it is on a boundary. For example - * - * fo|o -> will return foo - * foo |bar -> will return foo - * - */ - function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node | undefined; - function findNextToken(previousToken: Node, parent: Node, sourceFile: SourceFile): Node | undefined; - /** - * Finds the rightmost token satisfying `token.end <= position`, - * excluding `JsxText` tokens containing only whitespace. - */ - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node, includeJsDoc?: boolean): Node | undefined; - function isInString(sourceFile: SourceFile, position: number, previousToken?: Node | undefined): boolean; - /** - * returns true if the position is in between the open and close elements of an JSX expression. - */ - function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; - function isInTemplateString(sourceFile: SourceFile, position: number): boolean; - function findPrecedingMatchingToken(token: Node, matchingTokenKind: SyntaxKind, sourceFile: SourceFile): Node | undefined; - interface PossibleTypeArgumentInfo { - readonly called: Identifier; - readonly nTypeArguments: number; - } - function isPossiblyTypeArgumentPosition(tokenIn: Node, sourceFile: SourceFile): PossibleTypeArgumentInfo | undefined; - /** - * Returns true if the cursor at position in sourceFile is within a comment. - * - * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) - * @param predicate Additional predicate to test on the comment range. - */ - function isInComment(sourceFile: SourceFile, position: number, tokenAtPosition?: Node, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean; - function getNodeModifiers(node: Node): string; - function getTypeArgumentOrTypeParameterList(node: Node): NodeArray | undefined; - function isComment(kind: SyntaxKind): boolean; - function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; - function isPunctuation(kind: SyntaxKind): boolean; - function isInsideTemplateLiteral(node: TemplateLiteralToken, position: number, sourceFile: SourceFile): boolean; - function isAccessibilityModifier(kind: SyntaxKind): boolean; - function cloneCompilerOptions(options: CompilerOptions): CompilerOptions; - function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; - function isInReferenceComment(sourceFile: SourceFile, position: number): boolean; - function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean; - function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan; - function createTextSpanFromRange(range: TextRange): TextSpan; - function createTextRangeFromSpan(span: TextSpan): TextRange; - function createTextChangeFromStartLength(start: number, length: number, newText: string): TextChange; - function createTextChange(span: TextSpan, newText: string): TextChange; - const typeKeywords: ReadonlyArray; - function isTypeKeyword(kind: SyntaxKind): boolean; - /** True if the symbol is for an external module, as opposed to a namespace. */ - function isExternalModuleSymbol(moduleSymbol: Symbol): boolean; - /** Returns `true` the first time it encounters a node and `false` afterwards. */ - type NodeSeenTracker = (node: T) => boolean; - function nodeSeenTracker(): NodeSeenTracker; - function getSnapshotText(snap: IScriptSnapshot): string; - function repeatString(str: string, count: number): string; - function skipConstraint(type: Type): Type; - function getNameFromPropertyName(name: PropertyName): string | undefined; - function programContainsEs6Modules(program: Program): boolean; - function compilerOptionsIndicateEs6Modules(compilerOptions: CompilerOptions): boolean; - function hostUsesCaseSensitiveFileNames(host: LanguageServiceHost): boolean; - function hostGetCanonicalFileName(host: LanguageServiceHost): GetCanonicalFileName; - function makeImportIfNecessary(defaultImport: Identifier | undefined, namedImports: ReadonlyArray | undefined, moduleSpecifier: string, quotePreference: QuotePreference): ImportDeclaration | undefined; - function makeImport(defaultImport: Identifier | undefined, namedImports: ReadonlyArray | undefined, moduleSpecifier: string | Expression, quotePreference: QuotePreference): ImportDeclaration; - function makeStringLiteral(text: string, quotePreference: QuotePreference): StringLiteral; - enum QuotePreference { - Single = 0, - Double = 1 - } - function quotePreferenceFromString(str: StringLiteral, sourceFile: SourceFile): QuotePreference; - function getQuotePreference(sourceFile: SourceFile, preferences: UserPreferences): QuotePreference; - function symbolNameNoDefault(symbol: Symbol): string | undefined; - function symbolEscapedNameNoDefault(symbol: Symbol): __String | undefined; - function getPropertySymbolFromBindingElement(checker: TypeChecker, bindingElement: BindingElement & { - name: Identifier; - }): Symbol | undefined; - /** - * 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, checker: TypeChecker, cb: (symbol: Symbol) => T | undefined): T | undefined; - function isMemberSymbolInBaseType(memberSymbol: Symbol, checker: TypeChecker): boolean; - interface ReadonlyNodeSet { - has(node: Node): boolean; - forEach(cb: (node: Node) => void): void; - some(pred: (node: Node) => boolean): boolean; - } - class NodeSet implements ReadonlyNodeSet { - private map; - add(node: Node): void; - has(node: Node): boolean; - forEach(cb: (node: Node) => void): void; - some(pred: (node: Node) => boolean): boolean; - } - function getParentNodeInSpan(node: Node | undefined, file: SourceFile, span: TextSpan): Node | undefined; - function findModifier(node: Node, kind: Modifier["kind"]): Modifier | undefined; - function insertImport(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importDecl: Statement): void; -} -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; - /** - * The default is CRLF. - */ - function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost, formatSettings?: FormatCodeSettings): 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 isImportOrExportSpecifierName(location: Node): location is Identifier; - /** - * Strip off existed single quotes or double quotes from a given string - * - * @return non-quoted string - */ - function stripQuotes(name: string): string; - function startsWithQuote(name: string): boolean; - function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; - function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; - function getUniqueSymbolId(symbol: Symbol, checker: TypeChecker): number; - function getFirstNonSpaceCharacterPosition(text: string, position: number): number; - /** - * Creates a deep, memberwise clone of a node with no source map location. - * - * WARNING: This is an expensive operation and is only intended to be used in refactorings - * and code fixes (because those are triggered by explicit user actions). - */ - function getSynthesizedDeepClone(node: T, includeTrivia?: boolean): T; - function getSynthesizedDeepClones(nodes: NodeArray, includeTrivia?: boolean): NodeArray; - function getSynthesizedDeepClones(nodes: NodeArray | undefined, includeTrivia?: boolean): NodeArray | undefined; - /** - * Sets EmitFlags to suppress leading and trailing trivia on the node. - */ - function suppressLeadingAndTrailingTrivia(node: Node): void; - /** - * Sets EmitFlags to suppress leading trivia on the node. - */ - function suppressLeadingTrivia(node: Node): void; - /** - * Sets EmitFlags to suppress trailing trivia on the node. - */ - function suppressTrailingTrivia(node: Node): void; - function getUniqueName(baseName: string, sourceFile: SourceFile): string; - /** - * @return The index of the (only) reference to the extracted symbol. We want the cursor - * to be on the reference, rather than the declaration, because it's closer to where the - * user was before extracting it. - */ - function getRenameLocation(edits: ReadonlyArray, renameFilename: string, name: string, preferLastLocation: boolean): number; - function copyComments(sourceNode: Node, targetNode: Node, sourceFile: SourceFile, commentKind?: CommentKind, hasTrailingNewLine?: boolean): void; -} declare namespace ts { function createClassifier(): Classifier; - function getSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: UnderscoreEscapedMap, span: TextSpan): ClassifiedSpan[]; - function getEncodedSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: UnderscoreEscapedMap, 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.PathCompletions { - interface NameAndKind { - readonly name: string; - readonly kind: ScriptElementKind.scriptElement | ScriptElementKind.directory | ScriptElementKind.externalModuleName; - } - interface PathCompletion extends NameAndKind { - readonly span: TextSpan | undefined; - } - function getStringLiteralCompletionsFromModuleNames(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker): ReadonlyArray; - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number, compilerOptions: CompilerOptions, host: LanguageServiceHost): ReadonlyArray | undefined; -} -declare namespace ts.Completions { - type Log = (message: string) => void; - function getCompletionsAtPosition(host: LanguageServiceHost, program: Program, log: Log, sourceFile: SourceFile, position: number, preferences: UserPreferences, triggerCharacter: CompletionsTriggerCharacter | undefined): CompletionInfo | undefined; - interface CompletionEntryIdentifier { - name: string; - source?: string; - } - function getCompletionEntryDetails(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost, formatContext: formatting.FormatContext, getCanonicalFileName: GetCanonicalFileName, preferences: UserPreferences, cancellationToken: CancellationToken): CompletionEntryDetails | undefined; - function getCompletionEntrySymbol(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier): Symbol | undefined; -} -declare namespace ts.DocumentHighlights { - function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: ReadonlyArray): DocumentHighlights[] | undefined; } declare namespace ts { /** @@ -11002,276 +5607,16 @@ declare namespace ts { */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; - getLanguageServiceRefCounts(path: Path): [string, number | undefined][]; reportStats(): string; } - interface ExternalDocumentCache { - setDocument(key: DocumentRegistryBucketKey, path: Path, sourceFile: SourceFile): void; - getDocument(key: DocumentRegistryBucketKey, path: Path): SourceFile | undefined; - } type DocumentRegistryBucketKey = string & { __bucketKey: any; }; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; - function createDocumentRegistryInternal(useCaseSensitiveFileNames?: boolean, currentDirectory?: string, externalCache?: ExternalDocumentCache): DocumentRegistry; -} -declare namespace ts.FindAllReferences { - interface ImportsResult { - /** For every import of the symbol, the location and local symbol for the import. */ - importSearches: ReadonlyArray<[Identifier, Symbol]>; - /** For rename imports/exports `{ foo as bar }`, `foo` is not a local, so it may be added as a reference immediately without further searching. */ - singleReferences: ReadonlyArray; - /** List of source files that may (or may not) use the symbol via a namespace. (For UMD modules this is every file.) */ - indirectUsers: ReadonlyArray; - } - type ImportTracker = (exportSymbol: Symbol, exportInfo: ExportInfo, isForRename: boolean) => ImportsResult; - /** Creates the imports map and returns an ImportTracker that uses it. Call this lazily to avoid calling `getDirectImportsMap` unnecessarily. */ - function createImportTracker(sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap, checker: TypeChecker, cancellationToken: CancellationToken | undefined): ImportTracker; - /** Info about an exported symbol to perform recursive search on. */ - interface ExportInfo { - exportingModuleSymbol: Symbol; - exportKind: ExportKind; - } - enum ExportKind { - Named = 0, - Default = 1, - ExportEquals = 2 - } - enum ImportExport { - Import = 0, - Export = 1 - } - type ModuleReference = { - kind: "import"; - literal: StringLiteralLike; - } - /** or */ - | { - kind: "reference"; - referencingFile: SourceFile; - ref: FileReference; - }; - function findModuleReferences(program: Program, sourceFiles: ReadonlyArray, searchModuleSymbol: Symbol): ModuleReference[]; - interface ImportedSymbol { - kind: ImportExport.Import; - symbol: Symbol; - isNamedImport: boolean; - } - interface ExportedSymbol { - kind: ImportExport.Export; - symbol: Symbol; - exportInfo: ExportInfo; - } - /** - * Given a local reference, we might notice that it's an import/export and recursively search for references of that. - * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. - * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. - * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. - */ - function getImportOrExportSymbol(node: Node, symbol: Symbol, checker: TypeChecker, comingFromExport: boolean): ImportedSymbol | ExportedSymbol | undefined; - function getExportInfo(exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker): ExportInfo | undefined; -} -declare namespace ts.FindAllReferences { - interface SymbolAndEntries { - definition: Definition | undefined; - references: Entry[]; - } - type Definition = { - type: "symbol"; - symbol: Symbol; - } | { - type: "label"; - node: Identifier; - } | { - type: "keyword"; - node: Node; - } | { - type: "this"; - node: Node; - } | { - type: "string"; - node: StringLiteral; - }; - type Entry = NodeEntry | SpanEntry; - interface NodeEntry { - type: "node"; - node: Node; - isInString?: true; - } - interface SpanEntry { - type: "span"; - fileName: string; - textSpan: TextSpan; - } - function nodeEntry(node: Node, isInString?: true): NodeEntry; - interface Options { - readonly findInStrings?: boolean; - readonly findInComments?: boolean; - /** - * True if we are renaming the symbol. - * If so, we will find fewer references -- if it is referenced by several different names, we sill only find references for the original name. - */ - readonly isForRename?: boolean; - /** True if we are searching for implementations. We will have a different method of adding references if so. */ - readonly implementations?: boolean; - } - function findReferencedSymbols(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ReferencedSymbol[] | undefined; - function getImplementationsAtPosition(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, sourceFile: SourceFile, position: number): ImplementationLocation[] | undefined; - function findReferencedEntries(program: Program, cancellationToken: CancellationToken, sourceFiles: ReadonlyArray, node: Node, position: number, options: Options | undefined): ReferenceEntry[] | undefined; - function getReferenceEntriesForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options?: Options, sourceFilesSet?: ReadonlyMap): Entry[] | undefined; - function toHighlightSpan(entry: Entry): { - fileName: string; - span: HighlightSpan; - }; -} -/** Encapsulates the core find-all-references algorithm. */ -declare namespace ts.FindAllReferences.Core { - /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */ - function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options?: Options, sourceFilesSet?: ReadonlyMap): SymbolAndEntries[] | undefined; - function eachExportReference(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken | undefined, exportSymbol: Symbol, exportingModuleSymbol: Symbol, exportName: string, isDefaultExport: boolean, cb: (ref: Identifier) => void): void; - /** Used as a quick check for whether a symbol is used at all in a file (besides its definition). */ - function isSymbolReferencedInFile(definition: Identifier, checker: TypeChecker, sourceFile: SourceFile): boolean; - function eachSymbolReferenceInFile(definition: Identifier, checker: TypeChecker, sourceFile: SourceFile, cb: (token: Identifier) => T): T | undefined; - function eachSignatureCall(signature: SignatureDeclaration, sourceFiles: ReadonlyArray, checker: TypeChecker, cb: (call: CallExpression) => void): void; - /** - * 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(node: Node, symbol: Symbol): SemanticMeaning; - function getReferenceEntriesForShorthandPropertyAssignment(node: Node, checker: TypeChecker, addReference: (node: Node) => void): void; -} -declare namespace ts { - function getEditsForFileRename(program: Program, oldFileOrDirPath: string, newFileOrDirPath: string, host: LanguageServiceHost, formatContext: formatting.FormatContext, preferences: UserPreferences): ReadonlyArray; - /** If 'path' refers to an old directory, returns path in the new directory. */ - type PathUpdater = (path: string) => string | undefined; - function getPathUpdater(oldFileOrDirPath: string, newFileOrDirPath: string, getCanonicalFileName: GetCanonicalFileName): PathUpdater; -} -declare namespace ts.GoToDefinition { - function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[] | undefined; - function getReferenceAtPosition(sourceFile: SourceFile, position: number, program: Program): { - fileName: string; - file: SourceFile; - } | undefined; - function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): DefinitionInfo[] | undefined; - function getDefinitionAndBoundSpan(program: Program, sourceFile: SourceFile, position: number): DefinitionInfoAndBoundSpan | undefined; - function findReferenceInPosition(refs: ReadonlyArray, pos: number): FileReference | undefined; -} -declare namespace ts.JsDoc { - function getJsDocCommentsFromDeclarations(declarations: ReadonlyArray): SymbolDisplayPart[]; - function getJsDocTagsFromDeclarations(declarations?: Declaration[]): JSDocTagInfo[]; - function getJSDocTagNameCompletions(): CompletionEntry[]; - const getJSDocTagNameCompletionDetails: typeof getJSDocTagCompletionDetails; - function getJSDocTagCompletions(): CompletionEntry[]; - function getJSDocTagCompletionDetails(name: string): CompletionEntryDetails; - function getJSDocParameterNameCompletions(tag: JSDocParameterTag): CompletionEntry[]; - function getJSDocParameterNameCompletionDetails(name: string): CompletionEntryDetails; - /** - * Checks if position points to a valid position to add JSDoc comments, and if so, - * returns the appropriate template. Otherwise returns an empty string. - * Valid positions are - * - outside of comments, statements, and expressions, and - * - preceding a: - * - function/constructor/method declaration - * - class declarations - * - variable statements - * - namespace declarations - * - interface declarations - * - method signatures - * - type alias declarations - * - * Hosts should ideally check that: - * - The line is all whitespace up to 'position' before performing the insertion. - * - If the keystroke sequence "/\*\*" induced the call, we also check that the next - * non-whitespace character is '*', which (approximately) indicates whether we added - * the second '*' to complete an existing (JSDoc) comment. - * @param fileName The file in which to perform the check. - * @param position The (character-indexed) position in the file where the check should - * be performed. - */ - function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion | undefined; -} -declare namespace ts.NavigateTo { - function getNavigateToItems(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number | undefined, excludeDtsFiles: boolean): NavigateToItem[]; -} -declare namespace ts.NavigationBar { - function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationBarItem[]; - function getNavigationTree(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationTree; -} -declare namespace ts.OrganizeImports { - /** - * Organize imports by: - * 1) Removing unused imports - * 2) Coalescing imports from the same module - * 3) Sorting imports - */ - function organizeImports(sourceFile: SourceFile, formatContext: formatting.FormatContext, host: LanguageServiceHost, program: Program, _preferences: UserPreferences): FileTextChanges[]; - /** - * @param importGroup a list of ImportDeclarations, all with the same module name. - */ - function coalesceImports(importGroup: ReadonlyArray): ReadonlyArray; - /** - * @param exportGroup a list of ExportDeclarations, all with the same module name. - */ - function coalesceExports(exportGroup: ReadonlyArray): ReadonlyArray; - function compareModuleSpecifiers(m1: Expression, m2: Expression): Comparison; -} -declare namespace ts.OutliningElementsCollector { - function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[]; -} -declare namespace ts { - enum PatternMatchKind { - exact = 0, - prefix = 1, - substring = 2, - camelCase = 3 - } - interface PatternMatch { - kind: PatternMatchKind; - isCaseSensitive: boolean; - } - interface PatternMatcher { - getMatchForLastSegmentOfPattern(candidate: string): PatternMatch | undefined; - getFullMatch(candidateContainers: ReadonlyArray, candidate: string): PatternMatch | undefined; - patternContainsDots: boolean; - } - function createPatternMatcher(pattern: string): PatternMatcher | undefined; - 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: GetCanonicalFileName, sourceFile: SourceFile, position: number): RenameInfo; -} -declare namespace ts.SignatureHelp { - function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems | undefined; - interface ArgumentInfoForCompletions { - readonly invocation: CallLikeExpression; - readonly argumentIndex: number; - readonly argumentCount: number; - } - function getArgumentInfoForCompletions(node: Node, position: number, sourceFile: SourceFile): ArgumentInfoForCompletions | undefined; -} -declare namespace ts { - function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[]; -} -declare namespace ts.SymbolDisplay { - function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): ScriptElementKind; - function getSymbolModifiers(symbol: Symbol): string; - interface SymbolDisplayPartsDocumentationAndSymbolKind { - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - symbolKind: ScriptElementKind; - tags: JSDocTagInfo[] | undefined; - } - function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node | undefined, location: Node, semanticMeaning?: SemanticMeaning, alias?: Symbol): SymbolDisplayPartsDocumentationAndSymbolKind; -} declare namespace ts { interface TranspileOptions { compilerOptions?: CompilerOptions; @@ -11288,519 +5633,10 @@ declare namespace ts { } function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; - /** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */ - function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions; -} -declare namespace ts.formatting { - enum FormattingRequestKind { - FormatDocument = 0, - FormatSelection = 1, - FormatOnEnter = 2, - FormatOnSemicolon = 3, - FormatOnOpeningCurlyBrace = 4, - FormatOnClosingCurlyBrace = 5 - } - class FormattingContext { - readonly sourceFile: SourceFileLike; - formattingRequestKind: FormattingRequestKind; - options: FormatCodeSettings; - currentTokenSpan: TextRangeWithKind; - nextTokenSpan: TextRangeWithKind; - contextNode: Node; - currentTokenParent: Node; - nextTokenParent: Node; - private contextNodeAllOnSameLine; - private nextNodeAllOnSameLine; - private tokensAreOnSameLine; - private contextNodeBlockIsOnOneLine; - private nextNodeBlockIsOnOneLine; - constructor(sourceFile: SourceFileLike, formattingRequestKind: FormattingRequestKind, options: FormatCodeSettings); - updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; - ContextNodeAllOnSameLine(): boolean; - NextNodeAllOnSameLine(): boolean; - TokensAreOnSameLine(): boolean; - ContextNodeBlockIsOnOneLine(): boolean; - NextNodeBlockIsOnOneLine(): boolean; - private NodeIsOnOneLine; - private BlockIsOnOneLine; - } -} -declare namespace ts.formatting { - interface FormattingScanner { - advance(): void; - isOnToken(): boolean; - readTokenInfo(n: Node): TokenInfo; - getCurrentLeadingTrivia(): TextRangeWithKind[] | undefined; - lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; - } - function getFormattingScanner(text: string, languageVariant: LanguageVariant, startPos: number, endPos: number, cb: (scanner: FormattingScanner) => T): T; -} -declare namespace ts.formatting { - interface Rule { - readonly debugName: string; - readonly context: ReadonlyArray; - readonly action: RuleAction; - readonly flags: RuleFlags; - } - type ContextPredicate = (context: FormattingContext) => boolean; - const anyContext: ReadonlyArray; - enum RuleAction { - Ignore = 1, - Space = 2, - NewLine = 4, - Delete = 8 - } - enum RuleFlags { - None = 0, - CanDeleteNewLines = 1 - } - interface TokenRange { - readonly tokens: ReadonlyArray; - readonly isSpecific: boolean; - } -} -declare namespace ts.formatting { - interface RuleSpec { - readonly leftTokenRange: TokenRange; - readonly rightTokenRange: TokenRange; - readonly rule: Rule; - } - function getAllRules(): RuleSpec[]; -} -declare namespace ts.formatting { - function getFormatContext(options: FormatCodeSettings): FormatContext; - type RulesMap = (context: FormattingContext) => Rule | undefined; -} -declare namespace ts.formatting { - interface FormatContext { - readonly options: FormatCodeSettings; - readonly getRule: RulesMap; - } - interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; - } - interface TextRangeWithTriviaKind extends TextRange { - kind: TriviaKind; - } - interface TokenInfo { - leadingTrivia: TextRangeWithTriviaKind[] | undefined; - token: TextRangeWithKind; - trailingTrivia: TextRangeWithTriviaKind[] | undefined; - } - function formatOnEnter(position: number, sourceFile: SourceFile, formatContext: FormatContext): TextChange[]; - function formatOnSemicolon(position: number, sourceFile: SourceFile, formatContext: FormatContext): TextChange[]; - function formatOnOpeningCurly(position: number, sourceFile: SourceFile, formatContext: FormatContext): TextChange[]; - function formatOnClosingCurly(position: number, sourceFile: SourceFile, formatContext: FormatContext): TextChange[]; - function formatDocument(sourceFile: SourceFile, formatContext: FormatContext): TextChange[]; - function formatSelection(start: number, end: number, sourceFile: SourceFile, formatContext: FormatContext): TextChange[]; - function formatNodeGivenIndentation(node: Node, sourceFileLike: SourceFileLike, languageVariant: LanguageVariant, initialIndentation: number, delta: number, formatContext: FormatContext): TextChange[]; - /** - * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. - */ - function getRangeOfEnclosingComment(sourceFile: SourceFile, position: number, onlyMultiLine: boolean, precedingToken?: Node | null, // tslint:disable-line:no-null-keyword - tokenAtPosition?: Node, predicate?: (c: CommentRange) => boolean): CommentRange | undefined; - function getIndentationString(indentation: number, options: EditorSettings): string; -} -declare namespace ts.formatting { - namespace SmartIndenter { - /** - * @param assumeNewLineBeforeCloseBrace - * `false` when called on text from a real source file. - * `true` when we need to assume `position` is on a newline. - * - * This is useful for codefixes. Consider - * ``` - * function f() { - * |} - * ``` - * with `position` at `|`. - * - * When inserting some text after an open brace, we would like to get indentation as if a newline was already there. - * By default indentation at `position` will be 0 so 'assumeNewLineBeforeCloseBrace' overrides this behavior. - */ - function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings, assumeNewLineBeforeCloseBrace?: boolean): number; - function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number; - function getBaseIndentation(options: EditorSettings): number; - function isArgumentAndStartLineOverlapsExpressionBeingCalled(parent: Node, child: Node, childStartLine: number, sourceFile: SourceFileLike): boolean; - function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean; - function getContainingList(node: Node, sourceFile: SourceFile): NodeArray | undefined; - /** - * Character is the actual index of the character since the beginning of the line. - * Column - position of the character after expanding tabs to spaces. - * "0\t2$" - * value of 'character' for '$' is 3 - * value of 'column' for '$' is 6 (assuming that tab size is 4) - */ - function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings): { - column: number; - character: number; - }; - function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings): number; - function nodeWillIndentChild(settings: FormatCodeSettings, parent: TextRangeWithKind, child: TextRangeWithKind | undefined, sourceFile: SourceFileLike | undefined, indentByDefault: boolean): boolean; - /** - * True when the parent node should indent the given child by an explicit rule. - * @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child. - */ - function shouldIndentChildNode(settings: FormatCodeSettings, parent: TextRangeWithKind, child?: Node, sourceFile?: SourceFileLike, isNextChild?: boolean): boolean; - } -} -declare namespace ts.textChanges { - interface ConfigurableStart { - /** True to use getStart() (NB, not getFullStart()) without adjustment. */ - useNonAdjustedStartPosition?: boolean; - } - interface ConfigurableEnd { - /** True to use getEnd() without adjustment. */ - useNonAdjustedEndPosition?: boolean; - } - enum Position { - FullStart = 0, - Start = 1 - } - /** - * Usually node.pos points to a position immediately after the previous token. - * If this position is used as a beginning of the span to remove - it might lead to removing the trailing trivia of the previous node, i.e: - * const x; // this is x - * ^ - pos for the next variable declaration will point here - * const y; // this is y - * ^ - end for previous variable declaration - * Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding - * variable declaration and trailing trivia for 'y' should include (whitespace, comment 'this is y', newline). - * By default when removing nodes we adjust start and end positions to respect specification of the trivia above. - * If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true - */ - interface ConfigurableStartEnd extends ConfigurableStart, ConfigurableEnd { - } - const useNonAdjustedPositions: ConfigurableStartEnd; - interface InsertNodeOptions { - /** - * Text to be inserted before the new node - */ - prefix?: string; - /** - * Text to be inserted after the new node - */ - suffix?: string; - /** - * Text of inserted node will be formatted with this indentation, otherwise indentation will be inferred from the old node - */ - indentation?: number; - /** - * Text of inserted node will be formatted with this delta, otherwise delta will be inferred from the new node kind - */ - delta?: number; - /** - * Do not trim leading white spaces in the edit range - */ - preserveLeadingWhitespace?: boolean; - } - interface ReplaceWithMultipleNodesOptions extends InsertNodeOptions { - readonly joiner?: string; - } - interface ChangeNodeOptions extends ConfigurableStartEnd, InsertNodeOptions { - } - interface TextChangesContext { - host: LanguageServiceHost; - formatContext: formatting.FormatContext; - } - type TypeAnnotatable = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertyDeclaration | PropertySignature; - class ChangeTracker { - private readonly newLineCharacter; - private readonly formatContext; - private readonly changes; - private readonly newFiles; - private readonly deletedNodesInLists; - private readonly classesWithNodesInsertedAtStart; - private readonly deletedDeclarations; - static fromContext(context: TextChangesContext): ChangeTracker; - static with(context: TextChangesContext, cb: (tracker: ChangeTracker) => void): FileTextChanges[]; - /** Public for tests only. Other callers should use `ChangeTracker.with`. */ - constructor(newLineCharacter: string, formatContext: formatting.FormatContext); - deleteRange(sourceFile: SourceFile, range: TextRange): this; - deleteDeclaration(sourceFile: SourceFile, node: Node): void; - /** Warning: This deletes comments too. See `copyComments` in `convertFunctionToEs6Class`. */ - deleteNode(sourceFile: SourceFile, node: Node, options?: ConfigurableStartEnd): this; - deleteModifier(sourceFile: SourceFile, modifier: Modifier): void; - deleteNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options?: ConfigurableStartEnd): this; - deleteNodeRangeExcludingEnd(sourceFile: SourceFile, startNode: Node, afterEndNode: Node | undefined, options?: ConfigurableStartEnd): void; - deleteNodeInList(sourceFile: SourceFile, node: Node): this; - replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options?: InsertNodeOptions): this; - replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options?: ChangeNodeOptions): this; - replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options?: ChangeNodeOptions): void; - private replaceRangeWithNodes; - replaceNodeWithNodes(sourceFile: SourceFile, oldNode: Node, newNodes: ReadonlyArray, options?: ChangeNodeOptions): this; - replaceNodeRangeWithNodes(sourceFile: SourceFile, startNode: Node, endNode: Node, newNodes: ReadonlyArray, options?: ReplaceWithMultipleNodesOptions & ConfigurableStartEnd): this; - private nextCommaToken; - replacePropertyAssignment(sourceFile: SourceFile, oldNode: PropertyAssignment, newNode: PropertyAssignment): this; - private insertNodeAt; - private insertNodesAt; - insertNodeAtTopOfFile(sourceFile: SourceFile, newNode: Statement, blankLineBetween: boolean): void; - insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, blankLineBetween?: boolean): void; - insertModifierBefore(sourceFile: SourceFile, modifier: SyntaxKind, before: Node): void; - insertCommentBeforeLine(sourceFile: SourceFile, lineNumber: number, position: number, commentText: string): void; - replaceRangeWithText(sourceFile: SourceFile, range: TextRange, text: string): void; - private insertText; - /** Prefer this over replacing a node with another that has a type annotation, as it avoids reformatting the other parts of the node. */ - tryInsertTypeAnnotation(sourceFile: SourceFile, node: TypeAnnotatable, type: TypeNode): void; - insertTypeParameters(sourceFile: SourceFile, node: SignatureDeclaration, typeParameters: ReadonlyArray): void; - private getOptionsForInsertNodeBefore; - insertNodeAtConstructorStart(sourceFile: SourceFile, ctr: ConstructorDeclaration, newStatement: Statement): void; - insertNodeAtConstructorEnd(sourceFile: SourceFile, ctr: ConstructorDeclaration, newStatement: Statement): void; - private replaceConstructorBody; - insertNodeAtEndOfScope(sourceFile: SourceFile, scope: Node, newNode: Node): void; - insertNodeAtClassStart(sourceFile: SourceFile, cls: ClassLikeDeclaration, newElement: ClassElement): void; - private getInsertNodeAtClassStartPrefixSuffix; - insertNodeAfterComma(sourceFile: SourceFile, after: Node, newNode: Node): void; - insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node): void; - insertNodeAtEndOfList(sourceFile: SourceFile, list: NodeArray, newNode: Node): void; - insertNodesAfter(sourceFile: SourceFile, after: Node, newNodes: ReadonlyArray): void; - private insertNodeAfterWorker; - private getInsertNodeAfterOptions; - private getInsertNodeAfterOptionsWorker; - insertName(sourceFile: SourceFile, node: FunctionExpression | ClassExpression | ArrowFunction, name: string): void; - insertExportModifier(sourceFile: SourceFile, node: DeclarationStatement | VariableStatement): void; - /** - * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, - * i.e. arguments in arguments lists, parameters in parameter lists etc. - * Note that separators are part of the node in statements and class elements. - */ - insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node, containingList?: NodeArray | undefined): this; - private finishClassesWithNodesInsertedAtStart; - private finishTrailingCommaAfterDeletingNodesInList; - private finishDeleteDeclarations; - /** - * Note: after calling this, the TextChanges object must be discarded! - * @param validate only for tests - * The reason we must validate as part of this method is that `getNonFormattedText` changes the node's positions, - * so we can only call this once and can't get the non-formatted text separately. - */ - getChanges(validate?: ValidateNonFormattedText): FileTextChanges[]; - createNewFile(oldFile: SourceFile, fileName: string, statements: ReadonlyArray): void; - } - type ValidateNonFormattedText = (node: Node, text: string) => void; - function applyChanges(text: string, changes: ReadonlyArray): string; - function isValidLocationToAddComment(sourceFile: SourceFile, position: number): boolean; -} -declare namespace ts { - interface CodeFixRegistration { - errorCodes: number[]; - getCodeActions(context: CodeFixContext): CodeFixAction[] | undefined; - fixIds?: string[]; - getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions; - } - interface CodeFixContextBase extends textChanges.TextChangesContext { - sourceFile: SourceFile; - program: Program; - cancellationToken: CancellationToken; - preferences: UserPreferences; - } - interface CodeFixAllContext extends CodeFixContextBase { - fixId: {}; - } - interface CodeFixContext extends CodeFixContextBase { - errorCode: number; - span: TextSpan; - } - namespace codefix { - type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string]; - function createCodeFixActionNoFixId(fixName: string, changes: FileTextChanges[], description: DiagnosticAndArguments): CodeFixAction; - function createCodeFixAction(fixName: string, changes: FileTextChanges[], description: DiagnosticAndArguments, fixId: {}, fixAllDescription: DiagnosticAndArguments, command?: CodeActionCommand): CodeFixAction; - function registerCodeFix(reg: CodeFixRegistration): void; - function getSupportedErrorCodes(): string[]; - function getFixes(context: CodeFixContext): CodeFixAction[]; - function getAllFixes(context: CodeFixAllContext): CombinedCodeActions; - function createFileTextChanges(fileName: string, textChanges: TextChange[]): FileTextChanges; - function codeFixAll(context: CodeFixAllContext, errorCodes: number[], use: (changes: textChanges.ChangeTracker, error: DiagnosticWithLocation, commands: Push) => void): CombinedCodeActions; - } -} -declare namespace ts { - interface Refactor { - /** Compute the associated code actions */ - getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined; - /** Compute (quickly) which actions are available here */ - getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined; - } - interface RefactorContext extends textChanges.TextChangesContext { - file: SourceFile; - startPosition: number; - endPosition?: number; - program: Program; - cancellationToken?: CancellationToken; - preferences: UserPreferences; - } - namespace refactor { - /** @param name An unique code associated with each refactor. Does not have to be human-readable. */ - function registerRefactor(name: string, refactor: Refactor): void; - function getApplicableRefactors(context: RefactorContext): ApplicableRefactorInfo[]; - function getEditsForRefactor(context: RefactorContext, refactorName: string, actionName: string): RefactorEditInfo | undefined; - } - function getRefactorContextSpan({ startPosition, endPosition }: RefactorContext): TextSpan; -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { - type DeclarationWithType = FunctionLikeDeclaration | VariableDeclaration | PropertySignature | PropertyDeclaration; - function parameterShouldGetTypeFromJSDoc(node: Node): node is DeclarationWithType; -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { - function getImportCompletionAction(exportedSymbol: Symbol, moduleSymbol: Symbol, sourceFile: SourceFile, symbolName: string, host: LanguageServiceHost, program: Program, checker: TypeChecker, compilerOptions: CompilerOptions, allSourceFiles: ReadonlyArray, formatContext: formatting.FormatContext, getCanonicalFileName: GetCanonicalFileName, symbolToken: Node | undefined, preferences: UserPreferences): { - readonly moduleSpecifier: string; - readonly codeAction: CodeAction; - }; - function forEachExternalModuleToImportFrom(checker: TypeChecker, from: SourceFile, allSourceFiles: ReadonlyArray, cb: (module: Symbol) => void): void; - function moduleSymbolToValidIdentifier(moduleSymbol: Symbol, target: ScriptTarget): string; - function moduleSpecifierToValidIdentifier(moduleSpecifier: string, target: ScriptTarget): string; -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { - /** - * 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 createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: ReadonlyArray, checker: TypeChecker, preferences: UserPreferences, out: (node: ClassElement) => void): void; - function createMethodFromCallExpression(context: CodeFixContextBase, { typeArguments, arguments: args, parent: parent }: CallExpression, methodName: string, inJs: boolean, makeStatic: boolean, preferences: UserPreferences): MethodDeclaration; -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.codefix { -} -declare namespace ts.refactor { -} -declare namespace ts.refactor { -} -declare namespace ts.refactor.extractSymbol { - /** - * Compute the associated code actions - * Exported for tests. - */ - function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined; - function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined; - namespace Messages { - const cannotExtractRange: DiagnosticMessage; - const cannotExtractImport: DiagnosticMessage; - const cannotExtractSuper: DiagnosticMessage; - const cannotExtractEmpty: DiagnosticMessage; - const expressionExpected: DiagnosticMessage; - const uselessConstantType: DiagnosticMessage; - const statementOrExpressionExpected: DiagnosticMessage; - const cannotExtractRangeContainingConditionalBreakOrContinueStatements: DiagnosticMessage; - const cannotExtractRangeContainingConditionalReturnStatement: DiagnosticMessage; - const cannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange: DiagnosticMessage; - const cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators: DiagnosticMessage; - const typeWillNotBeVisibleInTheNewScope: DiagnosticMessage; - const functionWillNotBeVisibleInTheNewScope: DiagnosticMessage; - const cannotExtractIdentifier: DiagnosticMessage; - const cannotExtractExportedEntity: DiagnosticMessage; - const cannotWriteInExpression: DiagnosticMessage; - const cannotExtractReadonlyPropertyInitializerOutsideConstructor: DiagnosticMessage; - const cannotExtractAmbientBlock: DiagnosticMessage; - const cannotAccessVariablesFromNestedScopes: DiagnosticMessage; - const cannotExtractToOtherFunctionLike: DiagnosticMessage; - const cannotExtractToJSClass: DiagnosticMessage; - const cannotExtractToExpressionArrowFunction: DiagnosticMessage; - } - enum RangeFacts { - None = 0, - HasReturn = 1, - IsGenerator = 2, - IsAsyncFunction = 4, - UsesThis = 8, - /** - * The range is in a function which needs the 'static' modifier in a class - */ - InStaticRegion = 16 - } - /** - * Represents an expression or a list of statements that should be extracted with some extra information - */ - interface TargetRange { - readonly range: Expression | Statement[]; - readonly facts: RangeFacts; - /** - * A list of symbols that are declared in the selected range which are visible in the containing lexical scope - * Used to ensure we don't turn something used outside the range free (or worse, resolve to a different entity). - */ - readonly declarations: Symbol[]; - } - /** - * Result of 'getRangeToExtract' operation: contains either a range or a list of errors - */ - type RangeToExtract = { - readonly targetRange?: never; - readonly errors: ReadonlyArray; - } | { - readonly targetRange: TargetRange; - readonly errors?: never; - }; - /** - * getRangeToExtract takes a span inside a text file and returns either an expression or an array - * of statements representing the minimum set of nodes needed to extract the entire span. This - * process may fail, in which case a set of errors is returned instead (these are currently - * not shown to the user, but can be used by us diagnostically) - */ - function getRangeToExtract(sourceFile: SourceFile, span: TextSpan): RangeToExtract; -} -declare namespace ts.refactor.generateGetAccessorAndSetAccessor { -} -declare namespace ts.refactor { -} -declare namespace ts.refactor.addOrRemoveBracesToArrowFunction { } declare namespace ts { /** The version of the language service API */ const servicesVersion = "0.8"; - interface DisplayPartsSymbolWriter extends EmitTextWriter { - displayParts(): SymbolDisplayPart[]; - } - function toEditorSettings(options: FormatCodeOptions | FormatCodeSettings): FormatCodeSettings; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[] | undefined): string; function getDefaultCompilerOptions(): CompilerOptions; @@ -11808,24 +5644,7 @@ declare namespace ts { function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange | undefined, aggressiveChecks?: boolean): SourceFile; - /** A cancellation that throttles calls to the host */ - class ThrottledCancellationToken implements CancellationToken { - private hostCancellationToken; - private readonly throttleWaitMilliseconds; - private lastCancellationCheckTime; - constructor(hostCancellationToken: HostCancellationToken, throttleWaitMilliseconds?: number); - isCancellationRequested(): boolean; - throwIfCancellationRequested(): void; - } function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry, syntaxOnly?: boolean): LanguageService; - /** Names in the name table are escaped, so an identifier `__foo` will have a name table entry `___foo`. */ - function getNameTable(sourceFile: SourceFile): UnderscoreEscapedMap; - /** - * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } - */ - function getContainingObjectLiteralElement(node: Node): ObjectLiteralElement | undefined; - function getPropertySymbolsFromContextualType(typeChecker: TypeChecker, node: ObjectLiteralElement): Symbol[]; - function getPropertySymbolsFromType(type: Type, propName: PropertyName): Symbol[] | undefined; /** * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. @@ -11833,13 +5652,7 @@ declare namespace ts { */ function getDefaultLibFilePath(options: CompilerOptions): string; } -declare namespace ts.BreakpointResolver { - /** - * Get the breakpoint span in given sourceFile - */ - function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number): TextSpan | undefined; -} -declare namespace ts { +declare namespace ts { /** * Transform one or more nodes using the supplied transformers. * @param source A single `Node` or an array of `Node` objects. @@ -11848,278 +5661,6 @@ declare namespace ts { */ function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; } -declare let debugObjectHost: { - CollectGarbage(): void; -}; -declare namespace ts { - interface ScriptSnapshotShim { - /** Gets a portion of the script snapshot specified by [start, end). */ - getText(start: number, end: number): string; - /** Gets the length of this script snapshot. */ - getLength(): number; - /** - * Returns a JSON-encoded value of the type: - * { span: { start: number; length: number }; newLength: number } - * - * Or undefined value if there was no change. - */ - getChangeRange(oldSnapshot: ScriptSnapshotShim): string | undefined; - /** Releases all resources held by this script snapshot */ - dispose?(): void; - } - interface Logger { - log(s: string): void; - trace(s: string): void; - error(s: string): void; - } - /** Public interface of the host of a language service shim instance. */ - interface LanguageServiceShimHost extends Logger { - getCompilationSettings(): string; - /** Returns a JSON-encoded value of the type: 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 | undefined; - fileExists(path: string): boolean; - getModuleResolutionsForFile?(fileName: string): string; - getTypeReferenceDirectiveResolutionsForFile?(fileName: string): string; - directoryExists(directoryName: string): boolean; - } - /** Public interface of the core-services host instance used in managed side */ - interface CoreServicesShimHost extends Logger { - directoryExists(directoryName: string): boolean; - fileExists(fileName: string): boolean; - getCurrentDirectory(): string; - getDirectories(path: string): string; - /** - * Returns a JSON-encoded value of the type: string[] - * - * @param exclude A JSON encoded string[] containing the paths to exclude - * when enumerating the directory. - */ - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - /** - * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules - */ - readFile(fileName: string): string | undefined; - realpath?(path: string): string; - trace(s: string): void; - useCaseSensitiveFileNames?(): boolean; - } - interface ShimsFileReference { - path: string; - position: number; - length: number; - } - /** Public interface of a language service instance shim. */ - interface ShimFactory { - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; - } - interface Shim { - dispose(_dummy: {}): void; - } - interface LanguageServiceShim extends Shim { - languageService: LanguageService; - dispose(_dummy: {}): void; - refresh(throwOnError: boolean): void; - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): string; - getSemanticDiagnostics(fileName: string): string; - getSuggestionDiagnostics(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, preferences: UserPreferences | undefined): string; - getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: string | undefined, source: string | undefined, preferences: UserPreferences | undefined): 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; - /** - * Returns a JSON-encoded value of the type: - * { canRename: boolean, localizedErrorMessage: string, displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, triggerSpan: { start; length } } - */ - getRenameInfo(fileName: string, position: number): string; - /** - * Returns a JSON-encoded value of the type: - * { fileName: string, textSpan: { start: number, length: number } }[] - */ - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string; - /** - * Returns a JSON-encoded value of the type: - * { fileName: string; textSpan: { start: number; length: number}; kind: string; name: string; containerKind: string; containerName: string } - * - * Or undefined value if no definition can be found. - */ - getDefinitionAtPosition(fileName: string, position: number): string; - getDefinitionAndBoundSpan(fileName: string, position: number): string; - /** - * Returns a JSON-encoded value of the type: - * { fileName: string; textSpan: { start: number; length: number}; kind: string; name: string; containerKind: string; containerName: string } - * - * Or undefined value if no definition can be found. - */ - getTypeDefinitionAtPosition(fileName: string, position: number): string; - /** - * Returns a JSON-encoded value of the type: - * { fileName: string; textSpan: { start: number; length: number}; }[] - */ - getImplementationAtPosition(fileName: string, position: number): string; - /** - * Returns a JSON-encoded value of the type: - * { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean, isDefinition?: boolean }[] - */ - getReferencesAtPosition(fileName: string, position: number): string; - /** - * Returns a JSON-encoded value of the type: - * { definition: ; references: [] }[] - */ - findReferences(fileName: string, position: number): string; - /** - * @deprecated - * Returns a JSON-encoded value of the type: - * { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[] - */ - getOccurrencesAtPosition(fileName: string, position: number): string; - /** - * Returns a JSON-encoded value of the type: - * { fileName: string; highlights: { start: number; length: number, isDefinition: boolean }[] }[] - * - * @param fileToSearch A JSON encoded string[] containing the file names that should be - * considered when searching. - */ - getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string; - /** - * Returns a JSON-encoded value of the type: - * { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = []; - */ - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): string; - /** - * Returns a JSON-encoded value of the type: - * { text: string; kind: string; kindModifiers: string; bolded: boolean; grayed: boolean; indent: number; spans: { start: number; length: number; }[]; childItems: [] } [] = []; - */ - getNavigationBarItems(fileName: string): string; - /** Returns a JSON-encoded value of the type ts.NavigationTree. */ - getNavigationTree(fileName: string): string; - /** - * Returns a JSON-encoded value of the type: - * { textSpan: { start: number, length: number }; hintSpan: { start: number, length: number }; bannerText: string; autoCollapse: boolean } [] = []; - */ - 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; - /** - * Returns JSON-encoded value of the type TextInsertion. - */ - getDocCommentTemplateAtPosition(fileName: string, position: number): string; - /** - * Returns JSON-encoded boolean to indicate whether we should support brace location - * at the current position. - * E.g. we don't want brace completion inside string-literals, comments, etc. - */ - isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; - /** - * Returns a JSON-encoded TextSpan | undefined indicating the range of the enclosing comment, if it exists. - */ - getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): 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 | undefined; - 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?: ReadonlyArray, exclude?: string[], include?: string[], depth?: number): string[]; - readFile(path: string, encoding?: string): string | undefined; - fileExists(path: string): boolean; - } - class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost, JsTyping.TypingResolutionHost { - private shimHost; - directoryExists: (directoryName: string) => boolean; - realpath: (path: string) => string; - useCaseSensitiveFileNames: boolean; - constructor(shimHost: CoreServicesShimHost); - readDirectory(rootDir: string, extensions: ReadonlyArray, exclude: ReadonlyArray, include: ReadonlyArray, depth?: number): string[]; - fileExists(fileName: string): boolean; - readFile(fileName: string): string | undefined; - getDirectories(path: string): string[]; - } - interface RealizedDiagnostic { - message: string; - start: number; - length: number; - category: string; - code: number; - reportsUnnecessary?: {}; - } - function realizeDiagnostics(diagnostics: ReadonlyArray, newLine: string): RealizedDiagnostic[]; - class TypeScriptServicesFactory implements ShimFactory { - private _shims; - private documentRegistry; - getServicesVersion(): string; - createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim; - createClassifierShim(logger: Logger): ClassifierShim; - createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim; - close(): void; - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; - } -} -declare namespace TypeScript.Services { - const TypeScriptServicesFactory: typeof ts.TypeScriptServicesFactory; -} -declare const toolsVersion = "3.0"; -//# sourceMappingURL=services.d.ts.map declare namespace ts.server { interface CompressedData { length: number; @@ -12173,6 +5714,7 @@ declare namespace ts.server { Perf = "Perf" } namespace Msg { + /** @deprecated Only here for backwards-compatibility. Prefer just `Msg`. */ type Types = Msg; } function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, cachePath?: string): DiscoverTypings; @@ -12197,10 +5739,16 @@ declare namespace ts.server { function createNormalizedPathMap(): NormalizedPathMap; interface ProjectOptions { configHasExtendsProperty: boolean; + /** + * true if config file explicitly listed files + */ configHasFilesProperty: boolean; configHasIncludeProperty: boolean; configHasExcludeProperty: boolean; projectReferences: ReadonlyArray | undefined; + /** + * these fields can be present in the project file + */ files?: string[]; wildcardDirectories?: Map; compilerOptions?: CompilerOptions; @@ -12211,87 +5759,49 @@ declare namespace ts.server { function makeInferredProjectName(counter: number): string; function createSortedArray(): SortedArray; } -declare namespace ts.server { - class ThrottledOperations { - private readonly host; - private readonly pendingTimeouts; - private readonly logger?; - constructor(host: ServerHost, logger: Logger); - schedule(operationId: string, delay: number, cb: () => void): void; - private static run; - } - 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; - } - function getBaseConfigFileName(configFilePath: NormalizedPath): "tsconfig.json" | "jsconfig.json" | undefined; - function removeSorted(array: SortedArray, remove: T, compare: Comparer): void; - function toSortedArray(arr: string[]): SortedArray; - function toSortedArray(arr: T[], comparer: Comparer): SortedArray; - function toDeduplicatedSortedArray(arr: string[]): SortedArray; - function indent(str: string): string; - function stringifyIndented(json: {}): string; -} +/** + * Declaration module describing the TypeScript Server protocol + */ declare namespace ts.server.protocol { enum CommandTypes { JsxClosingTag = "jsxClosingTag", Brace = "brace", - BraceFull = "brace-full", BraceCompletion = "braceCompletion", GetSpanOfEnclosingComment = "getSpanOfEnclosingComment", Change = "change", Close = "close", + /** @deprecated Prefer CompletionInfo -- see comment on CompletionsResponse */ Completions = "completions", CompletionInfo = "completionInfo", - CompletionsFull = "completions-full", CompletionDetails = "completionEntryDetails", - CompletionDetailsFull = "completionEntryDetails-full", CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList", CompileOnSaveEmitFile = "compileOnSaveEmitFile", Configure = "configure", Definition = "definition", - DefinitionFull = "definition-full", DefinitionAndBoundSpan = "definitionAndBoundSpan", - DefinitionAndBoundSpanFull = "definitionAndBoundSpan-full", Implementation = "implementation", - ImplementationFull = "implementation-full", Exit = "exit", Format = "format", Formatonkey = "formatonkey", - FormatFull = "format-full", - FormatonkeyFull = "formatonkey-full", - FormatRangeFull = "formatRange-full", Geterr = "geterr", GeterrForProject = "geterrForProject", SemanticDiagnosticsSync = "semanticDiagnosticsSync", SyntacticDiagnosticsSync = "syntacticDiagnosticsSync", SuggestionDiagnosticsSync = "suggestionDiagnosticsSync", NavBar = "navbar", - NavBarFull = "navbar-full", Navto = "navto", - NavtoFull = "navto-full", NavTree = "navtree", NavTreeFull = "navtree-full", + /** @deprecated */ Occurrences = "occurrences", DocumentHighlights = "documentHighlights", - DocumentHighlightsFull = "documentHighlights-full", Open = "open", Quickinfo = "quickinfo", - QuickinfoFull = "quickinfo-full", References = "references", - ReferencesFull = "references-full", Reload = "reload", Rename = "rename", - RenameInfoFull = "rename-full", - RenameLocationsFull = "renameLocations-full", Saveto = "saveto", SignatureHelp = "signatureHelp", - SignatureHelpFull = "signatureHelp-full", Status = "status", TypeDefinition = "typeDefinition", ProjectInfo = "projectInfo", @@ -12300,59 +5810,101 @@ declare namespace ts.server.protocol { OpenExternalProject = "openExternalProject", OpenExternalProjects = "openExternalProjects", CloseExternalProject = "closeExternalProject", - SynchronizeProjectList = "synchronizeProjectList", - ApplyChangedToOpenFiles = "applyChangedToOpenFiles", - EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full", - Cleanup = "cleanup", GetOutliningSpans = "getOutliningSpans", - GetOutliningSpansFull = "outliningSpans", TodoComments = "todoComments", Indentation = "indentation", DocCommentTemplate = "docCommentTemplate", - CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full", - NameOrDottedNameSpan = "nameOrDottedNameSpan", - BreakpointStatement = "breakpointStatement", CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects", GetCodeFixes = "getCodeFixes", - GetCodeFixesFull = "getCodeFixes-full", GetCombinedCodeFix = "getCombinedCodeFix", - GetCombinedCodeFixFull = "getCombinedCodeFix-full", ApplyCodeActionCommand = "applyCodeActionCommand", GetSupportedCodeFixes = "getSupportedCodeFixes", GetApplicableRefactors = "getApplicableRefactors", GetEditsForRefactor = "getEditsForRefactor", - GetEditsForRefactorFull = "getEditsForRefactor-full", OrganizeImports = "organizeImports", - OrganizeImportsFull = "organizeImports-full", - GetEditsForFileRename = "getEditsForFileRename", - GetEditsForFileRenameFull = "getEditsForFileRename-full" + GetEditsForFileRename = "getEditsForFileRename" } + /** + * A TypeScript Server message + */ interface Message { + /** + * Sequence number of the message + */ seq: number; + /** + * One of "request", "response", or "event" + */ type: "request" | "response" | "event"; } + /** + * Client-initiated request message + */ interface Request extends Message { type: "request"; + /** + * The command to execute + */ command: string; + /** + * Object containing arguments for the command + */ arguments?: any; } + /** + * Request to reload the project structure for all the opened files + */ interface ReloadProjectsRequest extends Message { command: CommandTypes.ReloadProjects; } + /** + * Server-initiated event message + */ interface Event extends Message { type: "event"; + /** + * Name of event + */ event: string; + /** + * Event-specific information + */ body?: any; } + /** + * Response by server to client request message. + */ interface Response extends Message { type: "response"; + /** + * Sequence number of the request message. + */ request_seq: number; + /** + * Outcome of the request. + */ success: boolean; + /** + * The command requested. + */ command: string; + /** + * If success === false, this should always be provided. + * Otherwise, may (or may not) contain a success message. + */ message?: string; + /** + * Contains message body if success === true. + */ body?: any; } + /** + * Arguments for FileRequest messages. + */ interface FileRequestArgs { + /** + * The file for the request (absolute pathname required). + */ file: string; projectFileName?: string; } @@ -12360,85 +5912,183 @@ declare namespace ts.server.protocol { command: CommandTypes.Status; } interface StatusResponseBody { + /** + * The TypeScript version (`ts.version`). + */ version: string; } + /** + * Response to StatusRequest + */ interface StatusResponse extends Response { body: StatusResponseBody; } + /** + * Requests a JS Doc comment template for a given position + */ interface DocCommentTemplateRequest extends FileLocationRequest { command: CommandTypes.DocCommentTemplate; } + /** + * Response to DocCommentTemplateRequest + */ interface DocCommandTemplateResponse extends Response { body?: TextInsertion; } + /** + * A request to get TODO comments from the file + */ interface TodoCommentRequest extends FileRequest { command: CommandTypes.TodoComments; arguments: TodoCommentRequestArgs; } + /** + * Arguments for TodoCommentRequest request. + */ interface TodoCommentRequestArgs extends FileRequestArgs { + /** + * Array of target TodoCommentDescriptors that describes TODO comments to be found + */ descriptors: TodoCommentDescriptor[]; } + /** + * Response for TodoCommentRequest request. + */ interface TodoCommentsResponse extends Response { body?: TodoComment[]; } + /** + * A request to determine if the caret is inside a comment. + */ interface SpanOfEnclosingCommentRequest extends FileLocationRequest { command: CommandTypes.GetSpanOfEnclosingComment; arguments: SpanOfEnclosingCommentRequestArgs; } interface SpanOfEnclosingCommentRequestArgs extends FileLocationRequestArgs { + /** + * Requires that the enclosing span be a multi-line comment, or else the request returns undefined. + */ onlyMultiLine: boolean; } + /** + * Request to obtain outlining spans in file. + */ interface OutliningSpansRequest extends FileRequest { command: CommandTypes.GetOutliningSpans; } interface OutliningSpan { + /** The span of the document to actually collapse. */ textSpan: TextSpan; + /** The span of the document to display when the user hovers over the collapsed span. */ hintSpan: TextSpan; + /** The text to display in the editor for the collapsed region. */ bannerText: string; + /** + * Whether or not this region should be automatically collapsed when + * the 'Collapse to Definitions' command is invoked. + */ autoCollapse: boolean; + /** + * Classification of the contents of the span + */ kind: OutliningSpanKind; } + /** + * Response to OutliningSpansRequest request. + */ interface OutliningSpansResponse extends Response { body?: OutliningSpan[]; } - interface OutliningSpansRequestFull extends FileRequest { - command: CommandTypes.GetOutliningSpansFull; - } - interface OutliningSpansResponseFull extends Response { - body?: ts.OutliningSpan[]; - } + /** + * A request to get indentation for a location in file + */ interface IndentationRequest extends FileLocationRequest { command: CommandTypes.Indentation; arguments: IndentationRequestArgs; } + /** + * Response for IndentationRequest request. + */ interface IndentationResponse extends Response { body?: IndentationResult; } + /** + * Indentation result representing where indentation should be placed + */ interface IndentationResult { + /** + * The base position in the document that the indent should be relative to + */ position: number; + /** + * The number of columns the indent should be at relative to the position's column. + */ indentation: number; } + /** + * Arguments for IndentationRequest request. + */ interface IndentationRequestArgs extends FileLocationRequestArgs { + /** + * An optional set of settings to be used when computing indentation. + * If argument is omitted - then it will use settings for file that were previously set via 'configure' request or global settings. + */ options?: EditorSettings; } + /** + * Arguments for ProjectInfoRequest request. + */ interface ProjectInfoRequestArgs extends FileRequestArgs { + /** + * Indicate if the file name list of the project is needed + */ needFileNameList: boolean; } + /** + * A request to get the project information of the current file. + */ interface ProjectInfoRequest extends Request { command: CommandTypes.ProjectInfo; arguments: ProjectInfoRequestArgs; } + /** + * A request to retrieve compiler options diagnostics for a project + */ interface CompilerOptionsDiagnosticsRequest extends Request { arguments: CompilerOptionsDiagnosticsRequestArgs; } + /** + * Arguments for CompilerOptionsDiagnosticsRequest request. + */ interface CompilerOptionsDiagnosticsRequestArgs { + /** + * Name of the project to retrieve compiler options diagnostics. + */ projectFileName: string; } + /** + * Response message body for "projectInfo" request + */ interface ProjectInfo { + /** + * For configured project, this is the normalized path of the 'tsconfig.json' file + * For inferred project, this is undefined + */ configFileName: string; + /** + * The list of normalized file name in the project, including 'lib.d.ts' + */ fileNames?: string[]; + /** + * Indicates if the project has a active language service instance + */ languageServiceDisabled?: boolean; } + /** + * Represents diagnostic info that includes location of diagnostic in two forms + * - start position and length of the error span + * - startLocation and endLocation - a pair of Location objects that store start/end line and offset of the error span. + */ interface DiagnosticWithLinePosition { message: string; start: number; @@ -12447,43 +6097,99 @@ declare namespace ts.server.protocol { endLocation: Location; category: string; code: number; + /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; relatedInformation?: DiagnosticRelatedInformation[]; } + /** + * Response message for "projectInfo" request + */ interface ProjectInfoResponse extends Response { body?: ProjectInfo; } + /** + * Request whose sole parameter is a file name. + */ interface FileRequest extends Request { arguments: FileRequestArgs; } + /** + * Instances of this interface specify a location in a source file: + * (file, line, character offset), where line and character offset are 1-based. + */ interface FileLocationRequestArgs extends FileRequestArgs { + /** + * The line number for the request (1-based). + */ line: number; + /** + * The character offset (on the line) for the request (1-based). + */ offset: number; - position?: number; } type FileLocationOrRangeRequestArgs = FileLocationRequestArgs | FileRangeRequestArgs; + /** + * Request refactorings at a given position or selection area. + */ interface GetApplicableRefactorsRequest extends Request { command: CommandTypes.GetApplicableRefactors; arguments: GetApplicableRefactorsRequestArgs; } type GetApplicableRefactorsRequestArgs = FileLocationOrRangeRequestArgs; + /** + * Response is a list of available refactorings. + * Each refactoring exposes one or more "Actions"; a user selects one action to invoke a refactoring + */ interface GetApplicableRefactorsResponse extends Response { body?: ApplicableRefactorInfo[]; } + /** + * A set of one or more available refactoring actions, grouped under a parent refactoring. + */ interface ApplicableRefactorInfo { + /** + * The programmatic name of the refactoring + */ name: string; + /** + * A description of this refactoring category to show to the user. + * If the refactoring gets inlined (see below), this text will not be visible. + */ description: string; + /** + * Inlineable refactorings can have their actions hoisted out to the top level + * of a context menu. Non-inlineanable refactorings should always be shown inside + * their parent grouping. + * + * If not specified, this value is assumed to be 'true' + */ inlineable?: boolean; actions: RefactorActionInfo[]; } + /** + * Represents a single refactoring action - for example, the "Extract Method..." refactor might + * offer several actions, each corresponding to a surround class or closure to extract into. + */ interface RefactorActionInfo { + /** + * The programmatic name of the refactoring action + */ name: string; + /** + * A description of this refactoring action to show to the user. + * If the parent refactoring is inlined away, this will be the only text shown, + * so this description should make sense by itself if the parent is inlineable=true + */ description: string; } interface GetEditsForRefactorRequest extends Request { command: CommandTypes.GetEditsForRefactor; arguments: GetEditsForRefactorRequestArgs; } + /** + * Request the edits that a particular refactoring action produces. + * Callers must specify the name of the refactor and the name of the action. + */ type GetEditsForRefactorRequestArgs = FileLocationOrRangeRequestArgs & { refactor: string; action: string; @@ -12493,9 +6199,19 @@ declare namespace ts.server.protocol { } interface RefactorEditInfo { edits: FileCodeEdits[]; + /** + * An optional location where the editor should start a rename operation once + * the refactoring edits have been applied + */ renameLocation?: Location; renameFilename?: string; } + /** + * Organize imports by: + * 1) Removing unused imports + * 2) Coalescing imports from the same module + * 3) Sorting imports + */ interface OrganizeImportsRequest extends Request { command: CommandTypes.OrganizeImports; arguments: OrganizeImportsRequestArgs; @@ -12511,6 +6227,7 @@ declare namespace ts.server.protocol { command: CommandTypes.GetEditsForFileRename; arguments: GetEditsForFileRenameRequestArgs; } + /** Note: Paths may also be directories. */ interface GetEditsForFileRenameRequestArgs { readonly oldFilePath: string; readonly newFilePath: string; @@ -12518,6 +6235,9 @@ declare namespace ts.server.protocol { interface GetEditsForFileRenameResponse extends Response { body: ReadonlyArray; } + /** + * Request for the available codefixes at a specific position. + */ interface CodeFixRequest extends Request { command: CommandTypes.GetCodeFixes; arguments: CodeFixRequestArgs; @@ -12536,15 +6256,31 @@ declare namespace ts.server.protocol { interface ApplyCodeActionCommandResponse extends Response { } interface FileRangeRequestArgs extends FileRequestArgs { + /** + * The line number for the request (1-based). + */ startLine: number; + /** + * The character offset (on the line) for the request (1-based). + */ startOffset: number; - startPosition?: number; + /** + * The line number for the request (1-based). + */ endLine: number; + /** + * The character offset (on the line) for the request (1-based). + */ endOffset: number; - endPosition?: number; } + /** + * Instances of this interface specify errorcodes on a specific location in a sourcefile. + */ interface CodeFixRequestArgs extends FileRangeRequestArgs { - errorCodes?: ReadonlyArray; + /** + * Errorcodes we want to get the fixes for. + */ + errorCodes: ReadonlyArray; } interface GetCombinedCodeFixRequestArgs { scope: GetCombinedCodeFixScope; @@ -12555,71 +6291,157 @@ declare namespace ts.server.protocol { args: FileRequestArgs; } interface ApplyCodeActionCommandRequestArgs { + /** May also be an array of commands. */ command: {}; } + /** + * Response for GetCodeFixes request. + */ interface GetCodeFixesResponse extends Response { body?: CodeAction[]; } + /** + * A request whose arguments specify a file location (file, line, col). + */ interface FileLocationRequest extends FileRequest { arguments: FileLocationRequestArgs; } + /** + * A request to get codes of supported code fixes. + */ interface GetSupportedCodeFixesRequest extends Request { command: CommandTypes.GetSupportedCodeFixes; } + /** + * A response for GetSupportedCodeFixesRequest request. + */ interface GetSupportedCodeFixesResponse extends Response { + /** + * List of error codes supported by the server. + */ body?: string[]; } - interface EncodedSemanticClassificationsRequest extends FileRequest { - arguments: EncodedSemanticClassificationsRequestArgs; - } + /** + * Arguments for EncodedSemanticClassificationsRequest request. + */ interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + /** + * Start position of the span. + */ start: number; + /** + * Length of the span. + */ length: number; } + /** + * Arguments in document highlight request; include: filesToSearch, file, + * line, offset. + */ interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + /** + * List of files to search for document highlights. + */ filesToSearch: string[]; } + /** + * Go to definition request; value of command field is + * "definition". Return response giving the file locations that + * define the symbol found in file at location line, col. + */ interface DefinitionRequest extends FileLocationRequest { command: CommandTypes.Definition; } + interface DefinitionAndBoundSpanRequest extends FileLocationRequest { + readonly command: CommandTypes.DefinitionAndBoundSpan; + } + interface DefinitionAndBoundSpanResponse extends Response { + readonly body: DefinitionInfoAndBoundSpan; + } + /** + * Go to type request; value of command field is + * "typeDefinition". Return response giving the file locations that + * define the type for the symbol found in file at location line, col. + */ interface TypeDefinitionRequest extends FileLocationRequest { command: CommandTypes.TypeDefinition; } + /** + * Go to implementation request; value of command field is + * "implementation". Return response giving the file locations that + * implement the symbol found in file at location line, col. + */ interface ImplementationRequest extends FileLocationRequest { command: CommandTypes.Implementation; } + /** + * Location in source code expressed as (one-based) line and (one-based) column offset. + */ interface Location { line: number; offset: number; } + /** + * Object found in response messages defining a span of text in source code. + */ interface TextSpan { + /** + * First character of the definition. + */ start: Location; + /** + * One character past last character of the definition. + */ end: Location; } + /** + * Object found in response messages defining a span of text in a specific source file. + */ interface FileSpan extends TextSpan { + /** + * File containing text span. + */ file: string; } interface DefinitionInfoAndBoundSpan { definitions: ReadonlyArray; textSpan: TextSpan; } + /** + * Definition response message. Gives text range for definition. + */ interface DefinitionResponse extends Response { body?: FileSpan[]; } interface DefinitionInfoAndBoundSpanReponse extends Response { body?: DefinitionInfoAndBoundSpan; } + /** + * Definition response message. Gives text range for definition. + */ interface TypeDefinitionResponse extends Response { body?: FileSpan[]; } + /** + * Implementation response message. Gives text range for implementations. + */ interface ImplementationResponse extends Response { body?: FileSpan[]; } + /** + * Request to get brace completion for a location in the file. + */ interface BraceCompletionRequest extends FileLocationRequest { command: CommandTypes.BraceCompletion; arguments: BraceCompletionRequestArgs; } + /** + * Argument for BraceCompletionRequest request. + */ interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + /** + * Kind of opening brace + */ openingBrace: string; } interface JsxClosingTagRequest extends FileLocationRequest { @@ -12631,240 +6453,596 @@ declare namespace ts.server.protocol { interface JsxClosingTagResponse extends Response { readonly body: TextInsertion; } + /** + * @deprecated + * Get occurrences request; value of command field is + * "occurrences". Return response giving spans that are relevant + * in the file at a given line and column. + */ interface OccurrencesRequest extends FileLocationRequest { command: CommandTypes.Occurrences; } + /** @deprecated */ interface OccurrencesResponseItem extends FileSpan { + /** + * True if the occurrence is a write location, false otherwise. + */ isWriteAccess: boolean; + /** + * True if the occurrence is in a string, undefined otherwise; + */ isInString?: true; } + /** @deprecated */ interface OccurrencesResponse extends Response { body?: OccurrencesResponseItem[]; } + /** + * Get document highlights request; value of command field is + * "documentHighlights". Return response giving spans that are relevant + * in the file at a given line and column. + */ interface DocumentHighlightsRequest extends FileLocationRequest { command: CommandTypes.DocumentHighlights; arguments: DocumentHighlightsRequestArgs; } + /** + * Span augmented with extra information that denotes the kind of the highlighting to be used for span. + */ interface HighlightSpan extends TextSpan { kind: HighlightSpanKind; } + /** + * Represents a set of highligh spans for a give name + */ interface DocumentHighlightsItem { + /** + * File containing highlight spans. + */ file: string; + /** + * Spans to highlight in file. + */ highlightSpans: HighlightSpan[]; } + /** + * Response for a DocumentHighlightsRequest request. + */ interface DocumentHighlightsResponse extends Response { body?: DocumentHighlightsItem[]; } + /** + * Find references request; value of command field is + * "references". Return response giving the file locations that + * reference the symbol found in file at location line, col. + */ interface ReferencesRequest extends FileLocationRequest { command: CommandTypes.References; } interface ReferencesResponseItem extends FileSpan { + /** Text of line containing the reference. Including this + * with the response avoids latency of editor loading files + * to show text of reference line (the server already has + * loaded the referencing files). + */ lineText: string; + /** + * True if reference is a write location, false otherwise. + */ isWriteAccess: boolean; + /** + * True if reference is a definition, false otherwise. + */ isDefinition: boolean; } + /** + * The body of a "references" response message. + */ interface ReferencesResponseBody { + /** + * The file locations referencing the symbol. + */ refs: ReferencesResponseItem[]; + /** + * The name of the symbol. + */ symbolName: string; + /** + * The start character offset of the symbol (on the line provided by the references request). + */ symbolStartOffset: number; + /** + * The full display name of the symbol. + */ symbolDisplayString: string; } + /** + * Response to "references" request. + */ interface ReferencesResponse extends Response { body?: ReferencesResponseBody; } + /** + * Argument for RenameRequest request. + */ interface RenameRequestArgs extends FileLocationRequestArgs { + /** + * Should text at specified location be found/changed in comments? + */ findInComments?: boolean; + /** + * Should text at specified location be found/changed in strings? + */ findInStrings?: boolean; } + /** + * Rename request; value of command field is "rename". Return + * response giving the file locations that reference the symbol + * found in file at location line, col. Also return full display + * name of the symbol so that client can print it unambiguously. + */ interface RenameRequest extends FileLocationRequest { command: CommandTypes.Rename; arguments: RenameRequestArgs; } + /** + * Information about the item to be renamed. + */ interface RenameInfo { + /** + * True if item can be renamed. + */ canRename: boolean; + /** + * Error message if item can not be renamed. + */ localizedErrorMessage?: string; + /** + * Display name of the item to be renamed. + */ displayName: string; + /** + * Full display name of item to be renamed. + */ fullDisplayName: string; + /** + * The items's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: ScriptElementKind; + /** + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; } + /** + * A group of text spans, all in 'file'. + */ interface SpanGroup { + /** The file to which the spans apply */ file: string; + /** The text spans in this group */ locs: TextSpan[]; } interface RenameResponseBody { + /** + * Information about the item to be renamed. + */ info: RenameInfo; + /** + * An array of span groups (one per file) that refer to the item to be renamed. + */ locs: ReadonlyArray; } + /** + * Rename response message. + */ interface RenameResponse extends Response { body?: RenameResponseBody; } + /** + * Represents a file in external project. + * External project is project whose set of files, compilation options and open\close state + * is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio). + * External project will exist even if all files in it are closed and should be closed 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. + */ interface ExternalFile { + /** + * Name of file file + */ fileName: string; + /** + * Script kind of the file + */ scriptKind?: ScriptKindName | ts.ScriptKind; + /** + * Whether file has mixed content (i.e. .cshtml file that combines html markup with C#/JavaScript) + */ hasMixedContent?: boolean; + /** + * Content of the file + */ content?: string; } + /** + * Represent an external project + */ interface ExternalProject { + /** + * Project name + */ projectFileName: string; + /** + * List of root files in project + */ rootFiles: ExternalFile[]; + /** + * Compiler options for the project + */ options: ExternalProjectCompilerOptions; + /** + * @deprecated typingOptions. Use typeAcquisition instead + */ typingOptions?: TypeAcquisition; + /** + * Explicitly specified type acquisition for the project + */ typeAcquisition?: TypeAcquisition; } interface CompileOnSaveMixin { + /** + * If compile on save is enabled for the project + */ compileOnSave?: boolean; } + /** + * For external projects, some of the project settings are sent together with + * compiler settings. + */ type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; - interface ProjectVersionInfo { - projectName: string; - isInferred: boolean; - version: number; - options: ts.CompilerOptions; - languageServiceDisabled: boolean; - lastFileExceededProgramSize?: string; - } + /** + * Represents a set of changes that happen in project + */ interface ProjectChanges { + /** + * List of added files + */ added: string[]; + /** + * List of removed files + */ removed: string[]; + /** + * List of updated files + */ updated: string[]; } - interface ProjectFiles { - info?: ProjectVersionInfo; - files?: string[]; - changes?: ProjectChanges; - } - interface ProjectFilesWithDiagnostics extends ProjectFiles { - projectErrors: DiagnosticWithLinePosition[]; - } - interface ChangedOpenFile { - fileName: string; - changes: ts.TextChange[]; - } + /** + * Information found in a configure request. + */ interface ConfigureRequestArguments { + /** + * Information about the host, for example 'Emacs 24.4' or + * 'Sublime Text version 3075' + */ hostInfo?: string; + /** + * If present, tab settings apply only to this file. + */ file?: string; + /** + * The format options to use during formatting and other code editing features. + */ formatOptions?: FormatCodeSettings; preferences?: UserPreferences; + /** + * The host's additional supported .js file extensions + */ extraFileExtensions?: FileExtensionInfo[]; } + /** + * Configure request; value of command field is "configure". Specifies + * host information, such as host type, tab size, and indent size. + */ interface ConfigureRequest extends Request { command: CommandTypes.Configure; arguments: ConfigureRequestArguments; } + /** + * Response to "configure" request. This is just an acknowledgement, so + * no body field is required. + */ interface ConfigureResponse extends Response { } + /** + * Information found in an "open" request. + */ interface OpenRequestArgs extends FileRequestArgs { + /** + * Used when a version of the file content is known to be more up to date than the one on disk. + * Then the known content will be used upon opening instead of the disk copy + */ fileContent?: string; + /** + * Used to specify the script kind of the file explicitly. It could be one of the following: + * "TS", "JS", "TSX", "JSX" + */ scriptKindName?: ScriptKindName; + /** + * Used to limit the searching for project config file. If given the searching will stop at this + * root path; otherwise it will go all the way up to the dist root path. + */ projectRootPath?: string; } type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + /** + * Open request; value of command field is "open". Notify the + * server that the client has file open. The server will not + * monitor the filesystem for changes in this file and will assume + * that the client is updating the server (using the change and/or + * reload messages) when the file changes. Server does not currently + * send a response to an open request. + */ interface OpenRequest extends Request { command: CommandTypes.Open; arguments: OpenRequestArgs; } + /** + * Request to open or update external project + */ interface OpenExternalProjectRequest extends Request { command: CommandTypes.OpenExternalProject; arguments: OpenExternalProjectArgs; } + /** + * Arguments to OpenExternalProjectRequest request + */ type OpenExternalProjectArgs = ExternalProject; + /** + * Request to open multiple external projects + */ interface OpenExternalProjectsRequest extends Request { command: CommandTypes.OpenExternalProjects; arguments: OpenExternalProjectsArgs; } + /** + * Arguments to OpenExternalProjectsRequest + */ interface OpenExternalProjectsArgs { + /** + * List of external projects to open or update + */ projects: ExternalProject[]; } + /** + * Response to OpenExternalProjectRequest request. This is just an acknowledgement, so + * no body field is required. + */ interface OpenExternalProjectResponse extends Response { } + /** + * Response to OpenExternalProjectsRequest request. This is just an acknowledgement, so + * no body field is required. + */ interface OpenExternalProjectsResponse extends Response { } + /** + * Request to close external project. + */ interface CloseExternalProjectRequest extends Request { command: CommandTypes.CloseExternalProject; arguments: CloseExternalProjectRequestArgs; } + /** + * Arguments to CloseExternalProjectRequest request + */ interface CloseExternalProjectRequestArgs { + /** + * Name of the project to close + */ projectFileName: string; } + /** + * Response to CloseExternalProjectRequest request. This is just an acknowledgement, so + * no body field is required. + */ interface CloseExternalProjectResponse extends Response { } - 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[]; - } + /** + * Request to set compiler options for inferred projects. + * External projects are opened / closed explicitly. + * Configured projects are opened when user opens loose file that has 'tsconfig.json' or 'jsconfig.json' anywhere in one of containing folders. + * This configuration file will be used to obtain a list of files and configuration settings for the project. + * Inferred projects are created when user opens a loose file that is not the part of external project + * or configured project and will contain only open file and transitive closure of referenced files if 'useOneInferredProject' is false, + * or all open loose files and its transitive closure of referenced files if 'useOneInferredProject' is true. + */ interface SetCompilerOptionsForInferredProjectsRequest extends Request { command: CommandTypes.CompilerOptionsForInferredProjects; arguments: SetCompilerOptionsForInferredProjectsArgs; } + /** + * Argument for SetCompilerOptionsForInferredProjectsRequest request. + */ interface SetCompilerOptionsForInferredProjectsArgs { + /** + * Compiler options to be used with inferred projects. + */ options: ExternalProjectCompilerOptions; + /** + * Specifies the project root path used to scope compiler options. + * It is an error to provide this property if the server has not been started with + * `useInferredProjectPerProjectRoot` enabled. + */ projectRootPath?: string; } + /** + * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so + * no body field is required. + */ interface SetCompilerOptionsForInferredProjectsResponse extends Response { } + /** + * Exit request; value of command field is "exit". Ask the server process + * to exit. + */ interface ExitRequest extends Request { command: CommandTypes.Exit; } + /** + * Close request; value of command field is "close". Notify the + * server that the client has closed a previously open file. If + * file is still referenced by open files, the server will resume + * monitoring the filesystem for changes to file. Server does not + * currently send a response to a close request. + */ interface CloseRequest extends FileRequest { command: CommandTypes.Close; } + /** + * Request to obtain the list of files that should be regenerated if target file is recompiled. + * NOTE: this us query-only operation and does not generate any output on disk. + */ interface CompileOnSaveAffectedFileListRequest extends FileRequest { command: CommandTypes.CompileOnSaveAffectedFileList; } + /** + * Contains a list of files that should be regenerated in a project + */ interface CompileOnSaveAffectedFileListSingleProject { + /** + * Project name + */ projectFileName: string; + /** + * List of files names that should be recompiled + */ fileNames: string[]; + /** + * true if project uses outFile or out compiler option + */ projectUsesOutFile: boolean; } + /** + * Response for CompileOnSaveAffectedFileListRequest request; + */ interface CompileOnSaveAffectedFileListResponse extends Response { body: CompileOnSaveAffectedFileListSingleProject[]; } + /** + * Request to recompile the file. All generated outputs (.js, .d.ts or .js.map files) is written on disk. + */ interface CompileOnSaveEmitFileRequest extends FileRequest { command: CommandTypes.CompileOnSaveEmitFile; arguments: CompileOnSaveEmitFileRequestArgs; } + /** + * Arguments for CompileOnSaveEmitFileRequest + */ interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + /** + * if true - then file should be recompiled even if it does not have any changes. + */ forced?: boolean; } + /** + * Quickinfo request; value of command field is + * "quickinfo". Return response giving a quick type and + * documentation string for the symbol found in file at location + * line, col. + */ interface QuickInfoRequest extends FileLocationRequest { command: CommandTypes.Quickinfo; } + /** + * Body of QuickInfoResponse. + */ interface QuickInfoResponseBody { + /** + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: ScriptElementKind; + /** + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; + /** + * Starting file location of symbol. + */ start: Location; + /** + * One past last character of symbol. + */ end: Location; + /** + * Type and kind of symbol. + */ displayString: string; + /** + * Documentation associated with symbol. + */ documentation: string; + /** + * JSDoc tags associated with symbol. + */ tags: JSDocTagInfo[]; } + /** + * Quickinfo response message. + */ interface QuickInfoResponse extends Response { body?: QuickInfoResponseBody; } + /** + * Arguments for format messages. + */ interface FormatRequestArgs extends FileLocationRequestArgs { + /** + * Last line of range for which to format text in file. + */ endLine: number; + /** + * Character offset on last line of range for which to format text in file. + */ endOffset: number; - endPosition?: number; + /** + * Format options to be used. + */ options?: FormatCodeSettings; } + /** + * Format request; value of command field is "format". Return + * response giving zero or more edit instructions. The edit + * instructions will be sorted in file order. Applying the edit + * instructions in reverse to file will result in correctly + * reformatted text. + */ interface FormatRequest extends FileLocationRequest { command: CommandTypes.Format; arguments: FormatRequestArgs; } + /** + * Object found in response messages defining an editing + * instruction for a span of text in source code. The effect of + * this instruction is to replace the text starting at start and + * ending one character before end with newText. For an insertion, + * the text span is empty. For a deletion, newText is empty. + */ interface CodeEdit { + /** + * First character of the text span to edit. + */ start: Location; + /** + * One character past last character of the text span to edit. + */ end: Location; + /** + * Replace the span defined above with this string (may be + * the empty string). + */ newText: string; } interface FileCodeEdits { @@ -12872,11 +7050,15 @@ declare namespace ts.server.protocol { textChanges: CodeEdit[]; } interface CodeFixResponse extends Response { + /** The code actions that are available */ body?: CodeFixAction[]; } interface CodeAction { + /** Description of the code action to display in the UI of the editor */ description: string; + /** Text changes to apply to each file as part of the code action */ changes: FileCodeEdits[]; + /** A command is an opaque object that should be passed to `ApplyCodeActionCommandRequestArgs` without modification. */ commands?: {}[]; } interface CombinedCodeActions { @@ -12884,68 +7066,200 @@ declare namespace ts.server.protocol { commands?: ReadonlyArray<{}>; } interface CodeFixAction extends CodeAction { + /** Short name to identify the fix, for use by telemetry. */ fixName: string; + /** + * If present, one may call 'getCombinedCodeFix' with this fixId. + * This may be omitted to indicate that the code fix can't be applied in a group. + */ fixId?: {}; + /** Should be present if and only if 'fixId' is. */ fixAllDescription?: string; } + /** + * Format and format on key response message. + */ interface FormatResponse extends Response { body?: CodeEdit[]; } + /** + * Arguments for format on key messages. + */ interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + /** + * Key pressed (';', '\n', or '}'). + */ key: string; options?: FormatCodeSettings; } + /** + * Format on key request; value of command field is + * "formatonkey". Given file location and key typed (as string), + * return response giving zero or more edit instructions. The + * edit instructions will be sorted in file order. Applying the + * edit instructions in reverse to file will result in correctly + * reformatted text. + */ interface FormatOnKeyRequest extends FileLocationRequest { command: CommandTypes.Formatonkey; arguments: FormatOnKeyRequestArgs; } type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; + /** + * Arguments for completions messages. + */ interface CompletionsRequestArgs extends FileLocationRequestArgs { + /** + * Optional prefix to apply to possible completions. + */ prefix?: string; + /** + * Character that was responsible for triggering completion. + * Should be `undefined` if a user manually requested completion. + */ triggerCharacter?: CompletionsTriggerCharacter; + /** + * @deprecated Use UserPreferences.includeCompletionsForModuleExports + */ includeExternalModuleExports?: boolean; + /** + * @deprecated Use UserPreferences.includeCompletionsWithInsertText + */ includeInsertTextCompletions?: boolean; } + /** + * Completions request; value of command field is "completions". + * Given a file location (file, line, col) and a prefix (which may + * be the empty string), return the possible completions that + * begin with prefix. + */ interface CompletionsRequest extends FileLocationRequest { command: CommandTypes.Completions; arguments: CompletionsRequestArgs; } + /** + * Arguments for completion details request. + */ interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + /** + * Names of one or more entries for which to obtain details. + */ entryNames: (string | CompletionEntryIdentifier)[]; } interface CompletionEntryIdentifier { name: string; source?: string; } + /** + * Completion entry details request; value of command field is + * "completionEntryDetails". Given a file location (file, line, + * col) and an array of completion entry names return more + * detailed information for each completion entry. + */ interface CompletionDetailsRequest extends FileLocationRequest { command: CommandTypes.CompletionDetails; arguments: CompletionDetailsRequestArgs; } + /** + * Part of a symbol description. + */ interface SymbolDisplayPart { + /** + * Text of an item describing the symbol. + */ text: string; + /** + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; } + /** + * An item found in a completion response. + */ interface CompletionEntry { + /** + * The symbol's name. + */ name: string; + /** + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: ScriptElementKind; + /** + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; + /** + * A string that is used for comparing completion items so that they can be ordered. This + * is often the same as the name but may be different in certain circumstances. + */ sortText: string; + /** + * Text to insert instead of `name`. + * This is used to support bracketed completions; If `name` might be "a-b" but `insertText` would be `["a-b"]`, + * coupled with `replacementSpan` to replace a dotted access with a bracket access. + */ insertText?: string; + /** + * An optional span that indicates the text to be replaced by this completion item. + * If present, this span should be used instead of the default one. + * It will be set if the required span differs from the one generated by the default replacement behavior. + */ replacementSpan?: TextSpan; + /** + * Indicates whether commiting this completion entry will require additional code actions to be + * made to avoid errors. The CompletionEntryDetails will have these actions. + */ hasAction?: true; + /** + * Identifier (not necessarily human-readable) identifying where this completion came from. + */ source?: string; + /** + * If true, this completion should be highlighted as recommended. There will only be one of these. + * This will be set when we know the user should write an expression with a certain type and that type is an enum or constructable class. + * Then either that enum/class or a namespace containing it will be the recommended symbol. + */ isRecommended?: true; } + /** + * Additional completion entry details, available on demand + */ interface CompletionEntryDetails { + /** + * The symbol's name. + */ name: string; + /** + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: ScriptElementKind; + /** + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; + /** + * Display parts of the symbol (similar to quick info). + */ displayParts: SymbolDisplayPart[]; + /** + * Documentation strings for the symbol. + */ documentation?: SymbolDisplayPart[]; + /** + * JSDoc tags for the symbol. + */ tags?: JSDocTagInfo[]; + /** + * The associated code actions for this entry + */ codeActions?: CodeAction[]; + /** + * Human-readable description of the `source` from the CompletionEntry. + */ source?: SymbolDisplayPart[]; } + /** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */ interface CompletionsResponse extends Response { body?: CompletionEntry[]; } @@ -12961,37 +7275,148 @@ declare namespace ts.server.protocol { interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } + /** + * Signature help information for a single parameter + */ interface SignatureHelpParameter { + /** + * The parameter's name + */ name: string; + /** + * Documentation of the parameter. + */ documentation: SymbolDisplayPart[]; + /** + * Display parts of the parameter. + */ displayParts: SymbolDisplayPart[]; + /** + * Whether the parameter is optional or not. + */ isOptional: boolean; } + /** + * Represents a single signature to show in signature help. + */ interface SignatureHelpItem { + /** + * Whether the signature accepts a variable number of arguments. + */ isVariadic: boolean; + /** + * The prefix display parts. + */ prefixDisplayParts: SymbolDisplayPart[]; + /** + * The suffix display parts. + */ suffixDisplayParts: SymbolDisplayPart[]; + /** + * The separator display parts. + */ separatorDisplayParts: SymbolDisplayPart[]; + /** + * The signature helps items for the parameters. + */ parameters: SignatureHelpParameter[]; + /** + * The signature's documentation + */ documentation: SymbolDisplayPart[]; + /** + * The signature's JSDoc tags + */ tags: JSDocTagInfo[]; } + /** + * Signature help items found in the response of a signature help request. + */ interface SignatureHelpItems { + /** + * The signature help items. + */ items: SignatureHelpItem[]; + /** + * The span for which signature help should appear on a signature + */ applicableSpan: TextSpan; + /** + * The item selected in the set of available help items. + */ selectedItemIndex: number; + /** + * The argument selected in the set of parameters. + */ argumentIndex: number; + /** + * The argument count + */ argumentCount: number; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + /** + * Arguments of a signature help request. + */ interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + /** + * Reason why signature help was invoked. + * See each individual possible + */ + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } + /** + * Signature help request; value of command field is "signatureHelp". + * Given a file location (file, line, col), return the signature + * help. + */ interface SignatureHelpRequest extends FileLocationRequest { command: CommandTypes.SignatureHelp; arguments: SignatureHelpRequestArgs; } + /** + * Response object for a SignatureHelpRequest. + */ interface SignatureHelpResponse extends Response { body?: SignatureHelpItems; } + /** + * Synchronous request for semantic diagnostics of one file. + */ interface SemanticDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SemanticDiagnosticsSync; arguments: SemanticDiagnosticsSyncRequestArgs; @@ -12999,6 +7424,9 @@ declare namespace ts.server.protocol { interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { includeLinePosition?: boolean; } + /** + * Response object for synchronous sematic diagnostics request. + */ interface SemanticDiagnosticsSyncResponse extends Response { body?: Diagnostic[] | DiagnosticWithLinePosition[]; } @@ -13008,6 +7436,9 @@ declare namespace ts.server.protocol { } type SuggestionDiagnosticsSyncRequestArgs = SemanticDiagnosticsSyncRequestArgs; type SuggestionDiagnosticsSyncResponse = SemanticDiagnosticsSyncResponse; + /** + * Synchronous request for syntactic diagnostics of one file. + */ interface SyntacticDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SyntacticDiagnosticsSync; arguments: SyntacticDiagnosticsSyncRequestArgs; @@ -13015,26 +7446,68 @@ declare namespace ts.server.protocol { interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { includeLinePosition?: boolean; } + /** + * Response object for synchronous syntactic diagnostics request. + */ interface SyntacticDiagnosticsSyncResponse extends Response { body?: Diagnostic[] | DiagnosticWithLinePosition[]; } + /** + * Arguments for GeterrForProject request. + */ interface GeterrForProjectRequestArgs { + /** + * the file requesting project error list + */ file: string; + /** + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ delay: number; } + /** + * GeterrForProjectRequest request; value of command field is + * "geterrForProject". It works similarly with 'Geterr', only + * it request for every file in this project. + */ interface GeterrForProjectRequest extends Request { command: CommandTypes.GeterrForProject; arguments: GeterrForProjectRequestArgs; } + /** + * Arguments for geterr messages. + */ interface GeterrRequestArgs { + /** + * List of file names for which to compute compiler errors. + * The files will be checked in list order. + */ files: string[]; + /** + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ delay: number; } + /** + * Geterr request; value of command field is "geterr". Wait for + * delay milliseconds and then, if during the wait no change or + * reload messages have arrived for the first file in the files + * list, get the syntactic errors for the file, field requests, + * and then get the semantic errors for the file. Repeat with a + * smaller delay for each subsequent file on the files list. Best + * practice for an editor is to send a file list containing each + * file that is currently visible, in most-recently-used order. + */ interface GeterrRequest extends Request { command: CommandTypes.Geterr; arguments: GeterrRequestArgs; } type RequestCompletedEventName = "requestCompleted"; + /** + * Event that is sent when server have finished processing request with specified id. + */ interface RequestCompletedEvent extends Event { event: RequestCompletedEventName; body: RequestCompletedEventBody; @@ -13042,36 +7515,103 @@ declare namespace ts.server.protocol { interface RequestCompletedEventBody { request_seq: number; } + /** + * Item of diagnostic information found in a DiagnosticEvent message. + */ interface Diagnostic { + /** + * Starting file location at which text applies. + */ start: Location; + /** + * The last file location at which the text applies. + */ end: Location; + /** + * Text of diagnostic message. + */ text: string; + /** + * The category of the diagnostic message, e.g. "error", "warning", or "suggestion". + */ category: string; reportsUnnecessary?: {}; + /** + * Any related spans the diagnostic may have, such as other locations relevant to an error, such as declarartion sites + */ relatedInformation?: DiagnosticRelatedInformation[]; + /** + * The error code of the diagnostic message. + */ code?: number; + /** + * The name of the plugin reporting the message. + */ source?: string; } interface DiagnosticWithFileName extends Diagnostic { + /** + * Name of the file the diagnostic is in + */ fileName: string; } + /** + * Represents additional spans returned with a diagnostic which are relevant to it + */ interface DiagnosticRelatedInformation { + /** + * The category of the related information message, e.g. "error", "warning", or "suggestion". + */ + category: string; + /** + * The code used ot identify the related information + */ + code: number; + /** + * Text of related or additional information. + */ message: string; + /** + * Associated location + */ span?: FileSpan; } interface DiagnosticEventBody { + /** + * The file for which diagnostic information is reported. + */ file: string; + /** + * An array of diagnostic information items. + */ diagnostics: Diagnostic[]; } type DiagnosticEventKind = "semanticDiag" | "syntaxDiag" | "suggestionDiag"; + /** + * Event message for DiagnosticEventKind event types. + * These events provide syntactic and semantic errors for a file. + */ interface DiagnosticEvent extends Event { body?: DiagnosticEventBody; } interface ConfigFileDiagnosticEventBody { + /** + * The file which trigged the searching and error-checking of the config file + */ triggerFile: string; + /** + * The name of the found config file. + */ configFile: string; + /** + * An arry of diagnostic information items for the found config file. + */ diagnostics: DiagnosticWithFileName[]; } + /** + * Event message for "configFileDiag" event type. + * This event provides errors for a found config file. + */ interface ConfigFileDiagnosticEvent extends Event { body?: ConfigFileDiagnosticEventBody; event: "configFileDiag"; @@ -13082,7 +7622,17 @@ declare namespace ts.server.protocol { body?: ProjectLanguageServiceStateEventBody; } interface ProjectLanguageServiceStateEventBody { + /** + * Project name that has changes in the state of language service. + * For configured projects this will be the config file path. + * For external projects this will be the name of the projects specified when project was open. + * For inferred projects this event is not raised. + */ projectName: string; + /** + * True if language service state switched from disabled to enabled + * and false otherwise. + */ languageServiceEnabled: boolean; } type ProjectsUpdatedInBackgroundEventName = "projectsUpdatedInBackground"; @@ -13091,76 +7641,203 @@ declare namespace ts.server.protocol { body: ProjectsUpdatedInBackgroundEventBody; } interface ProjectsUpdatedInBackgroundEventBody { + /** + * Current set of open files + */ openFiles: string[]; } + /** + * Arguments for reload request. + */ interface ReloadRequestArgs extends FileRequestArgs { + /** + * Name of temporary file from which to reload file + * contents. May be same as file. + */ tmpfile: string; } + /** + * Reload request message; value of command field is "reload". + * Reload contents of file with name given by the 'file' argument + * from temporary file with name given by the 'tmpfile' argument. + * The two names can be identical. + */ interface ReloadRequest extends FileRequest { command: CommandTypes.Reload; arguments: ReloadRequestArgs; } + /** + * Response to "reload" request. This is just an acknowledgement, so + * no body field is required. + */ interface ReloadResponse extends Response { } + /** + * Arguments for saveto request. + */ interface SavetoRequestArgs extends FileRequestArgs { + /** + * Name of temporary file into which to save server's view of + * file contents. + */ tmpfile: string; } + /** + * Saveto request message; value of command field is "saveto". + * For debugging purposes, save to a temporaryfile (named by + * argument 'tmpfile') the contents of file named by argument + * 'file'. The server does not currently send a response to a + * "saveto" request. + */ interface SavetoRequest extends FileRequest { command: CommandTypes.Saveto; arguments: SavetoRequestArgs; } + /** + * Arguments for navto request message. + */ interface NavtoRequestArgs extends FileRequestArgs { + /** + * Search term to navigate to from current location; term can + * be '.*' or an identifier prefix. + */ searchValue: string; + /** + * Optional limit on the number of items to return. + */ maxResultCount?: number; + /** + * Optional flag to indicate we want results for just the current file + * or the entire project. + */ currentFileOnly?: boolean; projectFileName?: string; } + /** + * Navto request message; value of command field is "navto". + * Return list of objects giving file locations and symbols that + * match the search term given in argument 'searchTerm'. The + * context for the search is given by the named file. + */ interface NavtoRequest extends FileRequest { command: CommandTypes.Navto; arguments: NavtoRequestArgs; } - interface NavtoItem { + /** + * An item found in a navto response. + */ + interface NavtoItem extends FileSpan { + /** + * The symbol's name. + */ name: string; + /** + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: ScriptElementKind; - matchKind?: string; - isCaseSensitive?: boolean; + /** + * exact, substring, or prefix. + */ + matchKind: string; + /** + * If this was a case sensitive or insensitive match. + */ + isCaseSensitive: boolean; + /** + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; - file: string; - start: Location; - end: Location; + /** + * Name of symbol's container symbol (if any); for example, + * the class name if symbol is a class member. + */ containerName?: string; + /** + * Kind of symbol's container symbol (if any). + */ containerKind?: ScriptElementKind; } + /** + * Navto response message. Body is an array of navto items. Each + * item gives a symbol that matched the search term. + */ interface NavtoResponse extends Response { body?: NavtoItem[]; } + /** + * Arguments for change request message. + */ interface ChangeRequestArgs extends FormatRequestArgs { + /** + * Optional string to insert at location (file, line, offset). + */ insertString?: string; } + /** + * Change request message; value of command field is "change". + * Update the server's view of the file named by argument 'file'. + * Server does not currently send a response to a change request. + */ interface ChangeRequest extends FileLocationRequest { command: CommandTypes.Change; arguments: ChangeRequestArgs; } + /** + * Response to "brace" request. + */ interface BraceResponse extends Response { body?: TextSpan[]; } + /** + * Brace matching request; value of command field is "brace". + * Return response giving the file locations of matching braces + * found in file at location line, offset. + */ interface BraceRequest extends FileLocationRequest { command: CommandTypes.Brace; } + /** + * NavBar items request; value of command field is "navbar". + * Return response giving the list of navigation bar entries + * extracted from the requested file. + */ interface NavBarRequest extends FileRequest { command: CommandTypes.NavBar; } + /** + * NavTree request; value of command field is "navtree". + * Return response giving the navigation tree of the requested file. + */ interface NavTreeRequest extends FileRequest { command: CommandTypes.NavTree; } interface NavigationBarItem { + /** + * The item's display text. + */ text: string; + /** + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: ScriptElementKind; + /** + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; + /** + * The definition locations of the item. + */ spans: TextSpan[]; + /** + * Optional children. + */ childItems?: NavigationBarItem[]; + /** + * Number of levels deep this item should appear. + */ indent: number; } + /** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */ interface NavigationTree { text: string; kind: ScriptElementKind; @@ -13192,8 +7869,17 @@ declare namespace ts.server.protocol { payload: TypingsInstalledTelemetryEventPayload; } interface TypingsInstalledTelemetryEventPayload { + /** + * Comma separated list of installed typing packages + */ installedPackages: string; + /** + * true if install request succeeded, otherwise - false + */ installSuccess: boolean; + /** + * version of typings installer + */ typingsInstallerVersion: string; } type BeginInstallTypesEventName = "beginInstallTypes"; @@ -13207,12 +7893,21 @@ declare namespace ts.server.protocol { body: EndInstallTypesEventBody; } interface InstallTypesEventBody { + /** + * correlation id to match begin and end events + */ eventId: number; + /** + * list of packages to install + */ packages: ReadonlyArray; } interface BeginInstallTypesEventBody extends InstallTypesEventBody { } interface EndInstallTypesEventBody extends InstallTypesEventBody { + /** + * true if installation succeeded, otherwise false + */ success: boolean; } interface NavBarResponse extends Response { @@ -13255,7 +7950,15 @@ declare namespace ts.server.protocol { interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "double" | "single"; + /** + * If enabled, TypeScript will search through all external modules' exports and add them to the completions list. + * This affects lone identifier completions but not completions on the right hand side of `obj.`. + */ readonly includeCompletionsForModuleExports?: boolean; + /** + * If enabled, the completion list will include completions with invalid identifier names. + * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. + */ readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; @@ -13327,6 +8030,7 @@ declare namespace ts.server.protocol { traceResolution?: boolean; resolveJsonModule?: boolean; types?: string[]; + /** Paths used to used to compute primary types search locations */ typeRoots?: string[]; [option: string]: CompilerOptionsValue | undefined; } @@ -13365,42 +8069,9 @@ declare namespace ts.server.protocol { } } declare namespace ts.server { - class TextStorage { - private readonly host; - private readonly fileName; - private svc; - private svcVersion; - private text; - private lineMap; - private textVersion; - isOpen: boolean; - private ownFileText; - private pendingReloadFromDisk; - constructor(host: ServerHost, fileName: NormalizedPath); - getVersion(): string; - hasScriptVersionCache_TestOnly(): boolean; - useScriptVersionCache_TestOnly(): void; - useText(newText?: string): void; - edit(start: number, end: number, newText: string): void; - reload(newText: string): true | undefined; - reloadWithFileText(tempFileName?: string): true | undefined; - reloadFromDisk(): boolean | undefined; - delayReloadFromFileIntoText(): void; - getSnapshot(): IScriptSnapshot; - getLineInfo(line: number): AbsolutePositionAndLineText; - lineToTextSpan(line: number): TextSpan; - lineOffsetToPosition(line: number, offset: number): number; - positionToLineOffset(position: number): protocol.Location; - private getFileText; - private switchToScriptVersionCache; - private useScriptVersionCacheIfValidOrOpen; - private getOrLoadText; - private getLineMap; - } - function isDynamicFileName(fileName: NormalizedPath): boolean; - interface DocumentRegistrySourceFileCache { - key: DocumentRegistryBucketKey; - sourceFile: SourceFile; + interface ScriptInfoVersion { + svc: number; + text: number; } class ScriptInfo { private readonly host; @@ -13408,22 +8079,19 @@ declare namespace ts.server { readonly scriptKind: ScriptKind; readonly hasMixedContent: boolean; readonly path: Path; + /** + * All projects that include this file + */ readonly containingProjects: Project[]; private formatSettings; private preferences; - fileWatcher: FileWatcher | undefined; private textStorage; - readonly isDynamic: boolean; - private realpath; - cacheSourceFile: DocumentRegistrySourceFileCache; - constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path); - isDynamicOrHasMixedContent(): boolean; + constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent: boolean, path: Path, initialVersion?: ScriptInfoVersion); isScriptOpen(): boolean; open(newText: string): void; close(fileExists?: boolean): void; getSnapshot(): IScriptSnapshot; private ensureRealPath; - getRealpathIfDifferent(): Path | undefined; getFormatCodeSettings(): FormatCodeSettings | undefined; getPreferences(): UserPreferences | undefined; attachToProject(project: Project): boolean; @@ -13435,13 +8103,18 @@ declare namespace ts.server { setOptions(formatSettings: FormatCodeSettings, preferences: UserPreferences | undefined): void; getLatestVersion(): string; saveTo(fileName: string): void; - delayReloadNonMixedContentFile(): void; reloadFromFile(tempFileName?: NormalizedPath): void; - getLineInfo(line: number): AbsolutePositionAndLineText; editContent(start: number, end: number, newText: string): void; markContainingProjectsAsDirty(): void; isOrphan(): boolean; + /** + * @param line 1 based index + */ lineToTextSpan(line: number): TextSpan; + /** + * @param line 1 based index + * @param offset 1 based index + */ lineOffsetToPosition(line: number, offset: number): number; positionToLineOffset(position: number): protocol.Location; isJavaScript(): boolean; @@ -13461,16 +8134,6 @@ declare namespace ts.server { readonly globalTypingsCacheLocation: string | undefined; } const nullTypingsInstaller: ITypingsInstaller; - class TypingsCache { - private readonly installer; - private readonly perProjectCache; - constructor(installer: ITypingsInstaller); - isKnownTypesPackageName(name: string): boolean; - installPackage(options: InstallPackageOptionsWithProject): Promise; - enqueueInstallTypingsForProject(project: Project, unresolvedImports: SortedReadonlyArray | undefined, forceRefresh: boolean): void; - updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray, newTypings: string[]): SortedReadonlyArray | SortedArray; - onProjectClosed(project: Project): void; - } } declare namespace ts.server { enum ProjectKind { @@ -13478,16 +8141,8 @@ declare namespace ts.server { Configured = 1, External = 2 } - type Mutable = { - -readonly [K in keyof T]: T[K]; - }; - function countEachFileTypes(infos: ScriptInfo[]): FileStats; function allRootFilesAreJsOrDts(project: Project): boolean; function allFilesAreJsOrDts(project: Project): boolean; - function hasNoTypeScriptSource(fileNames: string[]): boolean; - interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { - projectErrors: ReadonlyArray; - } interface PluginCreateInfo { project: Project; languageService: LanguageService; @@ -13502,8 +8157,11 @@ declare namespace ts.server { type PluginModuleFactory = (mod: { typescript: typeof ts; }) => PluginModule; + /** + * The project root can be script info - if root is present, + * or it could be just normalized path if root wasnt present on the host(only for non inferred project) + */ type ProjectRoot = ScriptInfo | NormalizedPath; - function isScriptInfo(value: ProjectRoot): value is ScriptInfo; abstract class Project implements LanguageServiceHost, ModuleResolutionHost { readonly projectName: string; readonly projectKind: ProjectKind; @@ -13517,33 +8175,40 @@ declare namespace ts.server { private externalFiles; private missingFilesMap; private plugins; - cachedUnresolvedImportsPerFile: Map>; - lastCachedUnresolvedImportsList: SortedReadonlyArray | undefined; - private hasAddedorRemovedFiles; private lastFileExceededProgramSize; protected languageService: LanguageService; languageServiceEnabled: boolean; readonly trace?: (s: string) => void; readonly realpath?: (path: string) => string; - hasInvalidatedResolution: HasInvalidatedResolution; - resolutionCache: ResolutionCache; private builderState; + /** + * Set of files names that were updated since the last call to getChangesSinceVersion. + */ private updatedFileNames; + /** + * Set of files that was returned from the last call to getChangesSinceVersion. + */ private lastReportedFileNames; + /** + * Last version that was reported. + */ private lastReportedVersion; + /** + * Current project's program version. (incremented everytime new program is created that is not complete reuse from the old one) + * This property is changed in 'updateGraph' based on the set of files in program + */ private projectProgramVersion; + /** + * Current version of the project state. It is changed when: + * - new root file was added/removed + * - edit happen in some file that is currently included in the project. + * This property is different from projectStructureVersion since in most cases edits don't affect set of files in the project + */ private projectStateVersion; - dirty: boolean; - hasChangedAutomaticTypeDirectiveNames: boolean; - typingFiles: SortedReadonlyArray; private readonly cancellationToken; isNonTsProject(): boolean; isJsOnlyProject(): boolean; static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void): {} | undefined; - readonly currentDirectory: string; - directoryStructureHost: DirectoryStructureHost; - readonly getCanonicalFileName: GetCanonicalFileName; - constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: DocumentRegistry, hasExplicitListOfFiles: boolean, lastFileExceededProgramSize: string | undefined, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean, directoryStructureHost: DirectoryStructureHost, currentDirectory: string | undefined); isKnownTypesPackageName(name: string): boolean; installPackage(options: InstallPackageOptions): Promise; private readonly typingsCache; @@ -13551,7 +8216,7 @@ declare namespace ts.server { getCompilerOptions(): CompilerOptions; getNewLine(): string; getProjectVersion(): string; - getProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): ReadonlyArray; getScriptFileNames(): string[]; private getOrCreateScriptInfoAndAttachToProject; getScriptKind(fileName: string): ScriptKind; @@ -13569,22 +8234,20 @@ declare namespace ts.server { resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists(path: string): boolean; getDirectories(path: string): string[]; - getCachedDirectoryStructureHost(): CachedDirectoryStructureHost; - toPath(fileName: string): Path; - watchDirectoryOfFailedLookupLocation(directory: string, cb: DirectoryWatcherCallback, flags: WatchDirectoryFlags): FileWatcher; - onInvalidatedResolution(): void; - watchTypeRootsDirectory(directory: string, cb: DirectoryWatcherCallback, flags: WatchDirectoryFlags): FileWatcher; - onChangedAutomaticTypeDirectiveNames(): void; - getGlobalCache(): string | undefined; - writeLog(s: string): void; log(s: string): void; error(s: string): void; private setInternalCompilerOptionsForEmittingJsFiles; + /** + * Get the errors that dont have any file name associated + */ getGlobalProjectErrors(): ReadonlyArray; getAllProjectErrors(): ReadonlyArray; getLanguageService(ensureSynchronized?: boolean): LanguageService; private shouldEmitFile; getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; + /** + * Returns true if emit was conducted + */ emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; enableLanguageService(): void; disableLanguageService(lastFileExceededProgramSize?: string): void; @@ -13593,14 +8256,11 @@ declare namespace ts.server { protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition; getExternalFiles(): SortedReadonlyArray; getSourceFile(path: Path): SourceFile | undefined; - getSourceFileOrConfigFile(path: Path): SourceFile | undefined; close(): void; private detachScriptInfoIfNotRoot; isClosed(): boolean; hasRoots(): boolean; - isOrphan(): boolean; getRootFiles(): NormalizedPath[]; - getRootFilesMap(): Map; getRootScriptInfos(): ScriptInfo[]; getScriptInfos(): ScriptInfo[]; getExcludedFiles(): ReadonlyArray; @@ -13614,11 +8274,11 @@ declare namespace ts.server { removeFile(info: ScriptInfo, fileExists: boolean, detachFromProject: boolean): void; registerFileUpdate(fileName: string): void; markAsDirty(): void; - private extractUnresolvedImportsFromSourceFile; - onFileAddedOrRemoved(): void; + /** + * Updates set of files that contribute to this project + * @returns: true if set of files in the project stays the same and false - otherwise. + */ updateGraph(): boolean; - updateTypingFiles(typingFiles: SortedReadonlyArray): void; - getCurrentProgram(): Program; protected removeExistingTypings(include: string[]): string[]; private updateGraphWorker; private detachScriptInfoFromProject; @@ -13628,66 +8288,76 @@ declare namespace ts.server { getScriptInfo(uncheckedFileName: string): ScriptInfo | undefined; filesToString(writeProjectFileNames: boolean): string; setCompilerOptions(compilerOptions: CompilerOptions): void; - getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics; protected removeRoot(info: ScriptInfo): void; protected enableGlobalPlugins(): void; protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]): void; + /** Starts a new check for diagnostics. Call this if some file has updated that would cause diagnostics to be changed. */ refreshDiagnostics(): void; private enableProxy; } + /** + * If a file is opened and no tsconfig (or jsconfig) is found, + * the file and its imports/references are put into an InferredProject. + */ class InferredProject extends Project { private static readonly newName; private _isJsInferredProject; toggleJsInferredProject(isJsInferredProject: boolean): void; setCompilerOptions(options?: CompilerOptions): void; + /** this is canonical project root path */ readonly projectRootPath: string | undefined; - readonly canonicalCurrentDirectory: string | undefined; - constructor(projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions, projectRootPath: NormalizedPath | undefined, currentDirectory: string | undefined); addRoot(info: ScriptInfo): void; removeRoot(info: ScriptInfo): void; - isOrphan(): boolean; isProjectWithSingleRoot(): boolean; close(): void; getTypeAcquisition(): TypeAcquisition; } + /** + * If a file is opened, the server will look for a tsconfig (or jsconfig) + * and if successfull create a ConfiguredProject for it. + * Otherwise it will create an InferredProject. + */ class ConfiguredProject extends Project { compileOnSaveEnabled: boolean; private projectReferences; private typeAcquisition; - configFileWatcher: FileWatcher | undefined; private directoriesWatchedForWildcards; readonly canonicalConfigFilePath: NormalizedPath; - pendingReload: ConfigFileProgramReloadLevel; - configFileSpecs: ConfigFileSpecs | undefined; + /** Ref count to the project when opened from external project */ private externalProjectRefCount; private projectErrors; - constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, lastFileExceededProgramSize: string | undefined, compileOnSaveEnabled: boolean, cachedDirectoryStructureHost: CachedDirectoryStructureHost, projectReferences: ReadonlyArray | undefined); + /** + * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph + * @returns: true if set of files in the project stays the same and false - otherwise. + */ updateGraph(): boolean; - getCachedDirectoryStructureHost(): CachedDirectoryStructureHost; getConfigFilePath(): NormalizedPath; - getProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): ReadonlyArray; updateReferences(refs: ReadonlyArray | undefined): void; enablePlugins(): void; + /** + * Get the errors that dont have any file name associated + */ getGlobalProjectErrors(): ReadonlyArray; + /** + * Get all the project errors + */ getAllProjectErrors(): ReadonlyArray; setProjectErrors(projectErrors: Diagnostic[]): void; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; getTypeAcquisition(): TypeAcquisition; - watchWildcards(wildcardDirectories: Map): void; - stopWatchingWildCards(): void; close(): void; - addExternalProjectReference(): void; - deleteExternalProjectReference(): void; - hasOpenRef(): boolean; getEffectiveTypeRoots(): string[]; - updateErrorOnNoInputFiles(hasFileNames: boolean): void; } + /** + * Project whose configuration is handled externally, such as in a '.csproj'. + * These are created only if a host explicitly calls `openExternalProject`. + */ class ExternalProject extends Project { externalProjectName: string; compileOnSaveEnabled: boolean; excludedFiles: ReadonlyArray; private typeAcquisition; - constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions, lastFileExceededProgramSize: string | undefined, compileOnSaveEnabled: boolean, projectFilePath?: string); getExcludedFiles(): ReadonlyArray; getTypeAcquisition(): TypeAcquisition; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; @@ -13721,13 +8391,20 @@ declare namespace ts.server { languageServiceEnabled: boolean; }; } + /** This will be converted to the payload of a protocol.TelemetryEvent in session.defaultEventHandler. */ interface ProjectInfoTelemetryEvent { readonly eventName: typeof ProjectInfoTelemetryEvent; readonly data: ProjectInfoTelemetryEventData; } interface ProjectInfoTelemetryEventData { + /** Cryptographically secure hash of project file location. */ readonly projectId: string; + /** Count of file extensions seen in the project. */ readonly fileStats: FileStats; + /** + * Any compiler options that might contain paths will be taken out. + * Enum compiler options will be converted to strings. + */ readonly compilerOptions: CompilerOptions; readonly extends: boolean | undefined; readonly files: boolean | undefined; @@ -13738,8 +8415,14 @@ declare namespace ts.server { readonly configFileName: "tsconfig.json" | "jsconfig.json" | "other"; readonly projectType: "external" | "configured"; readonly languageServiceEnabled: boolean; + /** TypeScript version used by the server. */ readonly version: string; } + /** + * Info that we may send about a file that was just opened. + * Info about a file will only be sent once per session, even if the file changes in ways that might affect the info. + * Currently this is only sent for '.js' files. + */ interface OpenFileInfoTelemetryEvent { readonly eventName: typeof OpenFileInfoTelemetryEvent; readonly data: OpenFileInfoTelemetryEventData; @@ -13792,20 +8475,6 @@ declare namespace ts.server { configFileName?: NormalizedPath; configFileErrors?: ReadonlyArray; } - enum WatchType { - ConfigFilePath = "Config file for the program", - MissingFilePath = "Missing file from program", - WildcardDirectories = "Wild card directory", - ClosedScriptInfo = "Closed Script info", - ConfigFileForInferredRoot = "Config file for the inferred project root", - FailedLookupLocation = "Directory of Failed lookup locations in module resolution", - TypeRoots = "Type root directory" - } - interface ConfigFileExistenceInfo { - exists: boolean; - openFilesImpactedByConfigFile: Map; - configFileWatcherForRootOfInferredProject?: FileWatcher; - } interface ProjectServiceOptions { host: ServerHost; logger: Logger; @@ -13823,27 +8492,60 @@ declare namespace ts.server { syntaxOnly?: boolean; } class ProjectService { - readonly typingsCache: TypingsCache; - readonly documentRegistry: DocumentRegistry; + /** + * Container of all known scripts + */ private readonly filenameToScriptInfo; + /** + * Contains all the deleted script info's version information so that + * it does not reset when creating script info again + * (and could have potentially collided with version where contents mismatch) + */ + private readonly filenameToScriptInfoVersion; private readonly allJsFilesForOpenFileTelemetry; - readonly realpathToScriptInfos: MultiMap | undefined; + /** + * maps external project file name to list of config files that were the part of this project + */ private readonly externalProjectToConfiguredProjectMap; + /** + * external projects (configuration and list of root files is not controlled by tsserver) + */ readonly externalProjects: ExternalProject[]; + /** + * projects built from openFileRoots + */ readonly inferredProjects: InferredProject[]; + /** + * projects specified by a tsconfig.json file + */ readonly configuredProjects: Map; + /** + * Open files: with value being project root path, and key being Path of the file that is open + */ readonly openFiles: Map; + /** + * Map of open files that are opened without complete path but have projectRoot as current directory + */ private readonly openFilesWithNonRootedDiskPath; private compilerOptionsForInferredProjects; private compilerOptionsForInferredProjectsPerProjectRoot; + /** + * Project size for configured or external projects + */ private readonly projectToSizeMap; + /** + * This is a map of config file paths existance that doesnt need query to disk + * - The entry can be present because there is inferred project that needs to watch addition of config file to directory + * In this case the exists could be true/false based on config file is present or not + * - Or it is present if we have configured project open with config file at that location + * In this case the exists property is always true + */ private readonly configFileExistenceInfoCache; private readonly throttledOperations; private readonly hostConfiguration; private safelist; private legacySafelist; private pendingProjectUpdates; - pendingEnsureProjectForOpenFiles: boolean; readonly currentDirectory: NormalizedPath; readonly toCanonicalFileName: (f: string) => string; readonly host: ServerHost; @@ -13861,34 +8563,27 @@ declare namespace ts.server { readonly allowLocalPluginLoads: boolean; readonly typesMapLocation: string | undefined; readonly syntaxOnly?: boolean; + /** Tracks projects that we have already sent telemetry for. */ private readonly seenProjects; - readonly watchFactory: WatchFactory; constructor(opts: ProjectServiceOptions); toPath(fileName: string): Path; - getExecutingFilePath(): string; - getNormalizedAbsolutePath(fileName: string): string; - setDocument(key: DocumentRegistryBucketKey, path: Path, sourceFile: SourceFile): void; - getDocument(key: DocumentRegistryBucketKey, path: Path): SourceFile | undefined; - ensureInferredProjectsUpToDate_TestOnly(): void; - getCompilerOptionsForInferredProjects(): CompilerOptions; - onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; private loadTypesMap; updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse): void; - updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse | BeginInstallTypes | EndInstallTypes): void; private delayEnsureProjectForOpenFiles; private delayUpdateProjectGraph; - hasPendingProjectUpdate(project: Project): boolean; - sendProjectsUpdatedInBackgroundEvent(): void; - delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project: Project): void; private delayUpdateProjectGraphs; setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void; findProject(projectName: string): Project | undefined; - forEachProject(cb: (project: Project) => void): void; getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined; - tryGetDefaultProjectForFile(fileName: NormalizedPath): Project | undefined; - ensureDefaultProjectForFile(fileName: NormalizedPath): Project; private doEnsureDefaultProjectForFile; getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo | undefined; + /** + * Ensures the project structures are upto date + * This means, + * - we go through all the projects and update them if they are dirty + * - if updates reflect some change in structure or there was pending request to ensure projects for open files + * ensure that each open script info has project + */ private ensureProjectStructuresUptoDate; getFormatCodeOptions(file: NormalizedPath): FormatCodeSettings; getPreferences(file: NormalizedPath): UserPreferences; @@ -13896,31 +8591,65 @@ declare namespace ts.server { getHostPreferences(): UserPreferences; private onSourceFileChanged; private handleDeletedFile; - watchWildcardDirectory(directory: Path, flags: WatchDirectoryFlags, project: ConfiguredProject): FileWatcher; - getConfigFileExistenceInfo(project: ConfiguredProject): ConfigFileExistenceInfo; private onConfigChangedForConfiguredProject; + /** + * This is the callback function for the config file add/remove/change at any location + * that matters to open script info but doesnt have configured project open + * for the config file + */ private onConfigFileChangeForOpenScriptInfo; private removeProject; - assignOrphanScriptInfoToInferredProject(info: ScriptInfo, projectRootPath: NormalizedPath | undefined): InferredProject; + /** + * Remove this file from the set of open, non-configured files. + * @param info The file that has been closed or newly configured + */ private closeOpenFile; private deleteScriptInfo; private configFileExists; private setConfigFileExistenceByNewConfiguredProject; + /** + * Returns true if the configFileExistenceInfo is needed/impacted by open files that are root of inferred project + */ private configFileExistenceImpactsRootOfInferredProject; private setConfigFileExistenceInfoByClosedConfiguredProject; private logConfigFileWatchUpdate; + /** + * Create the watcher for the configFileExistenceInfo + */ private createConfigFileWatcherOfConfigFileExistence; + /** + * Close the config file watcher in the cached ConfigFileExistenceInfo + * if there arent any open files that are root of inferred project + */ private closeConfigFileWatcherOfConfigFileExistenceInfo; + /** + * This is called on file close, so that we stop watching the config file for this script info + */ private stopWatchingConfigFilesForClosedScriptInfo; - startWatchingConfigFilesForInferredProjectRoot(info: ScriptInfo): void; - stopWatchingConfigFilesForInferredProjectRoot(info: ScriptInfo): void; + /** + * This function tries to search for a tsconfig.json for the given file. + * This is different from the method the compiler uses because + * the compiler can assume it will always start searching in the + * current directory (the directory in which tsc was invoked). + * The server must start searching from the directory containing + * the newly opened file. + */ private forEachConfigFileLocation; + /** + * This function tries to search for a tsconfig.json for the given file. + * This is different from the method the compiler uses because + * the compiler can assume it will always start searching in the + * current directory (the directory in which tsc was invoked). + * The server must start searching from the directory containing + * the newly opened file. + */ private getConfigFileNameForFile; private printProjects; private findConfiguredProjectByProjectName; private getConfiguredProjectByCanonicalConfigFilePath; private findExternalProjectByProjectName; private convertConfigFileContentToProjectOptions; + /** Get a filename if the language service exceeds the maximum allowed program size; otherwise returns undefined. */ private getFilenameForExceededTotalSizeLimitForNonTsFiles; private createExternalProject; private sendProjectTelemetry; @@ -13928,45 +8657,72 @@ declare namespace ts.server { private createConfiguredProject; private updateNonInferredProjectFiles; private updateNonInferredProject; - reloadFileNamesOfConfiguredProject(project: ConfiguredProject): boolean; - reloadConfiguredProject(project: ConfiguredProject): void; private sendConfigFileDiagEvent; private getOrCreateInferredProjectForProjectRootPathIfEnabled; private getOrCreateSingleInferredProjectIfEnabled; private getOrCreateSingleInferredWithoutProjectRoot; private createInferredProject; - getOrCreateScriptInfoNotOpenedByClient(uncheckedFileName: string, currentDirectory: string, hostToQueryFileExistsOn: DirectoryStructureHost): ScriptInfo | undefined; getScriptInfo(uncheckedFileName: string): ScriptInfo | undefined; - getSymlinkedProjects(info: ScriptInfo): MultiMap | undefined; private watchClosedScriptInfo; private stopWatchingScriptInfo; - getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined, hostToQueryFileExistsOn: DirectoryStructureHost | undefined): ScriptInfo | undefined; - getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName: NormalizedPath, currentDirectory: string, fileContent: string | undefined, scriptKind: ScriptKind | undefined, hasMixedContent: boolean | undefined): ScriptInfo | undefined; + private getOrCreateScriptInfoNotOpenedByClientForNormalizedPath; + private getOrCreateScriptInfoOpenedByClientForNormalizedPath; getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, hostToQueryFileExistsOn?: { fileExists(path: string): boolean; }): ScriptInfo | undefined; private getOrCreateScriptInfoWorker; + /** + * This gets the script info for the normalized path. If the path is not rooted disk path then the open script info with project root context is preferred + */ getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo | undefined; getScriptInfoForPath(fileName: Path): ScriptInfo | undefined; setHostConfiguration(args: protocol.ConfigureRequestArguments): void; closeLog(): void; + /** + * This function rebuilds the project for every file opened by the client + * This does not reload contents of open files from disk. But we could do that if needed + */ reloadProjects(): void; private delayReloadConfiguredProjectForFiles; + /** + * This function goes through all the openFiles and tries to file the config file for them. + * If the config file is found and it refers to existing project, it reloads it either immediately + * or schedules it for reload depending on delayReload option + * If the there is no existing project it just opens the configured project for the config file + * reloadForInfo provides a way to filter out files to reload configured project for + */ private reloadConfiguredProjectForFiles; + /** + * Remove the root of inferred project if script info is part of another project + */ private removeRootOfInferredProjectIfNowPartOfOtherProject; + /** + * This function is to update the project structure for every inferred project. + * It is called on the premise that all the configured projects are + * up to date. + * This will go through open files and assign them to inferred project if open file is not part of any other project + * After that all the inferred project graphs are updated + */ private ensureProjectForOpenFiles; + /** + * Open file whose contents is managed by the client + * @param filename is absolute pathname + * @param fileContent is a known version of the file content that is more up to date than the one on disk + */ openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind, projectRootPath?: string): OpenConfiguredProjectResult; private findExternalProjectContainingOpenScriptInfo; openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult; private telemetryOnOpenFile; + /** + * Close file whose contents is managed by the client + * @param filename is absolute pathname + */ closeClientFile(uncheckedFileName: string): void; private collectChanges; - synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[]; - applyChangesInOpenFiles(openFiles: protocol.ExternalFile[] | undefined, changedFiles: protocol.ChangedOpenFile[] | undefined, closedFiles: string[] | undefined): void; - applyChangesToFile(scriptInfo: ScriptInfo, changes: TextChange[]): void; private closeConfiguredProjectReferencedFromExternalProject; closeExternalProject(uncheckedFileName: string): void; openExternalProjects(projects: protocol.ExternalProject[]): void; + /** Makes a filename safe to insert in a RegExp */ private static readonly filenameEscapeRegexp; private static escapeFilenameForRegex; resetSafeList(): void; @@ -13992,7 +8748,6 @@ declare namespace ts.server { interface EventSender { event: Event; } - function toEvent(eventName: string, body: object): protocol.Event; interface SessionOptions { host: ServerHost; cancellationToken: ServerCancellationToken; @@ -14002,8 +8757,12 @@ declare namespace ts.server { byteLength: (buf: string, encoding?: string) => number; hrtime: (start?: number[]) => number[]; logger: Logger; + /** + * If falsy, all events are suppressed. + */ canUseEvents: boolean; eventHandler?: ProjectServiceEventHandler; + /** Has no effect if eventHandler is also specified. */ suppressDiagnosticEvents?: boolean; syntaxOnly?: boolean; throttleWaitMilliseconds?: number; @@ -14035,12 +8794,14 @@ declare namespace ts.server { logError(err: Error, cmd: string): void; send(msg: protocol.Message): void; event(body: T, eventName: string): void; + /** @deprecated */ output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; private doOutput; private semanticCheck; private syntacticCheck; private suggestionCheck; private sendDiagnosticsEvent; + /** It is the caller's responsibility to verify that `!this.suppressDiagnosticEvents`. */ private updateErrorCheck; private cleanProjects; private cleanup; @@ -14053,11 +8814,14 @@ declare namespace ts.server { private convertToDiagnosticsWithLinePosition; private getDiagnosticsWorker; private getDefinition; + private mapDefinitionInfoLocations; private getDefinitionAndBoundSpan; + private getEmitOutput; private mapDefinitionInfo; private static mapToOriginalLocation; private toFileSpan; private getTypeDefinition; + private mapImplementationLocations; private getImplementation; private getOccurrences; private getSyntacticDiagnosticsSync; @@ -14072,7 +8836,13 @@ declare namespace ts.server { private getProjects; private getDefaultProject; private getRenameLocations; + private static mapRenameInfo; + private toSpanGroups; private getReferences; + /** + * @param fileName is the name of the file to be opened + * @param fileContent is a version of the file content that is known to be more up to date than the one on disk + */ private openClientFile; private getPosition; private getPositionInFile; @@ -14110,6 +8880,7 @@ declare namespace ts.server { private toLocationTextSpan; private getNavigationTree; private getNavigateToItems; + private getFullNavigateToItems; private getSupportedCodeFixes; private isLocation; private extractPositionAndRange; @@ -14148,110 +8919,7 @@ declare namespace ts.server { response?: {}; responseRequired?: boolean; } - function getLocationInNewDocument(oldText: string, renameFilename: string, renameLocation: number, edits: ReadonlyArray): protocol.Location; -} -declare namespace ts.server { - interface LineCollection { - charCount(): number; - lineCount(): number; - isLeaf(): this is LineLeaf; - walk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker): void; - } - interface AbsolutePositionAndLineText { - absolutePosition: number; - lineText: string | undefined; - } - enum CharRangeSection { - PreStart = 0, - Start = 1, - Entire = 2, - Mid = 3, - End = 4, - PostEnd = 5 - } - interface LineIndexWalker { - goSubtree: boolean; - done: boolean; - leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void; - pre?(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineNode, nodeType: CharRangeSection): void; - post?(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineNode, nodeType: CharRangeSection): void; - } - class ScriptVersionCache { - private changes; - private readonly versions; - private minVersion; - private currentVersion; - private static readonly changeNumberThreshold; - private static readonly changeLengthThreshold; - private static readonly maxVersions; - private versionToIndex; - private currentVersionToIndex; - edit(pos: number, deleteLen: number, insertedText?: string): void; - getSnapshot(): IScriptSnapshot; - private _getSnapshot; - getSnapshotVersion(): number; - getLineInfo(line: number): AbsolutePositionAndLineText; - lineOffsetToPosition(line: number, column: number): number; - positionToLineOffset(position: number): protocol.Location; - lineToTextSpan(line: number): TextSpan; - getTextChangesBetweenVersions(oldVersion: number, newVersion: number): TextChangeRange | undefined; - static fromString(script: string): ScriptVersionCache; - } - class LineIndex { - root: LineNode; - checkEdits: boolean; - absolutePositionOfStartOfLine(oneBasedLine: number): number; - positionToLineOffset(position: number): protocol.Location; - private positionToColumnAndLineText; - lineNumberToInfo(oneBasedLine: number): AbsolutePositionAndLineText; - load(lines: string[]): void; - walk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker): void; - getText(rangeStart: number, rangeLength: number): string; - getLength(): number; - every(f: (ll: LineLeaf, s: number, len: number) => boolean, rangeStart: number, rangeEnd?: number): boolean; - edit(pos: number, deleteLength: number, newText?: string): LineIndex; - private static buildTreeFromBottom; - static linesFromText(text: string): { - lines: string[]; - lineMap: number[]; - }; - } - class LineNode implements LineCollection { - private readonly children; - totalChars: number; - totalLines: number; - constructor(children?: LineCollection[]); - isLeaf(): boolean; - updateCounts(): void; - private execWalk; - private skipChild; - walk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker): void; - charOffsetToLineInfo(lineNumberAccumulator: number, relativePosition: number): { - oneBasedLine: number; - zeroBasedColumn: number; - lineText: string | undefined; - }; - lineNumberToInfo(relativeOneBasedLine: number, positionAccumulator: number): { - position: number; - leaf: LineLeaf | undefined; - }; - private splitAfter; - remove(child: LineCollection): void; - private findChildIndex; - insertAt(child: LineCollection, nodes: LineCollection[]): LineNode[]; - add(collection: LineCollection): void; - charCount(): number; - lineCount(): number; - } - class LineLeaf implements LineCollection { - text: string; - constructor(text: string); - isLeaf(): boolean; - walk(rangeStart: number, rangeLength: number, walkFns: LineIndexWalker): void; - charCount(): number; - lineCount(): number; - } } -//# sourceMappingURL=server.d.ts.map + export = ts; export as namespace ts; \ No newline at end of file diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 723b00994998d..488f7c85a69d7 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1,5 +1,20 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + declare namespace ts { - const versionMajorMinor = "3.0"; + const versionMajorMinor = "3.1"; /** The version of the TypeScript compiler release */ const version: string; } @@ -530,7 +545,7 @@ declare namespace ts { } interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; - parent: DeclarationWithTypeParameters | InferTypeNode; + parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -1105,7 +1120,10 @@ declare namespace ts { } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + expression: JsxTagNameExpression; + } interface JsxAttributes extends ObjectLiteralExpressionBase { parent: JsxOpeningLikeElement; } @@ -1299,7 +1317,8 @@ declare namespace ts { block: Block; } type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; @@ -1819,7 +1838,6 @@ declare namespace ts { inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; } /** Return code used by getEmitOutput function to indicate status of the function */ enum ExitStatus { @@ -1884,17 +1902,12 @@ declare namespace ts { */ getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; - getTypeAtLocation(node: Node): Type | undefined; + 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, flags?: SymbolFormatFlags): string; typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - /** - * @deprecated Use the createX factory functions or XToY typechecker methods and `createPrinter` or the `xToString` methods instead - * This will be removed in a future version. - */ - getSymbolDisplayBuilder(): SymbolDisplayBuilder; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; @@ -1921,9 +1934,6 @@ declare namespace ts { getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; - getSuggestionForNonexistentProperty(name: Identifier | string, containingType: Type): string | undefined; - getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; - getSuggestionForNonexistentModule(node: Identifier, target: Symbol): string | undefined; getBaseConstraintOfType(type: Type): Type | undefined; getDefaultFromTypeParameter(type: Type): Type | undefined; /** @@ -1993,39 +2003,6 @@ declare namespace ts { AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8 } - /** - * @deprecated - */ - interface SymbolDisplayBuilder { - /** @deprecated */ buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - /** @deprecated */ buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; - /** @deprecated */ buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; - /** @deprecated */ buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - /** @deprecated */ buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - } - /** - * @deprecated Migrate to other methods of generating symbol names, ex symbolToEntityName + a printer or symbolToString - */ - interface SymbolWriter extends SymbolTracker { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeProperty(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - } enum TypePredicateKind { This = 0, Identifier = 1 @@ -2072,6 +2049,7 @@ declare namespace ts { Optional = 16777216, Transient = 33554432, JSContainer = 67108864, + ModuleExports = 134217728, Enum = 384, Variable = 3, Value = 67216319, @@ -2099,8 +2077,6 @@ declare namespace ts { AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, - HasExports = 1955, - HasMembers = 6240, BlockScoped = 418, PropertyOrAccessor = 98308, ClassMember = 106500 @@ -2397,14 +2373,14 @@ declare namespace ts { next?: DiagnosticMessageChain; } interface Diagnostic extends DiagnosticRelatedInformation { - category: DiagnosticCategory; /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; - code: number; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } interface DiagnosticRelatedInformation { + category: DiagnosticCategory; + code: number; file: SourceFile | undefined; start: number | undefined; length: number | undefined; @@ -2506,6 +2482,7 @@ declare namespace ts { strictFunctionTypes?: boolean; strictNullChecks?: boolean; strictPropertyInitialization?: boolean; + stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; @@ -2607,7 +2584,7 @@ declare namespace ts { } interface UpToDateHost { fileExists(fileName: string): boolean; - getModifiedTime(fileName: string): Date; + getModifiedTime(fileName: string): Date | undefined; getUnchangedTime?(fileName: string): Date | undefined; getLastStatus?(fileName: string): UpToDateStatus | undefined; setLastStatus?(fileName: string, status: UpToDateStatus): void; @@ -2711,7 +2688,7 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; - getModifiedTime?(fileName: string): Date; + getModifiedTime?(fileName: string): Date | undefined; setModifiedTime?(fileName: string, date: Date): void; deleteFile?(fileName: string): void; } @@ -2938,13 +2915,6 @@ declare namespace ts { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - /** @deprecated See comment on SymbolWriter */ - interface SymbolTracker { - trackSymbol?(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError?(): void; - reportPrivateInBaseOfClassExpression?(propertyName: string): void; - reportInaccessibleUniqueSymbolError?(): void; - } interface TextSpan { start: number; length: number; @@ -3055,7 +3025,7 @@ declare namespace ts { getCurrentDirectory(): string; getDirectories(path: string): string[]; readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; - getModifiedTime?(path: string): Date; + getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; /** @@ -3175,7 +3145,8 @@ declare namespace ts { function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; + function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; + function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** * Checks to see if the locale is in the appropriate format, @@ -3221,13 +3192,6 @@ declare namespace ts { function unescapeLeadingUnderscores(identifier: __String): string; function idText(identifier: Identifier): string; function symbolName(symbol: Symbol): string; - /** - * Remove extra underscore from escaped identifier text content. - * @deprecated Use `id.text` for the unescaped text. - * @param identifier The escaped identifier text. - * @returns The unescaped identifier text. - */ - function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; /** @@ -3276,16 +3240,21 @@ declare namespace ts { */ function getJSDocType(node: Node): TypeNode | undefined; /** - * Gets the return type node for the node if provided via JSDoc's return tag. + * Gets the return type node for the node if provided via JSDoc return tag or type tag. * * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function - * gets the type from inside the braces. + * gets the type from inside the braces, after the fat arrow, etc. */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ function getJSDocTags(node: Node): ReadonlyArray; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + /** + * Gets the effective type parameters. If the node was parsed in a + * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + */ + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; } declare namespace ts { function isNumericLiteral(node: Node): node is NumericLiteral; @@ -3776,7 +3745,7 @@ declare namespace ts { function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + /** @deprecated */ function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; @@ -3794,7 +3763,7 @@ declare namespace ts { function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator?: BinaryOperator | BinaryOperatorToken): 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; + /** @deprecated */ function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; @@ -3826,8 +3795,12 @@ declare namespace ts { function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; - function createStatement(expression: Expression): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + function createExpressionStatement(expression: Expression): ExpressionStatement; + function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; + /** @deprecated Use `createExpressionStatement` instead. */ + const createStatement: typeof createExpressionStatement; + /** @deprecated Use `updateExpressionStatement` instead. */ + const updateStatement: typeof updateExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; @@ -4184,10 +4157,14 @@ declare namespace ts { * @returns A 'Program' object. */ function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; + interface ResolveProjectReferencePathHost { + fileExists(fileName: string): boolean; + } /** - * Returns the target config filename of a project reference + * Returns the target config filename of a project reference. + * Note: The file might not exist. */ - function resolveProjectReferencePath(host: CompilerHost | UpToDateHost, ref: ProjectReference): ResolvedConfigFileName; + function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; } declare namespace ts { interface EmitOutput { @@ -4517,12 +4494,12 @@ declare namespace ts { */ interface UpToDate { type: UpToDateStatusType.UpToDate | UpToDateStatusType.UpToDateWithUpstreamTypes; - newestInputFileTime: Date; - newestInputFileName: string; - newestDeclarationFileContentChangedTime: Date; - newestOutputFileTime: Date; - newestOutputFileName: string; - oldestOutputFileName: string; + newestInputFileTime?: Date; + newestInputFileName?: string; + newestDeclarationFileContentChangedTime?: Date; + newestOutputFileTime?: Date; + newestOutputFileName?: string; + oldestOutputFileName?: string; } /** * One or more of the outputs of the project does not exist. @@ -4606,6 +4583,80 @@ declare namespace ts { function getAllProjectOutputs(project: ParsedCommandLine): ReadonlyArray; function formatUpToDateStatus(configFileName: string, status: UpToDateStatus, relName: (fileName: string) => string, formatMessage: (message: DiagnosticMessage, ...args: string[]) => T): T | undefined; } +declare namespace ts.server { + type ActionSet = "action::set"; + type ActionInvalidate = "action::invalidate"; + type ActionPackageInstalled = "action::packageInstalled"; + type EventTypesRegistry = "event::typesRegistry"; + type EventBeginInstallTypes = "event::beginInstallTypes"; + type EventEndInstallTypes = "event::endInstallTypes"; + type EventInitializationFailed = "event::initializationFailed"; + interface SortedReadonlyArray extends ReadonlyArray { + " __sortedArrayBrand": any; + } + interface TypingInstallerResponse { + readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed; + } + interface TypingInstallerRequestWithProjectName { + readonly projectName: string; + } + interface DiscoverTypings extends TypingInstallerRequestWithProjectName { + readonly fileNames: string[]; + readonly projectRootPath: Path; + readonly compilerOptions: CompilerOptions; + readonly typeAcquisition: TypeAcquisition; + readonly unresolvedImports: SortedReadonlyArray; + readonly cachePath?: string; + readonly kind: "discover"; + } + interface CloseProject extends TypingInstallerRequestWithProjectName { + readonly kind: "closeProject"; + } + interface TypesRegistryRequest { + readonly kind: "typesRegistry"; + } + interface InstallPackageRequest extends TypingInstallerRequestWithProjectName { + readonly kind: "installPackage"; + readonly fileName: Path; + readonly packageName: string; + readonly projectRootPath: Path; + } + interface PackageInstalledResponse extends ProjectResponse { + readonly kind: ActionPackageInstalled; + readonly success: boolean; + readonly message: string; + } + interface InitializationFailedResponse extends TypingInstallerResponse { + readonly kind: EventInitializationFailed; + readonly message: string; + } + interface ProjectResponse extends TypingInstallerResponse { + readonly projectName: string; + } + 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; + } + interface SetTypings extends ProjectResponse { + readonly typeAcquisition: TypeAcquisition; + readonly compilerOptions: CompilerOptions; + readonly typings: string[]; + readonly unresolvedImports: SortedReadonlyArray; + readonly kind: ActionSet; + } +} declare namespace ts { interface Node { getSourceFile(): SourceFile; @@ -4784,7 +4835,7 @@ declare namespace ts { getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; + getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; @@ -4844,13 +4895,54 @@ declare namespace ts { type OrganizeImportsScope = CombinedCodeFixScope; type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<"; interface GetCompletionsAtPositionOptions extends UserPreferences { - /** If the editor is asking for completions because a certain character was typed, and not because the user explicitly requested them, this should be set. */ + /** + * If the editor is asking for completions because a certain character was typed + * (as opposed to when the user explicitly requested them) this should be set. + */ triggerCharacter?: CompletionsTriggerCharacter; /** @deprecated Use includeCompletionsForModuleExports */ includeExternalModuleExports?: boolean; /** @deprecated Use includeCompletionsWithInsertText */ includeInsertTextCompletions?: boolean; } + type SignatureHelpTriggerCharacter = "," | "(" | "<"; + type SignatureHelpRetriggerCharacter = SignatureHelpTriggerCharacter | ")"; + interface SignatureHelpItemsOptions { + triggerReason?: SignatureHelpTriggerReason; + } + type SignatureHelpTriggerReason = SignatureHelpInvokedReason | SignatureHelpCharacterTypedReason | SignatureHelpRetriggeredReason; + /** + * Signals that the user manually requested signature help. + * The language service will unconditionally attempt to provide a result. + */ + interface SignatureHelpInvokedReason { + kind: "invoked"; + triggerCharacter?: undefined; + } + /** + * Signals that the signature help request came from a user typing a character. + * Depending on the character and the syntactic context, the request may or may not be served a result. + */ + interface SignatureHelpCharacterTypedReason { + kind: "characterTyped"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter: SignatureHelpTriggerCharacter; + } + /** + * Signals that this signature help request came from typing a character or moving the cursor. + * This should only occur if a signature help session was already active and the editor needs to see if it should adjust. + * The language service will unconditionally attempt to provide a result. + * `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + */ + interface SignatureHelpRetriggeredReason { + kind: "retrigger"; + /** + * Character that was responsible for triggering signature help. + */ + triggerCharacter?: SignatureHelpRetriggerCharacter; + } interface ApplyCodeActionCommandResult { successMessage: string; } @@ -5038,7 +5130,7 @@ declare namespace ts { name: string; kind: ScriptElementKind; kindModifiers: string; - matchKind: string; + matchKind: "exact" | "prefix" | "substring" | "camelCase"; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; @@ -5569,5 +5661,5 @@ declare namespace ts { */ function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; } -//# sourceMappingURL=typescriptServices.d.ts.map -export = ts \ No newline at end of file + +export = ts; \ No newline at end of file diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt index 4d6fbd063ae28..f30dabd56893e 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt +++ b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt @@ -21,7 +21,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error Types of property '0' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number]'. - Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'. + Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '[string, number]' is not assignable to type '[string]'. Types of property 'length' are incompatible. Type '2' is not assignable to type '1'. @@ -29,14 +29,14 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error Types of property 'length' are incompatible. Type '2' is not assignable to type '1'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(29,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string]'. - Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'. + Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(31,5): error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. Types of property '0' are incompatible. Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, string]'. - Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'. + Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'. ==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (19 errors) ==== @@ -102,7 +102,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error var l3: [number] = z; ~~ !!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number]'. -!!! error TS2322: Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'. +!!! error TS2322: Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'. var m1: [string] = x; ~~ !!! error TS2322: Type '[string, number]' is not assignable to type '[string]'. @@ -116,7 +116,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error var m3: [string] = z; ~~ !!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string]'. -!!! error TS2322: Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'. +!!! error TS2322: Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'. var n1: [number, string] = x; ~~ !!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. @@ -129,7 +129,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error var n3: [number, string] = z; ~~ !!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, string]'. -!!! error TS2322: Property 'push' is missing in type '{ 0: string; 1: number; length: 2; }'. +!!! error TS2322: Property 'pop' is missing in type '{ 0: string; 1: number; length: 2; }'. var o1: [string, number] = x; var o2: [string, number] = y; var o3: [string, number] = y; diff --git a/tests/baselines/reference/arrayAssignmentTest1.errors.txt b/tests/baselines/reference/arrayAssignmentTest1.errors.txt index 3cce5658c1368..e07306b19b21c 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.errors.txt +++ b/tests/baselines/reference/arrayAssignmentTest1.errors.txt @@ -34,7 +34,7 @@ tests/cases/compiler/arrayAssignmentTest1.ts(77,1): error TS2322: Type 'I1[]' is Type 'I1' is not assignable to type 'C3'. Property 'CM3M1' is missing in type 'I1'. tests/cases/compiler/arrayAssignmentTest1.ts(79,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'. - Property 'push' is missing in type '() => C1'. + Property 'pop' is missing in type '() => C1'. tests/cases/compiler/arrayAssignmentTest1.ts(80,1): error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'. Property 'length' is missing in type '{ one: number; }'. tests/cases/compiler/arrayAssignmentTest1.ts(82,1): error TS2322: Type 'C1' is not assignable to type 'any[]'. @@ -177,7 +177,7 @@ tests/cases/compiler/arrayAssignmentTest1.ts(85,1): error TS2322: Type 'I1' is n arr_any = f1; // should be an error - is ~~~~~~~ !!! error TS2322: Type '() => C1' is not assignable to type 'any[]'. -!!! error TS2322: Property 'push' is missing in type '() => C1'. +!!! error TS2322: Property 'pop' is missing in type '() => C1'. arr_any = o1; // should be an error - is ~~~~~~~ !!! error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'. diff --git a/tests/baselines/reference/arrayAssignmentTest2.errors.txt b/tests/baselines/reference/arrayAssignmentTest2.errors.txt index a2cc6b3b954e6..eca2f8ad6f5b7 100644 --- a/tests/baselines/reference/arrayAssignmentTest2.errors.txt +++ b/tests/baselines/reference/arrayAssignmentTest2.errors.txt @@ -8,9 +8,9 @@ tests/cases/compiler/arrayAssignmentTest2.ts(49,1): error TS2322: Type 'I1[]' is Type 'I1' is not assignable to type 'C3'. Property 'CM3M1' is missing in type 'I1'. tests/cases/compiler/arrayAssignmentTest2.ts(51,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'. - Property 'push' is missing in type '() => C1'. + Property 'pop' is missing in type '() => C1'. tests/cases/compiler/arrayAssignmentTest2.ts(52,1): error TS2322: Type '() => any' is not assignable to type 'any[]'. - Property 'push' is missing in type '() => any'. + Property 'pop' is missing in type '() => any'. tests/cases/compiler/arrayAssignmentTest2.ts(53,1): error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'. Property 'length' is missing in type '{ one: number; }'. tests/cases/compiler/arrayAssignmentTest2.ts(55,1): error TS2322: Type 'C1' is not assignable to type 'any[]'. @@ -89,11 +89,11 @@ tests/cases/compiler/arrayAssignmentTest2.ts(58,1): error TS2322: Type 'I1' is n arr_any = f1; // should be an error - is ~~~~~~~ !!! error TS2322: Type '() => C1' is not assignable to type 'any[]'. -!!! error TS2322: Property 'push' is missing in type '() => C1'. +!!! error TS2322: Property 'pop' is missing in type '() => C1'. arr_any = function () { return null;} // should be an error - is ~~~~~~~ !!! error TS2322: Type '() => any' is not assignable to type 'any[]'. -!!! error TS2322: Property 'push' is missing in type '() => any'. +!!! error TS2322: Property 'pop' is missing in type '() => any'. arr_any = o1; // should be an error - is ~~~~~~~ !!! error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'. diff --git a/tests/baselines/reference/arrayAssignmentTest4.errors.txt b/tests/baselines/reference/arrayAssignmentTest4.errors.txt index 0fb8112aa922a..2546c6abf0491 100644 --- a/tests/baselines/reference/arrayAssignmentTest4.errors.txt +++ b/tests/baselines/reference/arrayAssignmentTest4.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/arrayAssignmentTest4.ts(22,1): error TS2322: Type '() => any' is not assignable to type 'any[]'. - Property 'push' is missing in type '() => any'. + Property 'pop' is missing in type '() => any'. tests/cases/compiler/arrayAssignmentTest4.ts(23,1): error TS2322: Type 'C3' is not assignable to type 'any[]'. Property 'length' is missing in type 'C3'. @@ -29,7 +29,7 @@ tests/cases/compiler/arrayAssignmentTest4.ts(23,1): error TS2322: Type 'C3' is n arr_any = function () { return null;} // should be an error - is ~~~~~~~ !!! error TS2322: Type '() => any' is not assignable to type 'any[]'. -!!! error TS2322: Property 'push' is missing in type '() => any'. +!!! error TS2322: Property 'pop' is missing in type '() => any'. arr_any = c3; // should be an error - is ~~~~~~~ !!! error TS2322: Type 'C3' is not assignable to type 'any[]'. diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index 8ce34900b0a7b..d1c99742a2729 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -1,7 +1,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(10,5): error TS2322: Type '[]' is not assignable to type '[any, any, any]'. Property '0' is missing in type '[]'. -tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,38): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,48): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,51): error TS2322: Type 'true' is not assignable to type 'number'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'. Types of property 'length' are incompatible. Type '4' is not assignable to type '2'. @@ -10,15 +11,13 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. Property '0' is missing in type 'number[]'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. - Types of property 'push' are incompatible. - Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'. - Types of parameters 'items' and 'items' are incompatible. - Type 'Number' is not assignable to type 'string | number'. - Type 'Number' is not assignable to type 'number'. - 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. + Types of property 'pop' are incompatible. + Type '() => string | number' is not assignable to type '() => Number'. + Type 'string | number' is not assignable to type 'Number'. + Type 'string' is not assignable to type 'Number'. -==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ==== +==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (8 errors) ==== // Each element expression in a non-empty array literal is processed as follows: // - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) // by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, @@ -33,9 +32,12 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error !!! error TS2322: Type '[]' is not assignable to type '[any, any, any]'. !!! error TS2322: Property '0' is missing in type '[]'. var a1: [boolean, string, number] = ["string", 1, true]; // Error - ~~ -!!! error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. + ~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + ~~~~ +!!! error TS2322: Type 'true' is not assignable to type 'number'. // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), @@ -71,10 +73,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[] ~~ !!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. -!!! error TS2322: Types of property 'push' are incompatible. -!!! error TS2322: Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'. -!!! error TS2322: Types of parameters 'items' and 'items' are incompatible. -!!! error TS2322: Type 'Number' is not assignable to type 'string | number'. -!!! error TS2322: Type 'Number' is not assignable to type 'number'. -!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. +!!! error TS2322: Types of property 'pop' are incompatible. +!!! error TS2322: Type '() => string | number' is not assignable to type '() => Number'. +!!! error TS2322: Type 'string | number' is not assignable to type 'Number'. +!!! error TS2322: Type 'string' is not assignable to type 'Number'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt index ff79716cab832..1c100d66d9a68 100644 --- a/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt +++ b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt @@ -8,4 +8,5 @@ tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,10): error TS ~ !!! error TS2304: Cannot find name 'c'. ~~~~~ -!!! error TS2552: Cannot find name 'tupel'. Did you mean 'tuple'? \ No newline at end of file +!!! error TS2552: Cannot find name 'tupel'. Did you mean 'tuple'? +!!! related TS2728 tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts:1:5: 'tuple' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt b/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt index 204135cd004e5..8ba04d8ab2c29 100644 --- a/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt +++ b/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt @@ -1,6 +1,4 @@ -tests/cases/compiler/assignmentToObjectAndFunction.ts(1,5): error TS2322: Type '{ toString: number; }' is not assignable to type 'Object'. - Types of property 'toString' are incompatible. - Type 'number' is not assignable to type '() => string'. +tests/cases/compiler/assignmentToObjectAndFunction.ts(1,24): error TS2322: Type 'number' is not assignable to type '() => string'. tests/cases/compiler/assignmentToObjectAndFunction.ts(8,5): error TS2322: Type '{}' is not assignable to type 'Function'. Property 'apply' is missing in type '{}'. tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type 'typeof bad' is not assignable to type 'Function'. @@ -10,10 +8,9 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type ==== tests/cases/compiler/assignmentToObjectAndFunction.ts (3 errors) ==== var errObj: Object = { toString: 0 }; // Error, incompatible toString - ~~~~~~ -!!! error TS2322: Type '{ toString: number; }' is not assignable to type 'Object'. -!!! error TS2322: Types of property 'toString' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type '() => string'. + ~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type '() => string'. +!!! related TS6500 /.ts/lib.es5.d.ts:125:5: The expected type comes from property 'toString' which is declared here on type 'Object' var goodObj: Object = { toString(x?) { return ""; diff --git a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt index 907fcce4c315b..b5d6d0668a7dc 100644 --- a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt +++ b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt @@ -6,15 +6,9 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(17,1): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(18,2): error TS2539: Cannot assign to 'M' because it is not a variable. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(25,5): error TS2539: Cannot assign to 'M3' because it is not a variable. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(31,1): error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(32,1): error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(33,1): error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'. - Types of property 'x' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(31,11): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(32,13): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(33,13): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(37,1): error TS2539: Cannot assign to 'fn' because it is not a variable. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(38,2): error TS2539: Cannot assign to 'fn' because it is not a variable. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(43,5): error TS2322: Type '""' is not assignable to type 'number'. @@ -78,20 +72,17 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize (M2.M3) = { x: 3 }; // OK M2.M3 = { x: '' }; // Error - ~~~~~ -!!! error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts:22:20: The expected type comes from property 'x' which is declared here on type 'typeof M3' (M2).M3 = { x: '' }; // Error - ~~~~~~~ -!!! error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts:22:20: The expected type comes from property 'x' which is declared here on type 'typeof M3' (M2.M3) = { x: '' }; // Error - ~~~~~~~ -!!! error TS2322: Type '{ x: string; }' is not assignable to type 'typeof M3'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts:22:20: The expected type comes from property 'x' which is declared here on type 'typeof M3' function fn() { } diff --git a/tests/baselines/reference/augmentExportEquals3.types b/tests/baselines/reference/augmentExportEquals3.types index 67aa8399af349..d66b166c5abfe 100644 --- a/tests/baselines/reference/augmentExportEquals3.types +++ b/tests/baselines/reference/augmentExportEquals3.types @@ -1,9 +1,9 @@ === tests/cases/compiler/file1.ts === function foo() {} ->foo : typeof foo +>foo : typeof import("o") namespace foo { ->foo : typeof foo +>foo : typeof import("o") export var v = 1; >v : number diff --git a/tests/baselines/reference/augmentExportEquals3_1.types b/tests/baselines/reference/augmentExportEquals3_1.types index b0c0e806f57b5..08e21c6172c8b 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.types +++ b/tests/baselines/reference/augmentExportEquals3_1.types @@ -3,10 +3,10 @@ declare module "file1" { >"file1" : typeof import("file1") function foo(): void; ->foo : typeof foo +>foo : typeof import("o") namespace foo { ->foo : typeof foo +>foo : typeof import("o") export var v: number; >v : number diff --git a/tests/baselines/reference/augmentExportEquals4.types b/tests/baselines/reference/augmentExportEquals4.types index c2823d794e0eb..ebdacceae2b5f 100644 --- a/tests/baselines/reference/augmentExportEquals4.types +++ b/tests/baselines/reference/augmentExportEquals4.types @@ -1,9 +1,9 @@ === tests/cases/compiler/file1.ts === class foo {} ->foo : foo +>foo : import("o") namespace foo { ->foo : typeof foo +>foo : typeof import("o") export var v = 1; >v : number diff --git a/tests/baselines/reference/augmentExportEquals4_1.types b/tests/baselines/reference/augmentExportEquals4_1.types index dbb36c39e4217..7f28d24d64e29 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.types +++ b/tests/baselines/reference/augmentExportEquals4_1.types @@ -3,10 +3,10 @@ declare module "file1" { >"file1" : typeof import("file1") class foo {} ->foo : foo +>foo : import("o") namespace foo { ->foo : typeof foo +>foo : typeof import("o") export var v: number; >v : number diff --git a/tests/baselines/reference/augmentExportEquals5.types b/tests/baselines/reference/augmentExportEquals5.types index f9cc2bfeae95a..fd5bb168f805f 100644 --- a/tests/baselines/reference/augmentExportEquals5.types +++ b/tests/baselines/reference/augmentExportEquals5.types @@ -16,12 +16,12 @@ declare module "express" { >"express" : typeof import("express") function e(): e.Express; ->e : typeof e +>e : typeof import("e") >e : any ->Express : e.Express +>Express : import("e").Express namespace e { ->e : typeof e +>e : typeof import("e") interface IRoute { >IRoute : IRoute diff --git a/tests/baselines/reference/augmentExportEquals6.types b/tests/baselines/reference/augmentExportEquals6.types index 6948535c6da02..a8e9c36a4ee40 100644 --- a/tests/baselines/reference/augmentExportEquals6.types +++ b/tests/baselines/reference/augmentExportEquals6.types @@ -1,9 +1,9 @@ === tests/cases/compiler/file1.ts === class foo {} ->foo : foo +>foo : import("o") namespace foo { ->foo : typeof foo +>foo : typeof import("o") export class A {} >A : A diff --git a/tests/baselines/reference/augmentExportEquals6_1.types b/tests/baselines/reference/augmentExportEquals6_1.types index 3e7c2596df48e..3bde1ec600caf 100644 --- a/tests/baselines/reference/augmentExportEquals6_1.types +++ b/tests/baselines/reference/augmentExportEquals6_1.types @@ -3,10 +3,10 @@ declare module "file1" { >"file1" : typeof import("file1") class foo {} ->foo : foo +>foo : import("o") namespace foo { ->foo : typeof foo +>foo : typeof import("o") class A {} >A : A diff --git a/tests/baselines/reference/bangInModuleName.types b/tests/baselines/reference/bangInModuleName.types index cb1a66f986d4e..b475bdd903cd5 100644 --- a/tests/baselines/reference/bangInModuleName.types +++ b/tests/baselines/reference/bangInModuleName.types @@ -10,7 +10,7 @@ declare module "http" { } declare module 'intern/dojo/node!http' { ->'intern/dojo/node!http' : typeof 'intern/dojo/node!http' +>'intern/dojo/node!http' : typeof import("intern/dojo/node!http") import http = require('http'); >http : typeof http diff --git a/tests/baselines/reference/baseCheck.errors.txt b/tests/baselines/reference/baseCheck.errors.txt index 0ae410d4e3485..ca99ca426fcca 100644 --- a/tests/baselines/reference/baseCheck.errors.txt +++ b/tests/baselines/reference/baseCheck.errors.txt @@ -21,6 +21,7 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'. super(0, loc); ~~~ !!! error TS2552: Cannot find name 'loc'. Did you mean 'ELoc'? +!!! related TS2728 tests/cases/compiler/baseCheck.ts:2:7: 'ELoc' is declared here. } m() { diff --git a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt index 031fe18375415..5f46ee70d2aaa 100644 --- a/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt +++ b/tests/baselines/reference/baseClassImprovedMismatchErrors.errors.txt @@ -5,7 +5,6 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2416: Prop Types of property 'n' are incompatible. Type 'string | Derived' is not assignable to type 'string | Base'. Type 'Derived' is not assignable to type 'string | Base'. - Type 'Derived' is not assignable to type 'Base'. tests/cases/compiler/baseClassImprovedMismatchErrors.ts(9,5): error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'. Type '() => string | number' is not assignable to type '() => number'. Type 'string | number' is not assignable to type 'number'. @@ -17,7 +16,6 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(14,5): error TS2416: Pro Types of property 'n' are incompatible. Type 'string | DerivedInterface' is not assignable to type 'string | Base'. Type 'DerivedInterface' is not assignable to type 'string | Base'. - Type 'DerivedInterface' is not assignable to type 'Base'. tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Property 'fn' in type 'DerivedInterface' is not assignable to the same property in base type 'Base'. Type '() => string | number' is not assignable to type '() => number'. Type 'string | number' is not assignable to type 'number'. @@ -41,7 +39,6 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Pro !!! error TS2416: Types of property 'n' are incompatible. !!! error TS2416: Type 'string | Derived' is not assignable to type 'string | Base'. !!! error TS2416: Type 'Derived' is not assignable to type 'string | Base'. -!!! error TS2416: Type 'Derived' is not assignable to type 'Base'. fn() { ~~ !!! error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'. @@ -61,7 +58,6 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Pro !!! error TS2416: Types of property 'n' are incompatible. !!! error TS2416: Type 'string | DerivedInterface' is not assignable to type 'string | Base'. !!! error TS2416: Type 'DerivedInterface' is not assignable to type 'string | Base'. -!!! error TS2416: Type 'DerivedInterface' is not assignable to type 'Base'. fn() { ~~ !!! error TS2416: Property 'fn' in type 'DerivedInterface' is not assignable to the same property in base type 'Base'. diff --git a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.errors.txt b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.errors.txt index 3a55ebbfded50..042f5e6de4fc7 100644 --- a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.errors.txt +++ b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.errors.txt @@ -8,13 +8,16 @@ tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts(8,7): error TS2448: Bloc for (let {[a]: a} of [{ }]) continue; ~ !!! error TS2448: Block-scoped variable 'a' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts:2:16: 'a' is declared here. // 2: for (let {[a]: a} = { }; false; ) continue; ~ !!! error TS2448: Block-scoped variable 'a' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts:5:16: 'a' is declared here. // 3: let {[b]: b} = { }; ~ -!!! error TS2448: Block-scoped variable 'b' used before its declaration. \ No newline at end of file +!!! error TS2448: Block-scoped variable 'b' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts:8:11: 'b' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt index 94c58bccb041c..4de97fa02a420 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.errors.txt @@ -9,6 +9,7 @@ tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(100,12): error TS2448: let a = x; ~ !!! error TS2448: Block-scoped variable 'x' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts:3:9: 'x' is declared here. let x; } @@ -67,6 +68,7 @@ tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(100,12): error TS2448: static a = x; ~ !!! error TS2448: Block-scoped variable 'x' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts:60:9: 'x' is declared here. } let x; } @@ -76,6 +78,7 @@ tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(100,12): error TS2448: static a = x; ~ !!! error TS2448: Block-scoped variable 'x' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts:67:9: 'x' is declared here. } let x; } @@ -113,6 +116,7 @@ tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts(100,12): error TS2448: a: x ~ !!! error TS2448: Block-scoped variable 'x' used before its declaration. +!!! related TS2728 tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts:102:9: 'x' is declared here. } let x } \ No newline at end of file diff --git a/tests/baselines/reference/callbackCrossModule.symbols b/tests/baselines/reference/callbackCrossModule.symbols index be8175c4a1157..7c094d4f93689 100644 --- a/tests/baselines/reference/callbackCrossModule.symbols +++ b/tests/baselines/reference/callbackCrossModule.symbols @@ -4,6 +4,7 @@ * @return {any} I don't even know what this should return */ module.exports = C +>module.exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0)) >module : Symbol(export=, Decl(mod1.js, 0, 0)) >exports : Symbol(export=, Decl(mod1.js, 0, 0)) >C : Symbol(C, Decl(mod1.js, 4, 18)) diff --git a/tests/baselines/reference/callbackCrossModule.types b/tests/baselines/reference/callbackCrossModule.types index 2f7619585b940..c3f0aabbc0091 100644 --- a/tests/baselines/reference/callbackCrossModule.types +++ b/tests/baselines/reference/callbackCrossModule.types @@ -5,9 +5,9 @@ */ module.exports = C >module.exports = C : typeof C ->module.exports : any ->module : any ->exports : any +>module.exports : typeof C +>module : { "tests/cases/conformance/jsdoc/mod1": typeof C; } +>exports : typeof C >C : typeof C function C() { diff --git a/tests/baselines/reference/callbackTag2.types b/tests/baselines/reference/callbackTag2.types index 953d7d335ad68..94c6997b63c4f 100644 --- a/tests/baselines/reference/callbackTag2.types +++ b/tests/baselines/reference/callbackTag2.types @@ -43,7 +43,7 @@ var outside = n => n + 1; /** @type {Final<{ fantasy }, { heroes }>} */ var noreturn = (barts, tidus, noctis) => "cecil" >noreturn : Final<{ fantasy: any; }, { heroes: any; }> ->(barts, tidus, noctis) => "cecil" : (barts: { fantasy: any; }, tidus: { heroes: any; }, noctis: { heroes: any; } & { fantasy: any; }) => "cecil" +>(barts, tidus, noctis) => "cecil" : (barts: { fantasy: any; }, tidus: { heroes: any; }, noctis: { heroes: any; } & { fantasy: any; }) => "cecil" | "zidane" >barts : { fantasy: any; } >tidus : { heroes: any; } >noctis : { heroes: any; } & { fantasy: any; } diff --git a/tests/baselines/reference/callbackTagNamespace.types b/tests/baselines/reference/callbackTagNamespace.types index 8bca9a56a5c46..11d4fa5f7e682 100644 --- a/tests/baselines/reference/callbackTagNamespace.types +++ b/tests/baselines/reference/callbackTagNamespace.types @@ -11,7 +11,7 @@ var x = 1; /** @type {NS.Nested.Inner} */ function f(space, peace) { ->f : (space: any, peace: any) => string +>f : (space: any, peace: any) => string | number >space : any >peace : any diff --git a/tests/baselines/reference/capturedLetConstInLoop5.errors.txt b/tests/baselines/reference/capturedLetConstInLoop5.errors.txt index cb641af478dab..7ae1e69be63df 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/capturedLetConstInLoop5.ts(174,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop5.ts(229,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5.ts(174,13): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop5.ts(229,13): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. ==== tests/cases/compiler/capturedLetConstInLoop5.ts (2 errors) ==== @@ -178,7 +178,7 @@ tests/cases/compiler/capturedLetConstInLoop5.ts(229,13): error TS2365: Operator (() => x + v); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. return; } } @@ -235,7 +235,7 @@ tests/cases/compiler/capturedLetConstInLoop5.ts(229,13): error TS2365: Operator (() => x + y + v); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. return; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt index 1826ffa99f734..7d62d8db10ce2 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(174,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(229,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(174,13): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(229,13): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. ==== tests/cases/compiler/capturedLetConstInLoop5_ES6.ts (2 errors) ==== @@ -178,7 +178,7 @@ tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(229,13): error TS2365: Opera (() => x + v); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. return; } } @@ -235,7 +235,7 @@ tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(229,13): error TS2365: Opera (() => x + y + v); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. return; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop6.errors.txt index cc5d238e7afdf..f0a323305d870 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/capturedLetConstInLoop6.ts(147,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop6.ts(150,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop6.ts(194,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop6.ts(197,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop6.ts(147,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop6.ts(150,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop6.ts(194,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop6.ts(197,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. ==== tests/cases/compiler/capturedLetConstInLoop6.ts (4 errors) ==== @@ -153,12 +153,12 @@ tests/cases/compiler/capturedLetConstInLoop6.ts(197,9): error TS2365: Operator ' (() => x); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } } @@ -204,12 +204,12 @@ tests/cases/compiler/capturedLetConstInLoop6.ts(197,9): error TS2365: Operator ' (() => x + y); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt index 4e563153ac9ad..7edbf27370e0b 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(147,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(150,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(194,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(197,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(147,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(150,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(194,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(197,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. ==== tests/cases/compiler/capturedLetConstInLoop6_ES6.ts (4 errors) ==== @@ -153,12 +153,12 @@ tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(197,9): error TS2365: Operat (() => x); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } } @@ -204,12 +204,12 @@ tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(197,9): error TS2365: Operat (() => x + y); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop7.errors.txt b/tests/baselines/reference/capturedLetConstInLoop7.errors.txt index 4b8e512f41a09..0b215dba4bf7c 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop7.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/capturedLetConstInLoop7.ts(230,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7.ts(233,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7.ts(236,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7.ts(239,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7.ts(305,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7.ts(308,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7.ts(311,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7.ts(314,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7.ts(230,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7.ts(233,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7.ts(236,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7.ts(239,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7.ts(305,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7.ts(308,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7.ts(311,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7.ts(314,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. ==== tests/cases/compiler/capturedLetConstInLoop7.ts (8 errors) ==== @@ -240,22 +240,22 @@ tests/cases/compiler/capturedLetConstInLoop7.ts(314,9): error TS2365: Operator ' (() => x); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break l1_c; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l1_c; } } @@ -323,22 +323,22 @@ tests/cases/compiler/capturedLetConstInLoop7.ts(314,9): error TS2365: Operator ' (() => x + y); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break l5_c; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l5_c; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt index 30e2db6a25326..661afd90bb926 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(230,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(233,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(236,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(239,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(305,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(308,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(311,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(314,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(230,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(233,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(236,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(239,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(305,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(308,9): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(311,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(314,9): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. ==== tests/cases/compiler/capturedLetConstInLoop7_ES6.ts (8 errors) ==== @@ -240,22 +240,22 @@ tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(314,9): error TS2365: Operat (() => x); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break l1_c; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l1_c; } } @@ -323,22 +323,22 @@ tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(314,9): error TS2365: Operat (() => x + y); if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break l5_c; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l5_c; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop8.errors.txt b/tests/baselines/reference/capturedLetConstInLoop8.errors.txt index d54c79dfebbd4..cf93d70a01df4 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop8.errors.txt @@ -1,19 +1,19 @@ -tests/cases/compiler/capturedLetConstInLoop8.ts(73,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8.ts(76,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8.ts(79,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8.ts(82,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8.ts(86,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8.ts(89,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8.ts(92,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8.ts(95,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8.ts(98,21): error TS2365: Operator '==' cannot be applied to types '0' and '3'. -tests/cases/compiler/capturedLetConstInLoop8.ts(102,17): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8.ts(105,17): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8.ts(108,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8.ts(111,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8.ts(114,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8.ts(117,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8.ts(120,17): error TS2365: Operator '==' cannot be applied to types '0' and '3'. +tests/cases/compiler/capturedLetConstInLoop8.ts(73,21): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(76,21): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(79,21): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(82,21): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(86,21): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(89,21): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(92,21): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(95,21): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(98,21): error TS2367: This condition will always return 'false' since the types '0' and '3' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(102,17): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(105,17): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(108,17): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(111,17): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(114,17): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(117,17): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8.ts(120,17): error TS2367: This condition will always return 'false' since the types '0' and '3' have no overlap. ==== tests/cases/compiler/capturedLetConstInLoop8.ts (16 errors) ==== @@ -91,84 +91,84 @@ tests/cases/compiler/capturedLetConstInLoop8.ts(120,17): error TS2365: Operator (() => x + y); if (y == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (y == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break l1; } if (y == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break ll1; } if (y == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. continue l0; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l1; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue ll1; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. return "123" } if (x == 3) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '3'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '3' have no overlap. return; } } if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break l1; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l1; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l0; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. return "456"; } if (x == 3) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '3'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '3' have no overlap. return; } } diff --git a/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt index b8e856b66bf88..7181e0ec06e26 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt @@ -1,19 +1,19 @@ -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(73,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(76,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(79,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(82,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(86,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(89,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(92,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(95,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(98,21): error TS2365: Operator '==' cannot be applied to types '0' and '3'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(102,17): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(105,17): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(108,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(111,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(114,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(117,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(120,17): error TS2365: Operator '==' cannot be applied to types '0' and '3'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(73,21): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(76,21): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(79,21): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(82,21): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(86,21): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(89,21): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(92,21): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(95,21): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(98,21): error TS2367: This condition will always return 'false' since the types '0' and '3' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(102,17): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(105,17): error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(108,17): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(111,17): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(114,17): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(117,17): error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(120,17): error TS2367: This condition will always return 'false' since the types '0' and '3' have no overlap. ==== tests/cases/compiler/capturedLetConstInLoop8_ES6.ts (16 errors) ==== @@ -91,84 +91,84 @@ tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(120,17): error TS2365: Opera (() => x + y); if (y == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (y == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break l1; } if (y == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break ll1; } if (y == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. continue l0; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l1; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue ll1; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. return "123" } if (x == 3) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '3'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '3' have no overlap. return; } } if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break; } if (x == 1) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '1' have no overlap. break l1; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l1; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. continue l0; } if (x == 2) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '2' have no overlap. return "456"; } if (x == 3) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '0' and '3'. +!!! error TS2367: This condition will always return 'false' since the types '0' and '3' have no overlap. return; } } diff --git a/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.js b/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.js new file mode 100644 index 0000000000000..ac6e4b7e13502 --- /dev/null +++ b/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.js @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.ts] //// + +//// [index.ts] +import { TypeB } from './type-b'; + +export class Broken { + method () { + return { } as TypeB; + } +} +//// [type-b.ts] +import { Merge } from './types'; +import { TypeA } from './type-a'; + +export type TypeB = Merge; +//// [type-a.ts] +export type TypeA = { + a: string; +} +//// [types.ts] +export type Merge = T & U; + + +//// [types.js] +"use strict"; +exports.__esModule = true; +//// [type-a.js] +"use strict"; +exports.__esModule = true; +//// [type-b.js] +"use strict"; +exports.__esModule = true; +//// [index.js] +"use strict"; +exports.__esModule = true; +var Broken = /** @class */ (function () { + function Broken() { + } + Broken.prototype.method = function () { + return {}; + }; + return Broken; +}()); +exports.Broken = Broken; + + +//// [types.d.ts] +export declare type Merge = T & U; +//// [type-a.d.ts] +export declare type TypeA = { + a: string; +}; +//// [type-b.d.ts] +import { Merge } from './types'; +import { TypeA } from './type-a'; +export declare type TypeB = Merge; +//// [index.d.ts] +export declare class Broken { + method(): import("./types").Merge; +} diff --git a/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.symbols b/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.symbols new file mode 100644 index 0000000000000..2b5c3accb2712 --- /dev/null +++ b/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.symbols @@ -0,0 +1,45 @@ +=== tests/cases/compiler/Uppercased_Dir/src/index.ts === +import { TypeB } from './type-b'; +>TypeB : Symbol(TypeB, Decl(index.ts, 0, 8)) + +export class Broken { +>Broken : Symbol(Broken, Decl(index.ts, 0, 33)) + + method () { +>method : Symbol(Broken.method, Decl(index.ts, 2, 21)) + + return { } as TypeB; +>TypeB : Symbol(TypeB, Decl(index.ts, 0, 8)) + } +} +=== tests/cases/compiler/Uppercased_Dir/src/type-b.ts === +import { Merge } from './types'; +>Merge : Symbol(Merge, Decl(type-b.ts, 0, 8)) + +import { TypeA } from './type-a'; +>TypeA : Symbol(TypeA, Decl(type-b.ts, 1, 8)) + +export type TypeB = MergeTypeB : Symbol(TypeB, Decl(type-b.ts, 1, 33)) +>Merge : Symbol(Merge, Decl(type-b.ts, 0, 8)) +>TypeA : Symbol(TypeA, Decl(type-b.ts, 1, 8)) + + b: string; +>b : Symbol(b, Decl(type-b.ts, 3, 34)) + +}>; +=== tests/cases/compiler/Uppercased_Dir/src/type-a.ts === +export type TypeA = { +>TypeA : Symbol(TypeA, Decl(type-a.ts, 0, 0)) + + a: string; +>a : Symbol(a, Decl(type-a.ts, 0, 21)) +} +=== tests/cases/compiler/Uppercased_Dir/src/types.ts === +export type Merge = T & U; +>Merge : Symbol(Merge, Decl(types.ts, 0, 0)) +>T : Symbol(T, Decl(types.ts, 0, 18)) +>U : Symbol(U, Decl(types.ts, 0, 20)) +>T : Symbol(T, Decl(types.ts, 0, 18)) +>U : Symbol(U, Decl(types.ts, 0, 20)) + diff --git a/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.types b/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.types new file mode 100644 index 0000000000000..59401c34ae720 --- /dev/null +++ b/tests/baselines/reference/caseInsensitiveFileSystemWithCapsImportTypeDeclarations.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/Uppercased_Dir/src/index.ts === +import { TypeB } from './type-b'; +>TypeB : any + +export class Broken { +>Broken : Broken + + method () { +>method : () => import("tests/cases/compiler/Uppercased_Dir/src/types").Merge + + return { } as TypeB; +>{ } as TypeB : import("tests/cases/compiler/Uppercased_Dir/src/types").Merge +>{ } : {} +>TypeB : import("tests/cases/compiler/Uppercased_Dir/src/types").Merge + } +} +=== tests/cases/compiler/Uppercased_Dir/src/type-b.ts === +import { Merge } from './types'; +>Merge : any + +import { TypeA } from './type-a'; +>TypeA : any + +export type TypeB = MergeTypeB : Merge +>Merge : Merge +>TypeA : TypeA + + b: string; +>b : string + +}>; +=== tests/cases/compiler/Uppercased_Dir/src/type-a.ts === +export type TypeA = { +>TypeA : TypeA + + a: string; +>a : string +} +=== tests/cases/compiler/Uppercased_Dir/src/types.ts === +export type Merge = T & U; +>Merge : Merge +>T : T +>U : U +>T : T +>U : U + diff --git a/tests/baselines/reference/cf.errors.txt b/tests/baselines/reference/cf.errors.txt index 8f5f82f816962..910ffe5d88d37 100644 --- a/tests/baselines/reference/cf.errors.txt +++ b/tests/baselines/reference/cf.errors.txt @@ -14,7 +14,7 @@ tests/cases/compiler/cf.ts(36,13): error TS7027: Unreachable code detected. if (y==7) { continue L1; x=11; - ~ + ~~~~~ !!! error TS7027: Unreachable code detected. } if (y==3) { @@ -28,7 +28,7 @@ tests/cases/compiler/cf.ts(36,13): error TS7027: Unreachable code detected. if (y==20) { break; x=12; - ~ + ~~~~~ !!! error TS7027: Unreachable code detected. } } while (y<41); @@ -41,13 +41,13 @@ tests/cases/compiler/cf.ts(36,13): error TS7027: Unreachable code detected. L3: if (xA : typeof A >prototype : { [x: string]: any; m(n: number): number; } >B.prototype = { /** @param {number} n */ m(n) { return n + 1 }} : { [x: string]: any; m(n: number): number; } ->B.prototype : { [x: string]: any; } +>B.prototype : { [x: string]: any; m(n: number): number; } >B : typeof B ->prototype : { [x: string]: any; } +>prototype : { [x: string]: any; m(n: number): number; } >{ /** @param {number} n */ m(n) { return n + 1 }} : { [x: string]: any; m(n: number): number; } /** @param {number} n */ diff --git a/tests/baselines/reference/checkDestructuringShorthandAssigment.errors.txt b/tests/baselines/reference/checkDestructuringShorthandAssigment.errors.txt new file mode 100644 index 0000000000000..aca20286905c6 --- /dev/null +++ b/tests/baselines/reference/checkDestructuringShorthandAssigment.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/bug25434.js(4,9): error TS2304: Cannot find name 'b'. + + +==== tests/cases/compiler/bug25434.js (1 errors) ==== + // should not crash while checking + function Test({ b = '' } = {}) {} + + Test(({ b = '5' } = {})); + ~ +!!! error TS2304: Cannot find name 'b'. + \ No newline at end of file diff --git a/tests/baselines/reference/checkDestructuringShorthandAssigment.symbols b/tests/baselines/reference/checkDestructuringShorthandAssigment.symbols new file mode 100644 index 0000000000000..efe0b4f085033 --- /dev/null +++ b/tests/baselines/reference/checkDestructuringShorthandAssigment.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/bug25434.js === +// should not crash while checking +function Test({ b = '' } = {}) {} +>Test : Symbol(Test, Decl(bug25434.js, 0, 0)) +>b : Symbol(b, Decl(bug25434.js, 1, 15)) + +Test(({ b = '5' } = {})); +>Test : Symbol(Test, Decl(bug25434.js, 0, 0)) +>b : Symbol(b, Decl(bug25434.js, 3, 7)) + diff --git a/tests/baselines/reference/checkDestructuringShorthandAssigment.types b/tests/baselines/reference/checkDestructuringShorthandAssigment.types new file mode 100644 index 0000000000000..9eccb886051f3 --- /dev/null +++ b/tests/baselines/reference/checkDestructuringShorthandAssigment.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/bug25434.js === +// should not crash while checking +function Test({ b = '' } = {}) {} +>Test : ({ b }?: { [x: string]: any; }) => void +>b : string +>'' : "" +>{} : { b?: string; } + +Test(({ b = '5' } = {})); +>Test(({ b = '5' } = {})) : void +>Test : ({ b }?: { [x: string]: any; }) => void +>({ b = '5' } = {}) : { b?: any; } +>{ b = '5' } = {} : { b?: any; } +>{ b = '5' } : { [x: string]: any; b?: any; } +>b : any +>{} : { b?: any; } + diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols index 5d9aa8c53c563..ca9b9a934445f 100644 --- a/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols @@ -24,7 +24,7 @@ x( // come comment // some other comment -// @anohter +// @another x(); >x : Symbol(x, Decl(a.js, 0, 3)) diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.types b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types index a07bf43901b32..953a4f4b910dc 100644 --- a/tests/baselines/reference/checkJsFiles_skipDiagnostics.types +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types @@ -31,7 +31,7 @@ x( // come comment // some other comment -// @anohter +// @another x(); >x() : any diff --git a/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.symbols b/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.symbols index 6826881b83437..3385a5bb58c11 100644 --- a/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.symbols +++ b/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.symbols @@ -22,6 +22,7 @@ export = Foo; /** @typedef {(foo: Foo) => string} FooFun */ module.exports = /** @type {FooFun} */(void 0); +>module.exports : Symbol("tests/cases/compiler/something", Decl(something.js, 0, 0)) >module : Symbol(export=, Decl(something.js, 0, 0)) >exports : Symbol(export=, Decl(something.js, 0, 0)) diff --git a/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types b/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types index 1428cce142b2f..e9385a7152df3 100644 --- a/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types +++ b/tests/baselines/reference/checkJsTypeDefNoUnusedLocalMarked.types @@ -23,9 +23,9 @@ export = Foo; module.exports = /** @type {FooFun} */(void 0); >module.exports = /** @type {FooFun} */(void 0) : (foo: typeof Foo) => string ->module.exports : any ->module : any ->exports : any +>module.exports : (foo: typeof Foo) => string +>module : { "tests/cases/compiler/something": (foo: typeof Foo) => string; } +>exports : (foo: typeof Foo) => string >(void 0) : (foo: typeof Foo) => string >void 0 : undefined >0 : 0 diff --git a/tests/baselines/reference/checkJsdocTypeTag1.types b/tests/baselines/reference/checkJsdocTypeTag1.types index a0c0c53cfeb49..f5ec1c0d33786 100644 --- a/tests/baselines/reference/checkJsdocTypeTag1.types +++ b/tests/baselines/reference/checkJsdocTypeTag1.types @@ -61,7 +61,7 @@ y(1); /** @type {function (number)} */ const x1 = (a) => a + 1; >x1 : (arg0: number) => any ->(a) => a + 1 : (a: number) => number +>(a) => a + 1 : (a: number) => any >a : number >a + 1 : number >a : number diff --git a/tests/baselines/reference/checkJsdocTypeTag2.errors.txt b/tests/baselines/reference/checkJsdocTypeTag2.errors.txt index 3590c10e278e5..1f0feacd67547 100644 --- a/tests/baselines/reference/checkJsdocTypeTag2.errors.txt +++ b/tests/baselines/reference/checkJsdocTypeTag2.errors.txt @@ -3,8 +3,7 @@ tests/cases/conformance/jsdoc/0.js(6,5): error TS2322: Type '"hello"' is not ass tests/cases/conformance/jsdoc/0.js(10,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'. tests/cases/conformance/jsdoc/0.js(17,1): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/jsdoc/0.js(20,21): error TS2339: Property 'concat' does not exist on type 'number'. -tests/cases/conformance/jsdoc/0.js(24,7): error TS2322: Type '(a: number) => number' is not assignable to type '(arg0: number) => string'. - Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/0.js(24,19): error TS2322: Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/jsdoc/0.js (6 errors) ==== @@ -42,7 +41,6 @@ tests/cases/conformance/jsdoc/0.js(24,7): error TS2322: Type '(a: number) => num /** @type {function (number): string} */ const x4 = (a) => a + 1; - ~~ -!!! error TS2322: Type '(a: number) => number' is not assignable to type '(arg0: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. + ~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. x4(0); \ No newline at end of file diff --git a/tests/baselines/reference/checkJsdocTypeTag2.types b/tests/baselines/reference/checkJsdocTypeTag2.types index dfee596ca4e86..3fdd286cde1c7 100644 --- a/tests/baselines/reference/checkJsdocTypeTag2.types +++ b/tests/baselines/reference/checkJsdocTypeTag2.types @@ -13,7 +13,7 @@ var n = "hello"; /** @type {function (number)} */ const x1 = (a) => a + 1; >x1 : (arg0: number) => any ->(a) => a + 1 : (a: number) => number +>(a) => a + 1 : (a: number) => any >a : number >a + 1 : number >a : number @@ -47,7 +47,7 @@ a = x2(0); /** @type {function (number): number} */ const x3 = (a) => a.concat("hi"); >x3 : (arg0: number) => number ->(a) => a.concat("hi") : (a: number) => any +>(a) => a.concat("hi") : (a: number) => number >a : number >a.concat("hi") : any >a.concat : any @@ -63,7 +63,7 @@ x3(0); /** @type {function (number): string} */ const x4 = (a) => a + 1; >x4 : (arg0: number) => string ->(a) => a + 1 : (a: number) => number +>(a) => a + 1 : (a: number) => string >a : number >a + 1 : number >a : number diff --git a/tests/baselines/reference/checkJsdocTypeTag5.errors.txt b/tests/baselines/reference/checkJsdocTypeTag5.errors.txt new file mode 100644 index 0000000000000..022817b999744 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag5.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/jsdoc/test.js(3,17): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/test.js(5,14): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/test.js(7,24): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/test.js(10,17): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/test.js(12,14): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/test.js(14,24): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/test.js(28,5): error TS8030: The type of a function declaration must match the function's signature. +tests/cases/conformance/jsdoc/test.js(34,5): error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. + Type '1' is not assignable to type '2 | 3'. + + +==== tests/cases/conformance/jsdoc/test.js (8 errors) ==== + // all 6 should error on return statement/expression + /** @type {(x: number) => string} */ + function h(x) { return x } + ~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + /** @type {(x: number) => string} */ + var f = x => x + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + /** @type {(x: number) => string} */ + var g = function (x) { return x } + ~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + /** @type {{ (x: number): string }} */ + function i(x) { return x } + ~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + /** @type {{ (x: number): string }} */ + var j = x => x + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + /** @type {{ (x: number): string }} */ + var k = function (x) { return x } + ~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + + /** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ + /** @type {Argle} */ + function blargle(s) { + return 0; + } + + /** @type {0 | 1 | 2} - assignment should not error */ + var zeroonetwo = blargle('hi') + + /** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */ + + /** @type {Gioconda} */ + ~~~~~~~~~~~~~~~~ +!!! error TS8030: The type of a function declaration must match the function's signature. + function monaLisa(sb) { + return typeof sb === 'string' ? 1 : 2; + } + + /** @type {2 | 3} - overloads are not supported, so there will be an error */ + var twothree = monaLisa(false); + ~~~~~~~~ +!!! error TS2322: Type '1 | 2' is not assignable to type '2 | 3'. +!!! error TS2322: Type '1' is not assignable to type '2 | 3'. + \ No newline at end of file diff --git a/tests/baselines/reference/checkJsdocTypeTag5.symbols b/tests/baselines/reference/checkJsdocTypeTag5.symbols new file mode 100644 index 0000000000000..b1910e5d72d0d --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag5.symbols @@ -0,0 +1,69 @@ +=== tests/cases/conformance/jsdoc/test.js === +// all 6 should error on return statement/expression +/** @type {(x: number) => string} */ +function h(x) { return x } +>h : Symbol(h, Decl(test.js, 0, 0)) +>x : Symbol(x, Decl(test.js, 2, 11)) +>x : Symbol(x, Decl(test.js, 2, 11)) + +/** @type {(x: number) => string} */ +var f = x => x +>f : Symbol(f, Decl(test.js, 4, 3)) +>x : Symbol(x, Decl(test.js, 4, 7)) +>x : Symbol(x, Decl(test.js, 4, 7)) + +/** @type {(x: number) => string} */ +var g = function (x) { return x } +>g : Symbol(g, Decl(test.js, 6, 3)) +>x : Symbol(x, Decl(test.js, 6, 18)) +>x : Symbol(x, Decl(test.js, 6, 18)) + +/** @type {{ (x: number): string }} */ +function i(x) { return x } +>i : Symbol(i, Decl(test.js, 6, 33)) +>x : Symbol(x, Decl(test.js, 9, 11)) +>x : Symbol(x, Decl(test.js, 9, 11)) + +/** @type {{ (x: number): string }} */ +var j = x => x +>j : Symbol(j, Decl(test.js, 11, 3)) +>x : Symbol(x, Decl(test.js, 11, 7)) +>x : Symbol(x, Decl(test.js, 11, 7)) + +/** @type {{ (x: number): string }} */ +var k = function (x) { return x } +>k : Symbol(k, Decl(test.js, 13, 3)) +>x : Symbol(x, Decl(test.js, 13, 18)) +>x : Symbol(x, Decl(test.js, 13, 18)) + + +/** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ +/** @type {Argle} */ +function blargle(s) { +>blargle : Symbol(blargle, Decl(test.js, 13, 33)) +>s : Symbol(s, Decl(test.js, 18, 17)) + + return 0; +} + +/** @type {0 | 1 | 2} - assignment should not error */ +var zeroonetwo = blargle('hi') +>zeroonetwo : Symbol(zeroonetwo, Decl(test.js, 23, 3)) +>blargle : Symbol(blargle, Decl(test.js, 13, 33)) + +/** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */ + +/** @type {Gioconda} */ +function monaLisa(sb) { +>monaLisa : Symbol(monaLisa, Decl(test.js, 23, 30)) +>sb : Symbol(sb, Decl(test.js, 28, 18)) + + return typeof sb === 'string' ? 1 : 2; +>sb : Symbol(sb, Decl(test.js, 28, 18)) +} + +/** @type {2 | 3} - overloads are not supported, so there will be an error */ +var twothree = monaLisa(false); +>twothree : Symbol(twothree, Decl(test.js, 33, 3)) +>monaLisa : Symbol(monaLisa, Decl(test.js, 23, 30)) + diff --git a/tests/baselines/reference/checkJsdocTypeTag5.types b/tests/baselines/reference/checkJsdocTypeTag5.types new file mode 100644 index 0000000000000..b16904c700d58 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag5.types @@ -0,0 +1,84 @@ +=== tests/cases/conformance/jsdoc/test.js === +// all 6 should error on return statement/expression +/** @type {(x: number) => string} */ +function h(x) { return x } +>h : (x: number) => string +>x : number +>x : number + +/** @type {(x: number) => string} */ +var f = x => x +>f : (x: number) => string +>x => x : (x: number) => string +>x : number +>x : number + +/** @type {(x: number) => string} */ +var g = function (x) { return x } +>g : (x: number) => string +>function (x) { return x } : (x: number) => string +>x : number +>x : number + +/** @type {{ (x: number): string }} */ +function i(x) { return x } +>i : (x: number) => string +>x : number +>x : number + +/** @type {{ (x: number): string }} */ +var j = x => x +>j : (x: number) => string +>x => x : (x: number) => string +>x : number +>x : number + +/** @type {{ (x: number): string }} */ +var k = function (x) { return x } +>k : (x: number) => string +>function (x) { return x } : (x: number) => string +>x : number +>x : number + + +/** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */ +/** @type {Argle} */ +function blargle(s) { +>blargle : (s: "hi" | "bye") => 0 | 1 | 2 +>s : "hi" | "bye" + + return 0; +>0 : 0 +} + +/** @type {0 | 1 | 2} - assignment should not error */ +var zeroonetwo = blargle('hi') +>zeroonetwo : 0 | 1 | 2 +>blargle('hi') : 0 | 1 | 2 +>blargle : (s: "hi" | "bye") => 0 | 1 | 2 +>'hi' : "hi" + +/** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */ + +/** @type {Gioconda} */ +function monaLisa(sb) { +>monaLisa : (sb: any) => 1 | 2 +>sb : any + + return typeof sb === 'string' ? 1 : 2; +>typeof sb === 'string' ? 1 : 2 : 1 | 2 +>typeof sb === 'string' : boolean +>typeof sb : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>sb : any +>'string' : "string" +>1 : 1 +>2 : 2 +} + +/** @type {2 | 3} - overloads are not supported, so there will be an error */ +var twothree = monaLisa(false); +>twothree : 2 | 3 +>monaLisa(false) : 1 | 2 +>monaLisa : (sb: any) => 1 | 2 +>false : false + diff --git a/tests/baselines/reference/checkJsdocTypeTag6.errors.txt b/tests/baselines/reference/checkJsdocTypeTag6.errors.txt new file mode 100644 index 0000000000000..cc86b6115aff0 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag6.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/jsdoc/test.js(1,5): error TS8030: The type of a function declaration must match the function's signature. +tests/cases/conformance/jsdoc/test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. + Property 'prop' is missing in type '(prop: any) => void'. +tests/cases/conformance/jsdoc/test.js(10,5): error TS8030: The type of a function declaration must match the function's signature. + + +==== tests/cases/conformance/jsdoc/test.js (3 errors) ==== + /** @type {number} */ + ~~~~~~~~~~~~~~ +!!! error TS8030: The type of a function declaration must match the function's signature. + function f() { + return 1 + } + + /** @type {{ prop: string }} */ + var g = function (prop) { + ~ +!!! error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'. +!!! error TS2322: Property 'prop' is missing in type '(prop: any) => void'. + } + + /** @type {(a: number) => number} */ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8030: The type of a function declaration must match the function's signature. + function add1(a, b) { return a + b; } + + /** @type {(a: number, b: number) => number} */ + function add2(a, b) { return a + b; } + + // TODO: Should be an error since signature doesn't match. + /** @type {(a: number, b: number, c: number) => number} */ + function add3(a, b) { return a + b; } + \ No newline at end of file diff --git a/tests/baselines/reference/checkJsdocTypeTag6.symbols b/tests/baselines/reference/checkJsdocTypeTag6.symbols new file mode 100644 index 0000000000000..b7ddd9f289b4e --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag6.symbols @@ -0,0 +1,39 @@ +=== tests/cases/conformance/jsdoc/test.js === +/** @type {number} */ +function f() { +>f : Symbol(f, Decl(test.js, 0, 0)) + + return 1 +} + +/** @type {{ prop: string }} */ +var g = function (prop) { +>g : Symbol(g, Decl(test.js, 6, 3)) +>prop : Symbol(prop, Decl(test.js, 6, 18)) +} + +/** @type {(a: number) => number} */ +function add1(a, b) { return a + b; } +>add1 : Symbol(add1, Decl(test.js, 7, 1)) +>a : Symbol(a, Decl(test.js, 10, 14)) +>b : Symbol(b, Decl(test.js, 10, 16)) +>a : Symbol(a, Decl(test.js, 10, 14)) +>b : Symbol(b, Decl(test.js, 10, 16)) + +/** @type {(a: number, b: number) => number} */ +function add2(a, b) { return a + b; } +>add2 : Symbol(add2, Decl(test.js, 10, 37)) +>a : Symbol(a, Decl(test.js, 13, 14)) +>b : Symbol(b, Decl(test.js, 13, 16)) +>a : Symbol(a, Decl(test.js, 13, 14)) +>b : Symbol(b, Decl(test.js, 13, 16)) + +// TODO: Should be an error since signature doesn't match. +/** @type {(a: number, b: number, c: number) => number} */ +function add3(a, b) { return a + b; } +>add3 : Symbol(add3, Decl(test.js, 13, 37)) +>a : Symbol(a, Decl(test.js, 17, 14)) +>b : Symbol(b, Decl(test.js, 17, 16)) +>a : Symbol(a, Decl(test.js, 17, 14)) +>b : Symbol(b, Decl(test.js, 17, 16)) + diff --git a/tests/baselines/reference/checkJsdocTypeTag6.types b/tests/baselines/reference/checkJsdocTypeTag6.types new file mode 100644 index 0000000000000..a2d9ffbbd7af6 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag6.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsdoc/test.js === +/** @type {number} */ +function f() { +>f : () => number + + return 1 +>1 : 1 +} + +/** @type {{ prop: string }} */ +var g = function (prop) { +>g : { prop: string; } +>function (prop) {} : (prop: any) => void +>prop : any +} + +/** @type {(a: number) => number} */ +function add1(a, b) { return a + b; } +>add1 : (a: any, b: any) => number +>a : any +>b : any +>a + b : any +>a : any +>b : any + +/** @type {(a: number, b: number) => number} */ +function add2(a, b) { return a + b; } +>add2 : (a: number, b: number) => number +>a : number +>b : number +>a + b : number +>a : number +>b : number + +// TODO: Should be an error since signature doesn't match. +/** @type {(a: number, b: number, c: number) => number} */ +function add3(a, b) { return a + b; } +>add3 : (a: number, b: number) => number +>a : number +>b : number +>a + b : number +>a : number +>b : number + diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt index 48559d79cb189..3d1051fdfd441 100644 --- a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt @@ -1,8 +1,6 @@ tests/cases/conformance/jsdoc/0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string | undefined'. -tests/cases/conformance/jsdoc/0.js(7,3): error TS2322: Type '(n1: number) => string' is not assignable to type '(arg0: number) => number'. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/jsdoc/0.js(11,3): error TS2322: Type '(n1: number) => string' is not assignable to type '(arg0: number) => number'. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsdoc/0.js(8,7): error TS2322: Type '"42"' is not assignable to type 'number'. +tests/cases/conformance/jsdoc/0.js(11,20): error TS2322: Type '"lol"' is not assignable to type 'number'. tests/cases/conformance/jsdoc/0.js(13,15): error TS2322: Type '"0"' is not assignable to type 'number'. tests/cases/conformance/jsdoc/0.js(15,3): error TS2322: Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/jsdoc/0.js(19,5): error TS2322: Type 'number' is not assignable to type 'string'. @@ -19,16 +17,14 @@ tests/cases/conformance/jsdoc/0.js(22,22): error TS2345: Argument of type '"0"' !!! error TS2322: Type 'number' is not assignable to type 'string | undefined'. /** @type {function(number): number} */ method1(n1) { - ~~~~~~~ -!!! error TS2322: Type '(n1: number) => string' is not assignable to type '(arg0: number) => number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. return "42"; + ~~~~~~~~~~~~ +!!! error TS2322: Type '"42"' is not assignable to type 'number'. }, /** @type {function(number): number} */ method2: (n1) => "lol", - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '(n1: number) => string' is not assignable to type '(arg0: number) => number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~~~~ +!!! error TS2322: Type '"lol"' is not assignable to type 'number'. /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, ~~~~~~~ diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types index c7f2b7bbeb007..94aad119feb9b 100644 --- a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types @@ -14,7 +14,7 @@ const obj = { /** @type {function(number): number} */ method1(n1) { ->method1 : (n1: number) => string +>method1 : (n1: number) => number >n1 : number return "42"; @@ -24,7 +24,7 @@ const obj = { /** @type {function(number): number} */ method2: (n1) => "lol", >method2 : (arg0: number) => number ->(n1) => "lol" : (n1: number) => string +>(n1) => "lol" : (n1: number) => number >n1 : number >"lol" : "lol" diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt index 986df05ceb686..4851bc3b4669e 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt @@ -32,6 +32,7 @@ tests/cases/conformance/jsx/file.tsx(32,10): error TS2322: Type '{ children: ((u

{ user.NAme }

~~~~ !!! error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'? +!!! related TS2728 tests/cases/conformance/jsx/file.tsx:4:5: 'Name' is declared here. ) } ); diff --git a/tests/baselines/reference/checkJsxGenericTagHasCorrectInferences.errors.txt b/tests/baselines/reference/checkJsxGenericTagHasCorrectInferences.errors.txt index 6a7143b85b2ed..6b81ccd77e1b7 100644 --- a/tests/baselines/reference/checkJsxGenericTagHasCorrectInferences.errors.txt +++ b/tests/baselines/reference/checkJsxGenericTagHasCorrectInferences.errors.txt @@ -1,6 +1,5 @@ -tests/cases/conformance/jsx/file.tsx(13,54): error TS2326: Types of property 'nextValues' are incompatible. - Type '(a: { x: string; }) => string' is not assignable to type '(cur: { x: string; }) => { x: string; }'. - Type 'string' is not assignable to type '{ x: string; }'. +tests/cases/conformance/jsx/file.tsx(13,54): error TS2322: Type '(a: { x: string; }) => string' is not assignable to type '(cur: { x: string; }) => { x: string; }'. + Type 'string' is not assignable to type '{ x: string; }'. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -17,7 +16,7 @@ tests/cases/conformance/jsx/file.tsx(13,54): error TS2326: Types of property 'ne let b = a} />; // No error - Values should be reinstantiated with `number` (since `object` is a default, not a constraint) let c = ({ x: a.x })} />; // No Error let d = a.x} />; // Error - `string` is not assignable to `{x: string}` - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2326: Types of property 'nextValues' are incompatible. -!!! error TS2326: Type '(a: { x: string; }) => string' is not assignable to type '(cur: { x: string; }) => { x: string; }'. -!!! error TS2326: Type 'string' is not assignable to type '{ x: string; }'. \ No newline at end of file + ~~~~~~~~~~ +!!! error TS2322: Type '(a: { x: string; }) => string' is not assignable to type '(cur: { x: string; }) => { x: string; }'. +!!! error TS2322: Type 'string' is not assignable to type '{ x: string; }'. +!!! related TS6500 tests/cases/conformance/jsx/file.tsx:13:54: The expected type comes from property 'nextValues' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes> & { initialValues: { x: string; }; nextValues: {}; } & BaseProps<{ x: string; }> & { children?: ReactNode; }' \ No newline at end of file diff --git a/tests/baselines/reference/circularImportAlias.errors.txt b/tests/baselines/reference/circularImportAlias.errors.txt index 13ff1d8c7c92f..a2488839b86ac 100644 --- a/tests/baselines/reference/circularImportAlias.errors.txt +++ b/tests/baselines/reference/circularImportAlias.errors.txt @@ -9,6 +9,7 @@ tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.t export class D extends a.C { ~ !!! error TS2449: Class 'C' used before its declaration. +!!! related TS2728 tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts:11:18: 'C' is declared here. id: number; } } diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt index d05e05517b265..3d1cb33d483f7 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -45,6 +45,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst var x : any = C; ~ !!! error TS2449: Class 'C' used before its declaration. +!!! related TS2728 tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts:26:7: 'C' is declared here. new x; // okay -- undefined behavior at runtime class C extends B { } // error -- not declared abstract diff --git a/tests/baselines/reference/classDeclarationShouldBeOutOfScopeInComputedNames.errors.txt b/tests/baselines/reference/classDeclarationShouldBeOutOfScopeInComputedNames.errors.txt index f7b8244f01327..a14d755b6ad28 100644 --- a/tests/baselines/reference/classDeclarationShouldBeOutOfScopeInComputedNames.errors.txt +++ b/tests/baselines/reference/classDeclarationShouldBeOutOfScopeInComputedNames.errors.txt @@ -12,14 +12,18 @@ tests/cases/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.ts(8,6): static readonly [A.p1] = 0; ~ !!! error TS2449: Class 'A' used before its declaration. +!!! related TS2728 tests/cases/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.ts:1:7: 'A' is declared here. static [A.p2]() { return 0 }; ~ !!! error TS2449: Class 'A' used before its declaration. +!!! related TS2728 tests/cases/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.ts:1:7: 'A' is declared here. [A.p1]() { } ~ !!! error TS2449: Class 'A' used before its declaration. +!!! related TS2728 tests/cases/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.ts:1:7: 'A' is declared here. [A.p2] = 0 ~ !!! error TS2449: Class 'A' used before its declaration. +!!! related TS2728 tests/cases/compiler/classDeclarationShouldBeOutOfScopeInComputedNames.ts:1:7: 'A' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt index 8f54ef1805161..0f4def9826ced 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt @@ -14,6 +14,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. ~ !!! error TS2449: Class 'E' used before its declaration. +!!! related TS2728 tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts:5:7: 'E' is declared here. class D extends C { bar: string; } ~ @@ -28,6 +29,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. ~~ !!! error TS2449: Class 'E2' used before its declaration. +!!! related TS2728 tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts:11:7: 'E2' is declared here. class D2 extends C2 { bar: T; } ~~ diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt index 48c787b54d9ab..3b5d16fa64fcf 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt @@ -14,6 +14,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. ~ !!! error TS2449: Class 'E' used before its declaration. +!!! related TS2728 tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts:9:18: 'E' is declared here. module M { export class D extends C { bar: string; } @@ -34,6 +35,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. ~~ !!! error TS2449: Class 'E2' used before its declaration. +!!! related TS2728 tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts:20:22: 'E2' is declared here. module P { export class D2 extends C2 { bar: T; } diff --git a/tests/baselines/reference/classInheritence.errors.txt b/tests/baselines/reference/classInheritence.errors.txt index 3bad3caf3d22f..338fcd16393b5 100644 --- a/tests/baselines/reference/classInheritence.errors.txt +++ b/tests/baselines/reference/classInheritence.errors.txt @@ -6,6 +6,7 @@ tests/cases/compiler/classInheritence.ts(2,7): error TS2506: 'A' is referenced d class B extends A { } ~ !!! error TS2449: Class 'A' used before its declaration. +!!! related TS2728 tests/cases/compiler/classInheritence.ts:2:7: 'A' is declared here. class A extends A { } ~ !!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classMergedWithInterfaceMultipleBasesNoError.errors.txt b/tests/baselines/reference/classMergedWithInterfaceMultipleBasesNoError.errors.txt index f760cf9bf2ae7..ce7dfcd7aa7de 100644 --- a/tests/baselines/reference/classMergedWithInterfaceMultipleBasesNoError.errors.txt +++ b/tests/baselines/reference/classMergedWithInterfaceMultipleBasesNoError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classMergedWithInterfaceMultipleBasesNoError.ts(8,30): error TS2448: Block-scoped variable 'handleIntersection' used before its declaration. +tests/cases/compiler/classMergedWithInterfaceMultipleBasesNoError.ts(8,30): error TS2729: Property 'handleIntersection' is used before its initialization. ==== tests/cases/compiler/classMergedWithInterfaceMultipleBasesNoError.ts (1 errors) ==== @@ -11,6 +11,7 @@ tests/cases/compiler/classMergedWithInterfaceMultipleBasesNoError.ts(8,30): erro export default class extends Foo { readonly observer = this.handleIntersection; ~~~~~~~~~~~~~~~~~~ -!!! error TS2448: Block-scoped variable 'handleIntersection' used before its declaration. +!!! error TS2729: Property 'handleIntersection' is used before its initialization. +!!! related TS2728 tests/cases/compiler/classMergedWithInterfaceMultipleBasesNoError.ts:9:14: 'handleIntersection' is declared here. readonly handleIntersection = () => { } } \ No newline at end of file diff --git a/tests/baselines/reference/classOrder2.errors.txt b/tests/baselines/reference/classOrder2.errors.txt index ce6dd9bd50f0c..229a7e283db94 100644 --- a/tests/baselines/reference/classOrder2.errors.txt +++ b/tests/baselines/reference/classOrder2.errors.txt @@ -5,6 +5,7 @@ tests/cases/compiler/classOrder2.ts(1,17): error TS2449: Class 'B' used before i class A extends B { ~ !!! error TS2449: Class 'B' used before its declaration. +!!! related TS2728 tests/cases/compiler/classOrder2.ts:7:7: 'B' is declared here. foo() { this.bar(); } diff --git a/tests/baselines/reference/classSideInheritance2.errors.txt b/tests/baselines/reference/classSideInheritance2.errors.txt index 7b27ee7c0f903..2ec59a360a9ba 100644 --- a/tests/baselines/reference/classSideInheritance2.errors.txt +++ b/tests/baselines/reference/classSideInheritance2.errors.txt @@ -11,6 +11,7 @@ tests/cases/compiler/classSideInheritance2.ts(7,23): error TS2449: Class 'TextBa class SubText extends TextBase { ~~~~~~~~ !!! error TS2449: Class 'TextBase' used before its declaration. +!!! related TS2728 tests/cases/compiler/classSideInheritance2.ts:14:7: 'TextBase' is declared here. constructor(text: IText, span: TextSpan) { super(); diff --git a/tests/baselines/reference/classStaticInitializersUsePropertiesBeforeDeclaration.errors.txt b/tests/baselines/reference/classStaticInitializersUsePropertiesBeforeDeclaration.errors.txt index 8b53637b884ee..2a67cec6f87b3 100644 --- a/tests/baselines/reference/classStaticInitializersUsePropertiesBeforeDeclaration.errors.txt +++ b/tests/baselines/reference/classStaticInitializersUsePropertiesBeforeDeclaration.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(2,25): error TS2450: Enum 'Enum' used before its declaration. -tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(2,30): error TS2448: Block-scoped variable 'A' used before its declaration. +tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(2,30): error TS2729: Property 'A' is used before its initialization. tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(3,31): error TS2448: Block-scoped variable 'ObjLiteral' used before its declaration. -tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(3,42): error TS2448: Block-scoped variable 'A' used before its declaration. -tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(4,40): error TS2448: Block-scoped variable 'A' used before its declaration. +tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(3,42): error TS2729: Property 'A' is used before its initialization. +tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(4,40): error TS2729: Property 'A' is used before its initialization. ==== tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts (5 errors) ==== @@ -10,16 +10,21 @@ tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts(4, static enumMember = Enum.A; ~~~~ !!! error TS2450: Enum 'Enum' used before its declaration. +!!! related TS2728 tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts:7:6: 'Enum' is declared here. ~ -!!! error TS2448: Block-scoped variable 'A' used before its declaration. +!!! error TS2729: Property 'A' is used before its initialization. +!!! related TS2728 tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts:8:5: 'A' is declared here. static objLiteralMember = ObjLiteral.A; ~~~~~~~~~~ !!! error TS2448: Block-scoped variable 'ObjLiteral' used before its declaration. +!!! related TS2728 tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts:11:7: 'ObjLiteral' is declared here. ~ -!!! error TS2448: Block-scoped variable 'A' used before its declaration. +!!! error TS2729: Property 'A' is used before its initialization. +!!! related TS2728 tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts:12:5: 'A' is declared here. static namespaceMember = Namespace.A; ~ -!!! error TS2448: Block-scoped variable 'A' used before its declaration. +!!! error TS2729: Property 'A' is used before its initialization. +!!! related TS2728 tests/cases/compiler/classStaticInitializersUsePropertiesBeforeDeclaration.ts:16:16: 'A' is declared here. } enum Enum { diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.errors.txt index 2563baf1c7243..1ee81a4ea113f 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.errors.txt @@ -46,54 +46,54 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(97,12): error TS2365: Operator '>=' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(98,12): error TS2365: Operator '>=' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(99,12): error TS2365: Operator '>=' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(103,12): error TS2365: Operator '==' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(104,12): error TS2365: Operator '==' cannot be applied to types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(105,12): error TS2365: Operator '==' cannot be applied to types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(106,12): error TS2365: Operator '==' cannot be applied to types '{ fn(): Base; }' and '{ fn(): C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(107,12): error TS2365: Operator '==' cannot be applied to types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(108,12): error TS2365: Operator '==' cannot be applied to types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(111,12): error TS2365: Operator '==' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(112,12): error TS2365: Operator '==' cannot be applied to types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(113,12): error TS2365: Operator '==' cannot be applied to types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(114,12): error TS2365: Operator '==' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(115,12): error TS2365: Operator '==' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(116,12): error TS2365: Operator '==' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(120,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(121,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(122,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(123,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(): Base; }' and '{ fn(): C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(124,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(125,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(128,12): error TS2365: Operator '!=' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(129,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(130,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(131,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(132,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(133,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(137,12): error TS2365: Operator '===' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(138,12): error TS2365: Operator '===' cannot be applied to types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(139,12): error TS2365: Operator '===' cannot be applied to types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(140,12): error TS2365: Operator '===' cannot be applied to types '{ fn(): Base; }' and '{ fn(): C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(141,12): error TS2365: Operator '===' cannot be applied to types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(142,12): error TS2365: Operator '===' cannot be applied to types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(145,12): error TS2365: Operator '===' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(146,12): error TS2365: Operator '===' cannot be applied to types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(147,12): error TS2365: Operator '===' cannot be applied to types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(148,12): error TS2365: Operator '===' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(149,12): error TS2365: Operator '===' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(150,12): error TS2365: Operator '===' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(154,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(155,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(156,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(157,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(): Base; }' and '{ fn(): C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(158,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(159,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(162,12): error TS2365: Operator '!==' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(163,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(164,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(165,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(166,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(167,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(103,12): error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(104,12): error TS2367: This condition will always return 'false' since the types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(105,12): error TS2367: This condition will always return 'false' since the types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(106,12): error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and '{ fn(): C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(107,12): error TS2367: This condition will always return 'false' since the types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(108,12): error TS2367: This condition will always return 'false' since the types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(111,12): error TS2367: This condition will always return 'false' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(112,12): error TS2367: This condition will always return 'false' since the types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(113,12): error TS2367: This condition will always return 'false' since the types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(114,12): error TS2367: This condition will always return 'false' since the types '{ fn(): C; }' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(115,12): error TS2367: This condition will always return 'false' since the types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(116,12): error TS2367: This condition will always return 'false' since the types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(120,12): error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(121,12): error TS2367: This condition will always return 'true' since the types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(122,12): error TS2367: This condition will always return 'true' since the types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(123,12): error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and '{ fn(): C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(124,12): error TS2367: This condition will always return 'true' since the types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(125,12): error TS2367: This condition will always return 'true' since the types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(128,12): error TS2367: This condition will always return 'true' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(129,12): error TS2367: This condition will always return 'true' since the types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(130,12): error TS2367: This condition will always return 'true' since the types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(131,12): error TS2367: This condition will always return 'true' since the types '{ fn(): C; }' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(132,12): error TS2367: This condition will always return 'true' since the types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(133,12): error TS2367: This condition will always return 'true' since the types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(137,12): error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(138,12): error TS2367: This condition will always return 'false' since the types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(139,12): error TS2367: This condition will always return 'false' since the types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(140,12): error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and '{ fn(): C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(141,12): error TS2367: This condition will always return 'false' since the types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(142,12): error TS2367: This condition will always return 'false' since the types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(145,12): error TS2367: This condition will always return 'false' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(146,12): error TS2367: This condition will always return 'false' since the types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(147,12): error TS2367: This condition will always return 'false' since the types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(148,12): error TS2367: This condition will always return 'false' since the types '{ fn(): C; }' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(149,12): error TS2367: This condition will always return 'false' since the types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(150,12): error TS2367: This condition will always return 'false' since the types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(154,12): error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(155,12): error TS2367: This condition will always return 'true' since the types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(156,12): error TS2367: This condition will always return 'true' since the types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(157,12): error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and '{ fn(): C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(158,12): error TS2367: This condition will always return 'true' since the types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(159,12): error TS2367: This condition will always return 'true' since the types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(162,12): error TS2367: This condition will always return 'true' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(163,12): error TS2367: This condition will always return 'true' since the types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(164,12): error TS2367: This condition will always return 'true' since the types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(165,12): error TS2367: This condition will always return 'true' since the types '{ fn(): C; }' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(166,12): error TS2367: This condition will always return 'true' since the types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts(167,12): error TS2367: This condition will always return 'true' since the types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }' have no overlap. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnCallSignature.ts (96 errors) ==== @@ -297,163 +297,163 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator == var r5a1 = a1 == b1; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. var r5a2 = a2 == b2; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }' have no overlap. var r5a3 = a3 == b3; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }' have no overlap. var r5a4 = a4 == b4; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(): Base; }' and '{ fn(): C; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and '{ fn(): C; }' have no overlap. var r5a5 = a5 == b5; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }' have no overlap. var r5a6 = a6 == b6; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }' have no overlap. var r5a7 = a7 == b7; var r5b1 = b1 == a1; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'false' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. var r5b2 = b2 == a2; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }' have no overlap. var r5b3 = b3 == a3; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }' have no overlap. var r5b4 = b4 == a4; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(): C; }' and '{ fn(): Base; }' have no overlap. var r5b5 = b5 == a5; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }' have no overlap. var r5b6 = b6 == a6; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }' have no overlap. var r5b7 = b7 == a7; // operator != var r6a1 = a1 != b1; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. var r6a2 = a2 != b2; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }' have no overlap. var r6a3 = a3 != b3; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }' have no overlap. var r6a4 = a4 != b4; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(): Base; }' and '{ fn(): C; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and '{ fn(): C; }' have no overlap. var r6a5 = a5 != b5; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }' have no overlap. var r6a6 = a6 != b6; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }' have no overlap. var r6a7 = a7 != b7; var r6b1 = b1 != a1; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'true' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. var r6b2 = b2 != a2; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }' have no overlap. var r6b3 = b3 != a3; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }' have no overlap. var r6b4 = b4 != a4; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(): C; }' and '{ fn(): Base; }' have no overlap. var r6b5 = b5 != a5; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }' have no overlap. var r6b6 = b6 != a6; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }' have no overlap. var r6b7 = b7 != a7; // operator === var r7a1 = a1 === b1; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. var r7a2 = a2 === b2; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }' have no overlap. var r7a3 = a3 === b3; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }' have no overlap. var r7a4 = a4 === b4; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(): Base; }' and '{ fn(): C; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and '{ fn(): C; }' have no overlap. var r7a5 = a5 === b5; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }' have no overlap. var r7a6 = a6 === b6; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }' have no overlap. var r7a7 = a7 === b7; var r7b1 = b1 === a1; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'false' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. var r7b2 = b2 === a2; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }' have no overlap. var r7b3 = b3 === a3; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }' have no overlap. var r7b4 = b4 === a4; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(): C; }' and '{ fn(): Base; }' have no overlap. var r7b5 = b5 === a5; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }' have no overlap. var r7b6 = b6 === a6; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }' have no overlap. var r7b7 = b7 === a7; // operator !== var r8a1 = a1 !== b1; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. var r8a2 = a2 !== b2; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a: number, b: string): void; }' and '{ fn(a: string): void; }' have no overlap. var r8a3 = a3 !== b3; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a: Base, b: string): void; }' and '{ fn(a: Derived, b: Base): void; }' have no overlap. var r8a4 = a4 !== b4; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(): Base; }' and '{ fn(): C; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and '{ fn(): C; }' have no overlap. var r8a5 = a5 !== b5; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a?: Base): void; }' and '{ fn(a?: C): void; }' have no overlap. var r8a6 = a6 !== b6; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(...a: Base[]): void; }' and '{ fn(...a: C[]): void; }' have no overlap. var r8a7 = a7 !== b7; var r8b1 = b1 !== a1; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'true' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. var r8b2 = b2 !== a2; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a: string): void; }' and '{ fn(a: number, b: string): void; }' have no overlap. var r8b3 = b3 !== a3; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a: Derived, b: Base): void; }' and '{ fn(a: Base, b: string): void; }' have no overlap. var r8b4 = b4 !== a4; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(): C; }' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(): C; }' and '{ fn(): Base; }' have no overlap. var r8b5 = b5 !== a5; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(a?: C): void; }' and '{ fn(a?: Base): void; }' have no overlap. var r8b6 = b6 !== a6; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(...a: C[]): void; }' and '{ fn(...a: Base[]): void; }' have no overlap. var r8b7 = b7 !== a7; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.errors.txt index cdfd199c0fa6d..f12a649d98b42 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.errors.txt @@ -46,54 +46,54 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(97,12): error TS2365: Operator '>=' cannot be applied to types 'new () => C' and 'new () => Base'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(98,12): error TS2365: Operator '>=' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(99,12): error TS2365: Operator '>=' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(103,12): error TS2365: Operator '==' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(104,12): error TS2365: Operator '==' cannot be applied to types 'new (a: number, b: string) => Base' and 'new (a: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(105,12): error TS2365: Operator '==' cannot be applied to types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(106,12): error TS2365: Operator '==' cannot be applied to types 'new () => Base' and 'new () => C'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(107,12): error TS2365: Operator '==' cannot be applied to types 'new (a?: Base) => Base' and 'new (a?: C) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(108,12): error TS2365: Operator '==' cannot be applied to types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(111,12): error TS2365: Operator '==' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(112,12): error TS2365: Operator '==' cannot be applied to types 'new (a: string) => Base' and 'new (a: number, b: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(113,12): error TS2365: Operator '==' cannot be applied to types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(114,12): error TS2365: Operator '==' cannot be applied to types 'new () => C' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(115,12): error TS2365: Operator '==' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(116,12): error TS2365: Operator '==' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(120,12): error TS2365: Operator '!=' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(121,12): error TS2365: Operator '!=' cannot be applied to types 'new (a: number, b: string) => Base' and 'new (a: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(122,12): error TS2365: Operator '!=' cannot be applied to types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(123,12): error TS2365: Operator '!=' cannot be applied to types 'new () => Base' and 'new () => C'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(124,12): error TS2365: Operator '!=' cannot be applied to types 'new (a?: Base) => Base' and 'new (a?: C) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(125,12): error TS2365: Operator '!=' cannot be applied to types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(128,12): error TS2365: Operator '!=' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(129,12): error TS2365: Operator '!=' cannot be applied to types 'new (a: string) => Base' and 'new (a: number, b: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(130,12): error TS2365: Operator '!=' cannot be applied to types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(131,12): error TS2365: Operator '!=' cannot be applied to types 'new () => C' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(132,12): error TS2365: Operator '!=' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(133,12): error TS2365: Operator '!=' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(137,12): error TS2365: Operator '===' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(138,12): error TS2365: Operator '===' cannot be applied to types 'new (a: number, b: string) => Base' and 'new (a: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(139,12): error TS2365: Operator '===' cannot be applied to types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(140,12): error TS2365: Operator '===' cannot be applied to types 'new () => Base' and 'new () => C'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(141,12): error TS2365: Operator '===' cannot be applied to types 'new (a?: Base) => Base' and 'new (a?: C) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(142,12): error TS2365: Operator '===' cannot be applied to types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(145,12): error TS2365: Operator '===' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(146,12): error TS2365: Operator '===' cannot be applied to types 'new (a: string) => Base' and 'new (a: number, b: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(147,12): error TS2365: Operator '===' cannot be applied to types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(148,12): error TS2365: Operator '===' cannot be applied to types 'new () => C' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(149,12): error TS2365: Operator '===' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(150,12): error TS2365: Operator '===' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(154,12): error TS2365: Operator '!==' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(155,12): error TS2365: Operator '!==' cannot be applied to types 'new (a: number, b: string) => Base' and 'new (a: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(156,12): error TS2365: Operator '!==' cannot be applied to types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(157,12): error TS2365: Operator '!==' cannot be applied to types 'new () => Base' and 'new () => C'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(158,12): error TS2365: Operator '!==' cannot be applied to types 'new (a?: Base) => Base' and 'new (a?: C) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(159,12): error TS2365: Operator '!==' cannot be applied to types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(162,12): error TS2365: Operator '!==' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(163,12): error TS2365: Operator '!==' cannot be applied to types 'new (a: string) => Base' and 'new (a: number, b: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(164,12): error TS2365: Operator '!==' cannot be applied to types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(165,12): error TS2365: Operator '!==' cannot be applied to types 'new () => C' and 'new () => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(166,12): error TS2365: Operator '!==' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(167,12): error TS2365: Operator '!==' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(103,12): error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(104,12): error TS2367: This condition will always return 'false' since the types 'new (a: number, b: string) => Base' and 'new (a: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(105,12): error TS2367: This condition will always return 'false' since the types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(106,12): error TS2367: This condition will always return 'false' since the types 'new () => Base' and 'new () => C' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(107,12): error TS2367: This condition will always return 'false' since the types 'new (a?: Base) => Base' and 'new (a?: C) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(108,12): error TS2367: This condition will always return 'false' since the types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(111,12): error TS2367: This condition will always return 'false' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(112,12): error TS2367: This condition will always return 'false' since the types 'new (a: string) => Base' and 'new (a: number, b: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(113,12): error TS2367: This condition will always return 'false' since the types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(114,12): error TS2367: This condition will always return 'false' since the types 'new () => C' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(115,12): error TS2367: This condition will always return 'false' since the types 'new (a?: C) => Base' and 'new (a?: Base) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(116,12): error TS2367: This condition will always return 'false' since the types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(120,12): error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(121,12): error TS2367: This condition will always return 'true' since the types 'new (a: number, b: string) => Base' and 'new (a: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(122,12): error TS2367: This condition will always return 'true' since the types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(123,12): error TS2367: This condition will always return 'true' since the types 'new () => Base' and 'new () => C' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(124,12): error TS2367: This condition will always return 'true' since the types 'new (a?: Base) => Base' and 'new (a?: C) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(125,12): error TS2367: This condition will always return 'true' since the types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(128,12): error TS2367: This condition will always return 'true' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(129,12): error TS2367: This condition will always return 'true' since the types 'new (a: string) => Base' and 'new (a: number, b: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(130,12): error TS2367: This condition will always return 'true' since the types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(131,12): error TS2367: This condition will always return 'true' since the types 'new () => C' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(132,12): error TS2367: This condition will always return 'true' since the types 'new (a?: C) => Base' and 'new (a?: Base) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(133,12): error TS2367: This condition will always return 'true' since the types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(137,12): error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(138,12): error TS2367: This condition will always return 'false' since the types 'new (a: number, b: string) => Base' and 'new (a: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(139,12): error TS2367: This condition will always return 'false' since the types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(140,12): error TS2367: This condition will always return 'false' since the types 'new () => Base' and 'new () => C' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(141,12): error TS2367: This condition will always return 'false' since the types 'new (a?: Base) => Base' and 'new (a?: C) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(142,12): error TS2367: This condition will always return 'false' since the types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(145,12): error TS2367: This condition will always return 'false' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(146,12): error TS2367: This condition will always return 'false' since the types 'new (a: string) => Base' and 'new (a: number, b: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(147,12): error TS2367: This condition will always return 'false' since the types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(148,12): error TS2367: This condition will always return 'false' since the types 'new () => C' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(149,12): error TS2367: This condition will always return 'false' since the types 'new (a?: C) => Base' and 'new (a?: Base) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(150,12): error TS2367: This condition will always return 'false' since the types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(154,12): error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(155,12): error TS2367: This condition will always return 'true' since the types 'new (a: number, b: string) => Base' and 'new (a: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(156,12): error TS2367: This condition will always return 'true' since the types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(157,12): error TS2367: This condition will always return 'true' since the types 'new () => Base' and 'new () => C' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(158,12): error TS2367: This condition will always return 'true' since the types 'new (a?: Base) => Base' and 'new (a?: C) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(159,12): error TS2367: This condition will always return 'true' since the types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(162,12): error TS2367: This condition will always return 'true' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(163,12): error TS2367: This condition will always return 'true' since the types 'new (a: string) => Base' and 'new (a: number, b: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(164,12): error TS2367: This condition will always return 'true' since the types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(165,12): error TS2367: This condition will always return 'true' since the types 'new () => C' and 'new () => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(166,12): error TS2367: This condition will always return 'true' since the types 'new (a?: C) => Base' and 'new (a?: Base) => Base' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts(167,12): error TS2367: This condition will always return 'true' since the types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base' have no overlap. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnConstructorSignature.ts (96 errors) ==== @@ -297,163 +297,163 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator == var r5a1 = a1 == b1; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. var r5a2 = a2 == b2; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (a: number, b: string) => Base' and 'new (a: string) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a: number, b: string) => Base' and 'new (a: string) => Base' have no overlap. var r5a3 = a3 == b3; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base' have no overlap. var r5a4 = a4 == b4; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new () => Base' and 'new () => C'. +!!! error TS2367: This condition will always return 'false' since the types 'new () => Base' and 'new () => C' have no overlap. var r5a5 = a5 == b5; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (a?: Base) => Base' and 'new (a?: C) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a?: Base) => Base' and 'new (a?: C) => Base' have no overlap. var r5a6 = a6 == b6; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base' have no overlap. var r5a7 = a7 == b7; var r5b1 = b1 == a1; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'false' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. var r5b2 = b2 == a2; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (a: string) => Base' and 'new (a: number, b: string) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a: string) => Base' and 'new (a: number, b: string) => Base' have no overlap. var r5b3 = b3 == a3; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base' have no overlap. var r5b4 = b4 == a4; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new () => C' and 'new () => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new () => C' and 'new () => Base' have no overlap. var r5b5 = b5 == a5; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a?: C) => Base' and 'new (a?: Base) => Base' have no overlap. var r5b6 = b6 == a6; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base' have no overlap. var r5b7 = b7 == a7; // operator != var r6a1 = a1 != b1; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. var r6a2 = a2 != b2; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (a: number, b: string) => Base' and 'new (a: string) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a: number, b: string) => Base' and 'new (a: string) => Base' have no overlap. var r6a3 = a3 != b3; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base' have no overlap. var r6a4 = a4 != b4; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new () => Base' and 'new () => C'. +!!! error TS2367: This condition will always return 'true' since the types 'new () => Base' and 'new () => C' have no overlap. var r6a5 = a5 != b5; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (a?: Base) => Base' and 'new (a?: C) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a?: Base) => Base' and 'new (a?: C) => Base' have no overlap. var r6a6 = a6 != b6; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base' have no overlap. var r6a7 = a7 != b7; var r6b1 = b1 != a1; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'true' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. var r6b2 = b2 != a2; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (a: string) => Base' and 'new (a: number, b: string) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a: string) => Base' and 'new (a: number, b: string) => Base' have no overlap. var r6b3 = b3 != a3; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base' have no overlap. var r6b4 = b4 != a4; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new () => C' and 'new () => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new () => C' and 'new () => Base' have no overlap. var r6b5 = b5 != a5; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a?: C) => Base' and 'new (a?: Base) => Base' have no overlap. var r6b6 = b6 != a6; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base' have no overlap. var r6b7 = b7 != a7; // operator === var r7a1 = a1 === b1; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. +!!! error TS2367: This condition will always return 'false' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. var r7a2 = a2 === b2; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (a: number, b: string) => Base' and 'new (a: string) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a: number, b: string) => Base' and 'new (a: string) => Base' have no overlap. var r7a3 = a3 === b3; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base' have no overlap. var r7a4 = a4 === b4; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new () => Base' and 'new () => C'. +!!! error TS2367: This condition will always return 'false' since the types 'new () => Base' and 'new () => C' have no overlap. var r7a5 = a5 === b5; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (a?: Base) => Base' and 'new (a?: C) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a?: Base) => Base' and 'new (a?: C) => Base' have no overlap. var r7a6 = a6 === b6; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base' have no overlap. var r7a7 = a7 === b7; var r7b1 = b1 === a1; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'false' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. var r7b2 = b2 === a2; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (a: string) => Base' and 'new (a: number, b: string) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a: string) => Base' and 'new (a: number, b: string) => Base' have no overlap. var r7b3 = b3 === a3; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base' have no overlap. var r7b4 = b4 === a4; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new () => C' and 'new () => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new () => C' and 'new () => Base' have no overlap. var r7b5 = b5 === a5; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (a?: C) => Base' and 'new (a?: Base) => Base' have no overlap. var r7b6 = b6 === a6; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. +!!! error TS2367: This condition will always return 'false' since the types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base' have no overlap. var r7b7 = b7 === a7; // operator !== var r8a1 = a1 !== b1; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ fn(): Base; }' and 'new () => Base'. +!!! error TS2367: This condition will always return 'true' since the types '{ fn(): Base; }' and 'new () => Base' have no overlap. var r8a2 = a2 !== b2; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (a: number, b: string) => Base' and 'new (a: string) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a: number, b: string) => Base' and 'new (a: string) => Base' have no overlap. var r8a3 = a3 !== b3; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a: Base, b: string) => Base' and 'new (a: Derived, b: Base) => Base' have no overlap. var r8a4 = a4 !== b4; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new () => Base' and 'new () => C'. +!!! error TS2367: This condition will always return 'true' since the types 'new () => Base' and 'new () => C' have no overlap. var r8a5 = a5 !== b5; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (a?: Base) => Base' and 'new (a?: C) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a?: Base) => Base' and 'new (a?: C) => Base' have no overlap. var r8a6 = a6 !== b6; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (...a: Base[]) => Base' and 'new (...a: C[]) => Base' have no overlap. var r8a7 = a7 !== b7; var r8b1 = b1 !== a1; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new () => Base' and '{ fn(): Base; }'. +!!! error TS2367: This condition will always return 'true' since the types 'new () => Base' and '{ fn(): Base; }' have no overlap. var r8b2 = b2 !== a2; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (a: string) => Base' and 'new (a: number, b: string) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a: string) => Base' and 'new (a: number, b: string) => Base' have no overlap. var r8b3 = b3 !== a3; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a: Derived, b: Base) => Base' and 'new (a: Base, b: string) => Base' have no overlap. var r8b4 = b4 !== a4; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new () => C' and 'new () => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new () => C' and 'new () => Base' have no overlap. var r8b5 = b5 !== a5; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (a?: C) => Base' and 'new (a?: Base) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (a?: C) => Base' and 'new (a?: Base) => Base' have no overlap. var r8b6 = b6 !== a6; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base'. +!!! error TS2367: This condition will always return 'true' since the types 'new (...a: C[]) => Base' and 'new (...a: Base[]) => Base' have no overlap. var r8b7 = b7 !== a7; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.errors.txt index 2efaf2e5ae2f7..9daa01a2dde36 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.errors.txt @@ -22,30 +22,30 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(64,12): error TS2365: Operator '>=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(65,12): error TS2365: Operator '>=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(66,12): error TS2365: Operator '>=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(70,12): error TS2365: Operator '==' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(71,12): error TS2365: Operator '==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(72,12): error TS2365: Operator '==' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(75,12): error TS2365: Operator '==' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(76,12): error TS2365: Operator '==' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(77,12): error TS2365: Operator '==' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(81,12): error TS2365: Operator '!=' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(82,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(83,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(86,12): error TS2365: Operator '!=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(87,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(88,12): error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(92,12): error TS2365: Operator '===' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(93,12): error TS2365: Operator '===' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(94,12): error TS2365: Operator '===' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(97,12): error TS2365: Operator '===' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(98,12): error TS2365: Operator '===' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(99,12): error TS2365: Operator '===' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(103,12): error TS2365: Operator '!==' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(104,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(105,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(108,12): error TS2365: Operator '!==' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(109,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(110,12): error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(70,12): error TS2367: This condition will always return 'false' since the types '{ [a: string]: string; }' and '{ [b: string]: number; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(71,12): error TS2367: This condition will always return 'false' since the types '{ [index: string]: Base; }' and '{ [index: string]: C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(72,12): error TS2367: This condition will always return 'false' since the types '{ [index: number]: Base; }' and '{ [index: number]: C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(75,12): error TS2367: This condition will always return 'false' since the types '{ [b: string]: number; }' and '{ [a: string]: string; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(76,12): error TS2367: This condition will always return 'false' since the types '{ [index: string]: C; }' and '{ [index: string]: Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(77,12): error TS2367: This condition will always return 'false' since the types '{ [index: number]: C; }' and '{ [index: number]: Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(81,12): error TS2367: This condition will always return 'true' since the types '{ [a: string]: string; }' and '{ [b: string]: number; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(82,12): error TS2367: This condition will always return 'true' since the types '{ [index: string]: Base; }' and '{ [index: string]: C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(83,12): error TS2367: This condition will always return 'true' since the types '{ [index: number]: Base; }' and '{ [index: number]: C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(86,12): error TS2367: This condition will always return 'true' since the types '{ [b: string]: number; }' and '{ [a: string]: string; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(87,12): error TS2367: This condition will always return 'true' since the types '{ [index: string]: C; }' and '{ [index: string]: Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(88,12): error TS2367: This condition will always return 'true' since the types '{ [index: number]: C; }' and '{ [index: number]: Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(92,12): error TS2367: This condition will always return 'false' since the types '{ [a: string]: string; }' and '{ [b: string]: number; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(93,12): error TS2367: This condition will always return 'false' since the types '{ [index: string]: Base; }' and '{ [index: string]: C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(94,12): error TS2367: This condition will always return 'false' since the types '{ [index: number]: Base; }' and '{ [index: number]: C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(97,12): error TS2367: This condition will always return 'false' since the types '{ [b: string]: number; }' and '{ [a: string]: string; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(98,12): error TS2367: This condition will always return 'false' since the types '{ [index: string]: C; }' and '{ [index: string]: Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(99,12): error TS2367: This condition will always return 'false' since the types '{ [index: number]: C; }' and '{ [index: number]: Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(103,12): error TS2367: This condition will always return 'true' since the types '{ [a: string]: string; }' and '{ [b: string]: number; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(104,12): error TS2367: This condition will always return 'true' since the types '{ [index: string]: Base; }' and '{ [index: string]: C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(105,12): error TS2367: This condition will always return 'true' since the types '{ [index: number]: Base; }' and '{ [index: number]: C; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(108,12): error TS2367: This condition will always return 'true' since the types '{ [b: string]: number; }' and '{ [a: string]: string; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(109,12): error TS2367: This condition will always return 'true' since the types '{ [index: string]: C; }' and '{ [index: string]: Base; }' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts(110,12): error TS2367: This condition will always return 'true' since the types '{ [index: number]: C; }' and '{ [index: number]: Base; }' have no overlap. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnIndexSignature.ts (48 errors) ==== @@ -168,91 +168,91 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator == var r5a1 = a1 == b1; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [a: string]: string; }' and '{ [b: string]: number; }' have no overlap. var r5a2 = a2 == b2; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [index: string]: Base; }' and '{ [index: string]: C; }' have no overlap. var r5a3 = a3 == b3; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [index: number]: Base; }' and '{ [index: number]: C; }' have no overlap. var r5a4 = a4 == b4; var r5b1 = b1 == a1; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [b: string]: number; }' and '{ [a: string]: string; }' have no overlap. var r5b2 = b2 == a2; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [index: string]: C; }' and '{ [index: string]: Base; }' have no overlap. var r5b3 = b3 == a3; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [index: number]: C; }' and '{ [index: number]: Base; }' have no overlap. var r5b4 = b4 == a4; // operator != var r6a1 = a1 != b1; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [a: string]: string; }' and '{ [b: string]: number; }' have no overlap. var r6a2 = a2 != b2; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [index: string]: Base; }' and '{ [index: string]: C; }' have no overlap. var r6a3 = a3 != b3; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [index: number]: Base; }' and '{ [index: number]: C; }' have no overlap. var r6a4 = a4 != b4; var r6b1 = b1 != a1; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [b: string]: number; }' and '{ [a: string]: string; }' have no overlap. var r6b2 = b2 != a2; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [index: string]: C; }' and '{ [index: string]: Base; }' have no overlap. var r6b3 = b3 != a3; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [index: number]: C; }' and '{ [index: number]: Base; }' have no overlap. var r6b4 = b4 != a4; // operator === var r7a1 = a1 === b1; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [a: string]: string; }' and '{ [b: string]: number; }' have no overlap. var r7a2 = a2 === b2; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [index: string]: Base; }' and '{ [index: string]: C; }' have no overlap. var r7a3 = a3 === b3; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [index: number]: Base; }' and '{ [index: number]: C; }' have no overlap. var r7a4 = a4 === b4; var r7b1 = b1 === a1; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [b: string]: number; }' and '{ [a: string]: string; }' have no overlap. var r7b2 = b2 === a2; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [index: string]: C; }' and '{ [index: string]: Base; }' have no overlap. var r7b3 = b3 === a3; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. +!!! error TS2367: This condition will always return 'false' since the types '{ [index: number]: C; }' and '{ [index: number]: Base; }' have no overlap. var r7b4 = b4 === a4; // operator !== var r8a1 = a1 !== b1; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ [a: string]: string; }' and '{ [b: string]: number; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [a: string]: string; }' and '{ [b: string]: number; }' have no overlap. var r8a2 = a2 !== b2; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: Base; }' and '{ [index: string]: C; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [index: string]: Base; }' and '{ [index: string]: C; }' have no overlap. var r8a3 = a3 !== b3; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: Base; }' and '{ [index: number]: C; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [index: number]: Base; }' and '{ [index: number]: C; }' have no overlap. var r8a4 = a4 !== b4; var r8b1 = b1 !== a1; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ [b: string]: number; }' and '{ [a: string]: string; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [b: string]: number; }' and '{ [a: string]: string; }' have no overlap. var r8b2 = b2 !== a2; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: string]: C; }' and '{ [index: string]: Base; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [index: string]: C; }' and '{ [index: string]: Base; }' have no overlap. var r8b3 = b3 !== a3; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types '{ [index: number]: C; }' and '{ [index: number]: Base; }'. +!!! error TS2367: This condition will always return 'true' since the types '{ [index: number]: C; }' and '{ [index: number]: Base; }' have no overlap. var r8b4 = b4 !== a4; \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.errors.txt index 5e700926eb5c7..0e69ec60138b4 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.errors.txt @@ -6,14 +6,14 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(22,11): error TS2365: Operator '<=' cannot be applied to types 'B1' and 'A1'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(25,11): error TS2365: Operator '>=' cannot be applied to types 'A1' and 'B1'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(26,11): error TS2365: Operator '>=' cannot be applied to types 'B1' and 'A1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(29,11): error TS2365: Operator '==' cannot be applied to types 'A1' and 'B1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(30,11): error TS2365: Operator '==' cannot be applied to types 'B1' and 'A1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(33,11): error TS2365: Operator '!=' cannot be applied to types 'A1' and 'B1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(34,11): error TS2365: Operator '!=' cannot be applied to types 'B1' and 'A1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(37,11): error TS2365: Operator '===' cannot be applied to types 'A1' and 'B1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(38,11): error TS2365: Operator '===' cannot be applied to types 'B1' and 'A1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(41,11): error TS2365: Operator '!==' cannot be applied to types 'A1' and 'B1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(42,11): error TS2365: Operator '!==' cannot be applied to types 'B1' and 'A1'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(29,11): error TS2367: This condition will always return 'false' since the types 'A1' and 'B1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(30,11): error TS2367: This condition will always return 'false' since the types 'B1' and 'A1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(33,11): error TS2367: This condition will always return 'true' since the types 'A1' and 'B1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(34,11): error TS2367: This condition will always return 'true' since the types 'B1' and 'A1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(37,11): error TS2367: This condition will always return 'false' since the types 'A1' and 'B1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(38,11): error TS2367: This condition will always return 'false' since the types 'B1' and 'A1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(41,11): error TS2367: This condition will always return 'true' since the types 'A1' and 'B1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts(42,11): error TS2367: This condition will always return 'true' since the types 'B1' and 'A1' have no overlap. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnOptionalProperty.ts (16 errors) ==== @@ -63,31 +63,31 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator == var re1 = a == b; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'A1' and 'B1'. +!!! error TS2367: This condition will always return 'false' since the types 'A1' and 'B1' have no overlap. var re2 = b == a; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'B1' and 'A1'. +!!! error TS2367: This condition will always return 'false' since the types 'B1' and 'A1' have no overlap. // operator != var rf1 = a != b; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'A1' and 'B1'. +!!! error TS2367: This condition will always return 'true' since the types 'A1' and 'B1' have no overlap. var rf2 = b != a; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'B1' and 'A1'. +!!! error TS2367: This condition will always return 'true' since the types 'B1' and 'A1' have no overlap. // operator === var rg1 = a === b; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'A1' and 'B1'. +!!! error TS2367: This condition will always return 'false' since the types 'A1' and 'B1' have no overlap. var rg2 = b === a; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'B1' and 'A1'. +!!! error TS2367: This condition will always return 'false' since the types 'B1' and 'A1' have no overlap. // operator !== var rh1 = a !== b; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'A1' and 'B1'. +!!! error TS2367: This condition will always return 'true' since the types 'A1' and 'B1' have no overlap. var rh2 = b !== a; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'B1' and 'A1'. \ No newline at end of file +!!! error TS2367: This condition will always return 'true' since the types 'B1' and 'A1' have no overlap. \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnProperty.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnProperty.errors.txt index 100330879468f..7be28d8c63b1c 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnProperty.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipObjectsOnProperty.errors.txt @@ -14,22 +14,22 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(45,12): error TS2365: Operator '>=' cannot be applied to types 'A2' and 'B2'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(47,12): error TS2365: Operator '>=' cannot be applied to types 'B1' and 'A1'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(48,12): error TS2365: Operator '>=' cannot be applied to types 'B2' and 'A2'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(51,12): error TS2365: Operator '==' cannot be applied to types 'A1' and 'B1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(52,12): error TS2365: Operator '==' cannot be applied to types 'A2' and 'B2'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(54,12): error TS2365: Operator '==' cannot be applied to types 'B1' and 'A1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(55,12): error TS2365: Operator '==' cannot be applied to types 'B2' and 'A2'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(58,12): error TS2365: Operator '!=' cannot be applied to types 'A1' and 'B1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(59,12): error TS2365: Operator '!=' cannot be applied to types 'A2' and 'B2'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(61,12): error TS2365: Operator '!=' cannot be applied to types 'B1' and 'A1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(62,12): error TS2365: Operator '!=' cannot be applied to types 'B2' and 'A2'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(65,12): error TS2365: Operator '===' cannot be applied to types 'A1' and 'B1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(66,12): error TS2365: Operator '===' cannot be applied to types 'A2' and 'B2'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(68,12): error TS2365: Operator '===' cannot be applied to types 'B1' and 'A1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(69,12): error TS2365: Operator '===' cannot be applied to types 'B2' and 'A2'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(72,12): error TS2365: Operator '!==' cannot be applied to types 'A1' and 'B1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(73,12): error TS2365: Operator '!==' cannot be applied to types 'A2' and 'B2'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(75,12): error TS2365: Operator '!==' cannot be applied to types 'B1' and 'A1'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(76,12): error TS2365: Operator '!==' cannot be applied to types 'B2' and 'A2'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(51,12): error TS2367: This condition will always return 'false' since the types 'A1' and 'B1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(52,12): error TS2367: This condition will always return 'false' since the types 'A2' and 'B2' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(54,12): error TS2367: This condition will always return 'false' since the types 'B1' and 'A1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(55,12): error TS2367: This condition will always return 'false' since the types 'B2' and 'A2' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(58,12): error TS2367: This condition will always return 'true' since the types 'A1' and 'B1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(59,12): error TS2367: This condition will always return 'true' since the types 'A2' and 'B2' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(61,12): error TS2367: This condition will always return 'true' since the types 'B1' and 'A1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(62,12): error TS2367: This condition will always return 'true' since the types 'B2' and 'A2' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(65,12): error TS2367: This condition will always return 'false' since the types 'A1' and 'B1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(66,12): error TS2367: This condition will always return 'false' since the types 'A2' and 'B2' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(68,12): error TS2367: This condition will always return 'false' since the types 'B1' and 'A1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(69,12): error TS2367: This condition will always return 'false' since the types 'B2' and 'A2' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(72,12): error TS2367: This condition will always return 'true' since the types 'A1' and 'B1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(73,12): error TS2367: This condition will always return 'true' since the types 'A2' and 'B2' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(75,12): error TS2367: This condition will always return 'true' since the types 'B1' and 'A1' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts(76,12): error TS2367: This condition will always return 'true' since the types 'B2' and 'A2' have no overlap. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipObjectsOnProperty.ts (32 errors) ==== @@ -117,59 +117,59 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator == var r5a1 = a1 == b1; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'A1' and 'B1'. +!!! error TS2367: This condition will always return 'false' since the types 'A1' and 'B1' have no overlap. var r5a2 = a2 == b2; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'A2' and 'B2'. +!!! error TS2367: This condition will always return 'false' since the types 'A2' and 'B2' have no overlap. var r5b1 = b1 == a1; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'B1' and 'A1'. +!!! error TS2367: This condition will always return 'false' since the types 'B1' and 'A1' have no overlap. var r5b2 = b2 == a2; ~~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'B2' and 'A2'. +!!! error TS2367: This condition will always return 'false' since the types 'B2' and 'A2' have no overlap. // operator != var r6a1 = a1 != b1; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'A1' and 'B1'. +!!! error TS2367: This condition will always return 'true' since the types 'A1' and 'B1' have no overlap. var r6a2 = a2 != b2; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'A2' and 'B2'. +!!! error TS2367: This condition will always return 'true' since the types 'A2' and 'B2' have no overlap. var r6b1 = b1 != a1; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'B1' and 'A1'. +!!! error TS2367: This condition will always return 'true' since the types 'B1' and 'A1' have no overlap. var r6b2 = b2 != a2; ~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'B2' and 'A2'. +!!! error TS2367: This condition will always return 'true' since the types 'B2' and 'A2' have no overlap. // operator === var r7a1 = a1 === b1; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'A1' and 'B1'. +!!! error TS2367: This condition will always return 'false' since the types 'A1' and 'B1' have no overlap. var r7a2 = a2 === b2; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'A2' and 'B2'. +!!! error TS2367: This condition will always return 'false' since the types 'A2' and 'B2' have no overlap. var r7b1 = b1 === a1; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'B1' and 'A1'. +!!! error TS2367: This condition will always return 'false' since the types 'B1' and 'A1' have no overlap. var r7b2 = b2 === a2; ~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'B2' and 'A2'. +!!! error TS2367: This condition will always return 'false' since the types 'B2' and 'A2' have no overlap. // operator !== var r8a1 = a1 !== b1; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'A1' and 'B1'. +!!! error TS2367: This condition will always return 'true' since the types 'A1' and 'B1' have no overlap. var r8a2 = a2 !== b2; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'A2' and 'B2'. +!!! error TS2367: This condition will always return 'true' since the types 'A2' and 'B2' have no overlap. var r8b1 = b1 !== a1; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'B1' and 'A1'. +!!! error TS2367: This condition will always return 'true' since the types 'B1' and 'A1' have no overlap. var r8b2 = b2 !== a2; ~~~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'B2' and 'A2'. \ No newline at end of file +!!! error TS2367: This condition will always return 'true' since the types 'B2' and 'A2' have no overlap. \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt index ec511069130e9..4b2560e3900fb 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt @@ -70,78 +70,78 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(109,12): error TS2365: Operator '>=' cannot be applied to types 'E' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(110,12): error TS2365: Operator '>=' cannot be applied to types 'E' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(111,12): error TS2365: Operator '>=' cannot be applied to types 'E' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(114,12): error TS2365: Operator '==' cannot be applied to types 'number' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(115,12): error TS2365: Operator '==' cannot be applied to types 'number' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(116,12): error TS2365: Operator '==' cannot be applied to types 'number' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(119,12): error TS2365: Operator '==' cannot be applied to types 'boolean' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(120,12): error TS2365: Operator '==' cannot be applied to types 'boolean' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(121,12): error TS2365: Operator '==' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(122,12): error TS2365: Operator '==' cannot be applied to types 'boolean' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(124,12): error TS2365: Operator '==' cannot be applied to types 'string' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(125,12): error TS2365: Operator '==' cannot be applied to types 'string' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(126,12): error TS2365: Operator '==' cannot be applied to types 'string' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(127,12): error TS2365: Operator '==' cannot be applied to types 'string' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(129,12): error TS2365: Operator '==' cannot be applied to types 'void' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(130,12): error TS2365: Operator '==' cannot be applied to types 'void' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(131,12): error TS2365: Operator '==' cannot be applied to types 'void' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(132,12): error TS2365: Operator '==' cannot be applied to types 'void' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(135,12): error TS2365: Operator '==' cannot be applied to types 'E' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(136,12): error TS2365: Operator '==' cannot be applied to types 'E' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(137,12): error TS2365: Operator '==' cannot be applied to types 'E' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(140,12): error TS2365: Operator '!=' cannot be applied to types 'number' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(141,12): error TS2365: Operator '!=' cannot be applied to types 'number' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(142,12): error TS2365: Operator '!=' cannot be applied to types 'number' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(145,12): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(146,12): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(147,12): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(148,12): error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(150,12): error TS2365: Operator '!=' cannot be applied to types 'string' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(151,12): error TS2365: Operator '!=' cannot be applied to types 'string' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(152,12): error TS2365: Operator '!=' cannot be applied to types 'string' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(153,12): error TS2365: Operator '!=' cannot be applied to types 'string' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(155,12): error TS2365: Operator '!=' cannot be applied to types 'void' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(156,12): error TS2365: Operator '!=' cannot be applied to types 'void' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(157,12): error TS2365: Operator '!=' cannot be applied to types 'void' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(158,12): error TS2365: Operator '!=' cannot be applied to types 'void' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(161,12): error TS2365: Operator '!=' cannot be applied to types 'E' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(162,12): error TS2365: Operator '!=' cannot be applied to types 'E' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(163,12): error TS2365: Operator '!=' cannot be applied to types 'E' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(166,12): error TS2365: Operator '===' cannot be applied to types 'number' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(167,12): error TS2365: Operator '===' cannot be applied to types 'number' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(168,12): error TS2365: Operator '===' cannot be applied to types 'number' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(171,12): error TS2365: Operator '===' cannot be applied to types 'boolean' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(172,12): error TS2365: Operator '===' cannot be applied to types 'boolean' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(173,12): error TS2365: Operator '===' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(174,12): error TS2365: Operator '===' cannot be applied to types 'boolean' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(176,12): error TS2365: Operator '===' cannot be applied to types 'string' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(177,12): error TS2365: Operator '===' cannot be applied to types 'string' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(178,12): error TS2365: Operator '===' cannot be applied to types 'string' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(179,12): error TS2365: Operator '===' cannot be applied to types 'string' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(181,12): error TS2365: Operator '===' cannot be applied to types 'void' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(182,12): error TS2365: Operator '===' cannot be applied to types 'void' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(183,12): error TS2365: Operator '===' cannot be applied to types 'void' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(184,12): error TS2365: Operator '===' cannot be applied to types 'void' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(187,12): error TS2365: Operator '===' cannot be applied to types 'E' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(188,12): error TS2365: Operator '===' cannot be applied to types 'E' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(189,12): error TS2365: Operator '===' cannot be applied to types 'E' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(192,12): error TS2365: Operator '!==' cannot be applied to types 'number' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(193,12): error TS2365: Operator '!==' cannot be applied to types 'number' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(194,12): error TS2365: Operator '!==' cannot be applied to types 'number' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(197,12): error TS2365: Operator '!==' cannot be applied to types 'boolean' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(198,12): error TS2365: Operator '!==' cannot be applied to types 'boolean' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(199,12): error TS2365: Operator '!==' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(200,12): error TS2365: Operator '!==' cannot be applied to types 'boolean' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(202,12): error TS2365: Operator '!==' cannot be applied to types 'string' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(203,12): error TS2365: Operator '!==' cannot be applied to types 'string' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(204,12): error TS2365: Operator '!==' cannot be applied to types 'string' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(205,12): error TS2365: Operator '!==' cannot be applied to types 'string' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(207,12): error TS2365: Operator '!==' cannot be applied to types 'void' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(208,12): error TS2365: Operator '!==' cannot be applied to types 'void' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(209,12): error TS2365: Operator '!==' cannot be applied to types 'void' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(210,12): error TS2365: Operator '!==' cannot be applied to types 'void' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(213,12): error TS2365: Operator '!==' cannot be applied to types 'E' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(214,12): error TS2365: Operator '!==' cannot be applied to types 'E' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(215,12): error TS2365: Operator '!==' cannot be applied to types 'E' and 'void'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(114,12): error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(115,12): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(116,12): error TS2367: This condition will always return 'false' since the types 'number' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(119,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(120,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(121,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(122,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(124,12): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(125,12): error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(126,12): error TS2367: This condition will always return 'false' since the types 'string' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(127,12): error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(129,12): error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(130,12): error TS2367: This condition will always return 'false' since the types 'void' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(131,12): error TS2367: This condition will always return 'false' since the types 'void' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(132,12): error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(135,12): error TS2367: This condition will always return 'false' since the types 'E' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(136,12): error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(137,12): error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(140,12): error TS2367: This condition will always return 'true' since the types 'number' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(141,12): error TS2367: This condition will always return 'true' since the types 'number' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(142,12): error TS2367: This condition will always return 'true' since the types 'number' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(145,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(146,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(147,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(148,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(150,12): error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(151,12): error TS2367: This condition will always return 'true' since the types 'string' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(152,12): error TS2367: This condition will always return 'true' since the types 'string' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(153,12): error TS2367: This condition will always return 'true' since the types 'string' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(155,12): error TS2367: This condition will always return 'true' since the types 'void' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(156,12): error TS2367: This condition will always return 'true' since the types 'void' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(157,12): error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(158,12): error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(161,12): error TS2367: This condition will always return 'true' since the types 'E' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(162,12): error TS2367: This condition will always return 'true' since the types 'E' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(163,12): error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(166,12): error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(167,12): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(168,12): error TS2367: This condition will always return 'false' since the types 'number' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(171,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(172,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(173,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(174,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(176,12): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(177,12): error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(178,12): error TS2367: This condition will always return 'false' since the types 'string' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(179,12): error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(181,12): error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(182,12): error TS2367: This condition will always return 'false' since the types 'void' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(183,12): error TS2367: This condition will always return 'false' since the types 'void' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(184,12): error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(187,12): error TS2367: This condition will always return 'false' since the types 'E' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(188,12): error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(189,12): error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(192,12): error TS2367: This condition will always return 'true' since the types 'number' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(193,12): error TS2367: This condition will always return 'true' since the types 'number' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(194,12): error TS2367: This condition will always return 'true' since the types 'number' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(197,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(198,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(199,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(200,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(202,12): error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(203,12): error TS2367: This condition will always return 'true' since the types 'string' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(204,12): error TS2367: This condition will always return 'true' since the types 'string' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(205,12): error TS2367: This condition will always return 'true' since the types 'string' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(207,12): error TS2367: This condition will always return 'true' since the types 'void' and 'number' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(208,12): error TS2367: This condition will always return 'true' since the types 'void' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(209,12): error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(210,12): error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(213,12): error TS2367: This condition will always return 'true' since the types 'E' and 'boolean' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(214,12): error TS2367: This condition will always return 'true' since the types 'E' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(215,12): error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts (144 errors) ==== @@ -404,247 +404,247 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator == var r5a1 = a == b; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'number' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. var r5a1 = a == c; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'number' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. var r5a1 = a == d; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'number' and 'void'. +!!! error TS2367: This condition will always return 'false' since the types 'number' and 'void' have no overlap. var r5a1 = a == e; // no error, expected var r5b1 = b == a; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'boolean' and 'number'. +!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap. var r5b1 = b == c; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'boolean' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. var r5b1 = b == d; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'boolean' and 'void'. +!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'void' have no overlap. var r5b1 = b == e; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'boolean' and 'E'. +!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'E' have no overlap. var r5c1 = c == a; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'string' and 'number'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. var r5c1 = c == b; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'string' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. var r5c1 = c == d; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'string' and 'void'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'void' have no overlap. var r5c1 = c == e; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'string' and 'E'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. var r5d1 = d == a; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'void' and 'number'. +!!! error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. var r5d1 = d == b; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'void' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'void' and 'boolean' have no overlap. var r5d1 = d == c; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'void' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'void' and 'string' have no overlap. var r5d1 = d == e; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'void' and 'E'. +!!! error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. var r5e1 = e == a; // no error, expected var r5e1 = e == b; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'E' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'E' and 'boolean' have no overlap. var r5e1 = e == c; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'E' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. var r5e1 = e == d; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'E' and 'void'. +!!! error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. // operator != var r6a1 = a != b; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'number' and 'boolean'. +!!! error TS2367: This condition will always return 'true' since the types 'number' and 'boolean' have no overlap. var r6a1 = a != c; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'number' and 'string'. +!!! error TS2367: This condition will always return 'true' since the types 'number' and 'string' have no overlap. var r6a1 = a != d; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'number' and 'void'. +!!! error TS2367: This condition will always return 'true' since the types 'number' and 'void' have no overlap. var r6a1 = a != e; // no error, expected var r6b1 = b != a; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'number'. +!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'number' have no overlap. var r6b1 = b != c; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'string'. +!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'string' have no overlap. var r6b1 = b != d; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'void'. +!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'void' have no overlap. var r6b1 = b != e; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and 'E'. +!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'E' have no overlap. var r6c1 = c != a; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'string' and 'number'. +!!! error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap. var r6c1 = c != b; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'string' and 'boolean'. +!!! error TS2367: This condition will always return 'true' since the types 'string' and 'boolean' have no overlap. var r6c1 = c != d; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'string' and 'void'. +!!! error TS2367: This condition will always return 'true' since the types 'string' and 'void' have no overlap. var r6c1 = c != e; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'string' and 'E'. +!!! error TS2367: This condition will always return 'true' since the types 'string' and 'E' have no overlap. var r6d1 = d != a; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'void' and 'number'. +!!! error TS2367: This condition will always return 'true' since the types 'void' and 'number' have no overlap. var r6d1 = d != b; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'void' and 'boolean'. +!!! error TS2367: This condition will always return 'true' since the types 'void' and 'boolean' have no overlap. var r6d1 = d != c; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'void' and 'string'. +!!! error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. var r6d1 = d != e; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'void' and 'E'. +!!! error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. var r6e1 = e != a; // no error, expected var r6e1 = e != b; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'E' and 'boolean'. +!!! error TS2367: This condition will always return 'true' since the types 'E' and 'boolean' have no overlap. var r6e1 = e != c; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'E' and 'string'. +!!! error TS2367: This condition will always return 'true' since the types 'E' and 'string' have no overlap. var r6e1 = e != d; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'E' and 'void'. +!!! error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. // operator === var r7a1 = a === b; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'number' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. var r7a1 = a === c; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'number' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. var r7a1 = a === d; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'number' and 'void'. +!!! error TS2367: This condition will always return 'false' since the types 'number' and 'void' have no overlap. var r7a1 = a === e; // no error, expected var r7b1 = b === a; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'boolean' and 'number'. +!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap. var r7b1 = b === c; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'boolean' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. var r7b1 = b === d; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'boolean' and 'void'. +!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'void' have no overlap. var r7b1 = b === e; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'boolean' and 'E'. +!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'E' have no overlap. var r7c1 = c === a; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'string' and 'number'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. var r7c1 = c === b; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'string' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. var r7c1 = c === d; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'string' and 'void'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'void' have no overlap. var r7c1 = c === e; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'string' and 'E'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. var r7d1 = d === a; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'void' and 'number'. +!!! error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. var r7d1 = d === b; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'void' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'void' and 'boolean' have no overlap. var r7d1 = d === c; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'void' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'void' and 'string' have no overlap. var r7d1 = d === e; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'void' and 'E'. +!!! error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. var r7e1 = e === a; // no error, expected var r7e1 = e === b; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'E' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'E' and 'boolean' have no overlap. var r7e1 = e === c; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'E' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. var r7e1 = e === d; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'E' and 'void'. +!!! error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. // operator !== var r8a1 = a !== b; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'number' and 'boolean'. +!!! error TS2367: This condition will always return 'true' since the types 'number' and 'boolean' have no overlap. var r8a1 = a !== c; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'number' and 'string'. +!!! error TS2367: This condition will always return 'true' since the types 'number' and 'string' have no overlap. var r8a1 = a !== d; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'number' and 'void'. +!!! error TS2367: This condition will always return 'true' since the types 'number' and 'void' have no overlap. var r8a1 = a !== e; // no error, expected var r8b1 = b !== a; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'boolean' and 'number'. +!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'number' have no overlap. var r8b1 = b !== c; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'boolean' and 'string'. +!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'string' have no overlap. var r8b1 = b !== d; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'boolean' and 'void'. +!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'void' have no overlap. var r8b1 = b !== e; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'boolean' and 'E'. +!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'E' have no overlap. var r8c1 = c !== a; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'string' and 'number'. +!!! error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap. var r8c1 = c !== b; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'string' and 'boolean'. +!!! error TS2367: This condition will always return 'true' since the types 'string' and 'boolean' have no overlap. var r8c1 = c !== d; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'string' and 'void'. +!!! error TS2367: This condition will always return 'true' since the types 'string' and 'void' have no overlap. var r8c1 = c !== e; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'string' and 'E'. +!!! error TS2367: This condition will always return 'true' since the types 'string' and 'E' have no overlap. var r8d1 = d !== a; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'void' and 'number'. +!!! error TS2367: This condition will always return 'true' since the types 'void' and 'number' have no overlap. var r8d1 = d !== b; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'void' and 'boolean'. +!!! error TS2367: This condition will always return 'true' since the types 'void' and 'boolean' have no overlap. var r8d1 = d !== c; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'void' and 'string'. +!!! error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. var r8d1 = d !== e; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'void' and 'E'. +!!! error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. var r8e1 = e !== a; // no error, expected var r8e1 = e !== b; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'E' and 'boolean'. +!!! error TS2367: This condition will always return 'true' since the types 'E' and 'boolean' have no overlap. var r8e1 = e !== c; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'E' and 'string'. +!!! error TS2367: This condition will always return 'true' since the types 'E' and 'string' have no overlap. var r8e1 = e !== d; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'E' and 'void'. \ No newline at end of file +!!! error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipTypeParameter.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipTypeParameter.errors.txt index 6bd8c30b205ca..da497e03a2206 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipTypeParameter.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipTypeParameter.errors.txt @@ -2,10 +2,10 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(13,14): error TS2365: Operator '>' cannot be applied to types 'T' and 'U'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(14,14): error TS2365: Operator '<=' cannot be applied to types 'T' and 'U'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(15,14): error TS2365: Operator '>=' cannot be applied to types 'T' and 'U'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(16,14): error TS2365: Operator '==' cannot be applied to types 'T' and 'U'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(17,14): error TS2365: Operator '!=' cannot be applied to types 'T' and 'U'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(18,14): error TS2365: Operator '===' cannot be applied to types 'T' and 'U'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(19,14): error TS2365: Operator '!==' cannot be applied to types 'T' and 'U'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(16,14): error TS2367: This condition will always return 'false' since the types 'T' and 'U' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(17,14): error TS2367: This condition will always return 'true' since the types 'T' and 'U' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(18,14): error TS2367: This condition will always return 'false' since the types 'T' and 'U' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(19,14): error TS2367: This condition will always return 'true' since the types 'T' and 'U' have no overlap. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(22,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(23,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(24,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'string'. @@ -146,16 +146,16 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>=' cannot be applied to types 'T' and 'U'. var r5 = t == u; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'T' and 'U'. +!!! error TS2367: This condition will always return 'false' since the types 'T' and 'U' have no overlap. var r6 = t != u; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'T' and 'U'. +!!! error TS2367: This condition will always return 'true' since the types 'T' and 'U' have no overlap. var r7 = t === u; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'T' and 'U'. +!!! error TS2367: This condition will always return 'false' since the types 'T' and 'U' have no overlap. var r8 = t !== u; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'T' and 'U'. +!!! error TS2367: This condition will always return 'true' since the types 'T' and 'U' have no overlap. // operator < var r1a1 = t < a; diff --git a/tests/baselines/reference/comparisonOperatorWithTypeParameter.errors.txt b/tests/baselines/reference/comparisonOperatorWithTypeParameter.errors.txt index e8193e91a0f77..6b07a7e23640d 100644 --- a/tests/baselines/reference/comparisonOperatorWithTypeParameter.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithTypeParameter.errors.txt @@ -2,34 +2,34 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(7,15): error TS2365: Operator '>' cannot be applied to types 'T' and 'U'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(8,15): error TS2365: Operator '<=' cannot be applied to types 'T' and 'U'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(9,15): error TS2365: Operator '>=' cannot be applied to types 'T' and 'U'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(10,15): error TS2365: Operator '==' cannot be applied to types 'T' and 'U'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(11,15): error TS2365: Operator '!=' cannot be applied to types 'T' and 'U'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(12,15): error TS2365: Operator '===' cannot be applied to types 'T' and 'U'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(13,15): error TS2365: Operator '!==' cannot be applied to types 'T' and 'U'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(10,15): error TS2367: This condition will always return 'false' since the types 'T' and 'U' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(11,15): error TS2367: This condition will always return 'true' since the types 'T' and 'U' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(12,15): error TS2367: This condition will always return 'false' since the types 'T' and 'U' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(13,15): error TS2367: This condition will always return 'true' since the types 'T' and 'U' have no overlap. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(15,15): error TS2365: Operator '<' cannot be applied to types 'U' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(16,15): error TS2365: Operator '>' cannot be applied to types 'U' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(17,15): error TS2365: Operator '<=' cannot be applied to types 'U' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(18,15): error TS2365: Operator '>=' cannot be applied to types 'U' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(19,15): error TS2365: Operator '==' cannot be applied to types 'U' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(20,15): error TS2365: Operator '!=' cannot be applied to types 'U' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(21,15): error TS2365: Operator '===' cannot be applied to types 'U' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(22,15): error TS2365: Operator '!==' cannot be applied to types 'U' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(19,15): error TS2367: This condition will always return 'false' since the types 'U' and 'T' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(20,15): error TS2367: This condition will always return 'true' since the types 'U' and 'T' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(21,15): error TS2367: This condition will always return 'false' since the types 'U' and 'T' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(22,15): error TS2367: This condition will always return 'true' since the types 'U' and 'T' have no overlap. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(24,15): error TS2365: Operator '<' cannot be applied to types 'T' and 'V'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(25,15): error TS2365: Operator '>' cannot be applied to types 'T' and 'V'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(26,15): error TS2365: Operator '<=' cannot be applied to types 'T' and 'V'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(27,15): error TS2365: Operator '>=' cannot be applied to types 'T' and 'V'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(28,15): error TS2365: Operator '==' cannot be applied to types 'T' and 'V'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(29,15): error TS2365: Operator '!=' cannot be applied to types 'T' and 'V'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(30,15): error TS2365: Operator '===' cannot be applied to types 'T' and 'V'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(31,15): error TS2365: Operator '!==' cannot be applied to types 'T' and 'V'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(28,15): error TS2367: This condition will always return 'false' since the types 'T' and 'V' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(29,15): error TS2367: This condition will always return 'true' since the types 'T' and 'V' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(30,15): error TS2367: This condition will always return 'false' since the types 'T' and 'V' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(31,15): error TS2367: This condition will always return 'true' since the types 'T' and 'V' have no overlap. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(33,15): error TS2365: Operator '<' cannot be applied to types 'V' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(34,15): error TS2365: Operator '>' cannot be applied to types 'V' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(35,15): error TS2365: Operator '<=' cannot be applied to types 'V' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(36,15): error TS2365: Operator '>=' cannot be applied to types 'V' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(37,15): error TS2365: Operator '==' cannot be applied to types 'V' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(38,15): error TS2365: Operator '!=' cannot be applied to types 'V' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(39,15): error TS2365: Operator '===' cannot be applied to types 'V' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(40,15): error TS2365: Operator '!==' cannot be applied to types 'V' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(37,15): error TS2367: This condition will always return 'false' since the types 'V' and 'T' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(38,15): error TS2367: This condition will always return 'true' since the types 'V' and 'T' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(39,15): error TS2367: This condition will always return 'false' since the types 'V' and 'T' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts(40,15): error TS2367: This condition will always return 'true' since the types 'V' and 'T' have no overlap. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithTypeParameter.ts (32 errors) ==== @@ -52,16 +52,16 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>=' cannot be applied to types 'T' and 'U'. var ra5 = t == u; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'T' and 'U'. +!!! error TS2367: This condition will always return 'false' since the types 'T' and 'U' have no overlap. var ra6 = t != u; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'T' and 'U'. +!!! error TS2367: This condition will always return 'true' since the types 'T' and 'U' have no overlap. var ra7 = t === u; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'T' and 'U'. +!!! error TS2367: This condition will always return 'false' since the types 'T' and 'U' have no overlap. var ra8 = t !== u; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'T' and 'U'. +!!! error TS2367: This condition will always return 'true' since the types 'T' and 'U' have no overlap. var rb1 = u < t; ~~~~~ @@ -77,16 +77,16 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>=' cannot be applied to types 'U' and 'T'. var rb5 = u == t; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'U' and 'T'. +!!! error TS2367: This condition will always return 'false' since the types 'U' and 'T' have no overlap. var rb6 = u != t; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'U' and 'T'. +!!! error TS2367: This condition will always return 'true' since the types 'U' and 'T' have no overlap. var rb7 = u === t; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'U' and 'T'. +!!! error TS2367: This condition will always return 'false' since the types 'U' and 'T' have no overlap. var rb8 = u !== t; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'U' and 'T'. +!!! error TS2367: This condition will always return 'true' since the types 'U' and 'T' have no overlap. var rc1 = t < v; ~~~~~ @@ -102,16 +102,16 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>=' cannot be applied to types 'T' and 'V'. var rc5 = t == v; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'T' and 'V'. +!!! error TS2367: This condition will always return 'false' since the types 'T' and 'V' have no overlap. var rc6 = t != v; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'T' and 'V'. +!!! error TS2367: This condition will always return 'true' since the types 'T' and 'V' have no overlap. var rc7 = t === v; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'T' and 'V'. +!!! error TS2367: This condition will always return 'false' since the types 'T' and 'V' have no overlap. var rc8 = t !== v; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'T' and 'V'. +!!! error TS2367: This condition will always return 'true' since the types 'T' and 'V' have no overlap. var rd1 = v < t; ~~~~~ @@ -127,16 +127,16 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>=' cannot be applied to types 'V' and 'T'. var rd5 = v == t; ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'V' and 'T'. +!!! error TS2367: This condition will always return 'false' since the types 'V' and 'T' have no overlap. var rd6 = v != t; ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'V' and 'T'. +!!! error TS2367: This condition will always return 'true' since the types 'V' and 'T' have no overlap. var rd7 = v === t; ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'V' and 'T'. +!!! error TS2367: This condition will always return 'false' since the types 'V' and 'T' have no overlap. var rd8 = v !== t; ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'V' and 'T'. +!!! error TS2367: This condition will always return 'true' since the types 'V' and 'T' have no overlap. // ok var re1 = t < a; diff --git a/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline b/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline index e01194874bf70..80a31656fd04b 100644 --- a/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline +++ b/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline @@ -4,6 +4,7 @@ Diagnostics: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. EmitSkipped: false + FileName : /tests/cases/fourslash/a.js function foo2() { return 30; } // no error - should emit a.js diff --git a/tests/baselines/reference/complexClassRelationships.errors.txt b/tests/baselines/reference/complexClassRelationships.errors.txt index c978a36c036ee..e7de3a0859008 100644 --- a/tests/baselines/reference/complexClassRelationships.errors.txt +++ b/tests/baselines/reference/complexClassRelationships.errors.txt @@ -6,6 +6,7 @@ tests/cases/compiler/complexClassRelationships.ts(2,23): error TS2449: Class 'Ba class Derived extends Base { ~~~~ !!! error TS2449: Class 'Base' used before its declaration. +!!! related TS2728 tests/cases/compiler/complexClassRelationships.ts:13:7: 'Base' is declared here. public static createEmpty(): Derived { var item = new Derived(); return item; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt index ee36609095a04..56e374f0d5352 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt @@ -1,21 +1,20 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(6,5): error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. - Index signatures are incompatible. - Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(7,5): error TS2418: Type of computed property's value is 'string', which is not assignable to type 'boolean'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(8,5): error TS2418: Type of computed property's value is 'number', which is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts (1 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts (2 errors) ==== interface I { [s: string]: boolean; [s: number]: boolean; } var o: I = { - ~ -!!! error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. [""+"foo"]: "", + ~~~~~~~~~~ +!!! error TS2418: Type of computed property's value is 'string', which is not assignable to type 'boolean'. +!!! related TS6501 tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts:2:5: The expected type comes from this index signature. [""+"bar"]: 0 + ~~~~~~~~~~ +!!! error TS2418: Type of computed property's value is 'number', which is not assignable to type 'boolean'. +!!! related TS6501 tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts:2:5: The expected type comes from this index signature. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt index 1048fd2e119e7..c24b53eaa1709 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt @@ -1,21 +1,20 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts(6,5): error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. - Index signatures are incompatible. - Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts(7,5): error TS2418: Type of computed property's value is 'string', which is not assignable to type 'boolean'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts(8,5): error TS2418: Type of computed property's value is 'number', which is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts (1 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts (2 errors) ==== interface I { [s: string]: boolean; [s: number]: boolean; } var o: I = { - ~ -!!! error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. -!!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. [""+"foo"]: "", + ~~~~~~~~~~ +!!! error TS2418: Type of computed property's value is 'string', which is not assignable to type 'boolean'. +!!! related TS6501 tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts:2:5: The expected type comes from this index signature. [""+"bar"]: 0 + ~~~~~~~~~~ +!!! error TS2418: Type of computed property's value is 'number', which is not assignable to type 'boolean'. +!!! related TS6501 tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts:2:5: The expected type comes from this index signature. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesWithStaticProperty.errors.txt b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.errors.txt index 5ce2c8bfe1ce5..34eee4d30b524 100644 --- a/tests/baselines/reference/computedPropertyNamesWithStaticProperty.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.errors.txt @@ -9,14 +9,17 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticPr get [C.staticProp]() { ~ !!! error TS2449: Class 'C' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts:1:7: 'C' is declared here. return "hello"; } set [C.staticProp](x: string) { ~ !!! error TS2449: Class 'C' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts:1:7: 'C' is declared here. var y = x; } [C.staticProp]() { } ~ !!! error TS2449: Class 'C' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts:1:7: 'C' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypesExcessProperties.errors.txt b/tests/baselines/reference/conditionalTypesExcessProperties.errors.txt new file mode 100644 index 0000000000000..a01cb8c8986b7 --- /dev/null +++ b/tests/baselines/reference/conditionalTypesExcessProperties.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/types/conditional/conditionalTypesExcessProperties.ts(8,5): error TS2322: Type '{ test: string; arg: A; }' is not assignable to type 'Something'. + Type '{ test: string; arg: A; }' is not assignable to type 'A extends object ? { arg: A; } : { arg?: undefined; }'. +tests/cases/conformance/types/conditional/conditionalTypesExcessProperties.ts(9,33): error TS2322: Type 'A' is not assignable to type 'Something["arr"]'. + Type 'object' is not assignable to type 'Something["arr"]'. + + +==== tests/cases/conformance/types/conditional/conditionalTypesExcessProperties.ts (2 errors) ==== + type Something = { test: string } & (T extends object ? { + arg: T + } : { + arg?: undefined + }); + + function testFunc2(a: A, sa: Something) { + sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable) + ~~ +!!! error TS2322: Type '{ test: string; arg: A; }' is not assignable to type 'Something'. +!!! error TS2322: Type '{ test: string; arg: A; }' is not assignable to type 'A extends object ? { arg: A; } : { arg?: undefined; }'. + sa = { test: 'bye', arg: a, arr: a } // excess + ~~~ +!!! error TS2322: Type 'A' is not assignable to type 'Something["arr"]'. +!!! error TS2322: Type 'object' is not assignable to type 'Something["arr"]'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypesExcessProperties.js b/tests/baselines/reference/conditionalTypesExcessProperties.js new file mode 100644 index 0000000000000..2dc9a0161a9f4 --- /dev/null +++ b/tests/baselines/reference/conditionalTypesExcessProperties.js @@ -0,0 +1,18 @@ +//// [conditionalTypesExcessProperties.ts] +type Something = { test: string } & (T extends object ? { + arg: T +} : { + arg?: undefined + }); + +function testFunc2(a: A, sa: Something) { + sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable) + sa = { test: 'bye', arg: a, arr: a } // excess +} + + +//// [conditionalTypesExcessProperties.js] +function testFunc2(a, sa) { + sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable) + sa = { test: 'bye', arg: a, arr: a }; // excess +} diff --git a/tests/baselines/reference/conditionalTypesExcessProperties.symbols b/tests/baselines/reference/conditionalTypesExcessProperties.symbols new file mode 100644 index 0000000000000..807330df855ea --- /dev/null +++ b/tests/baselines/reference/conditionalTypesExcessProperties.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/types/conditional/conditionalTypesExcessProperties.ts === +type Something = { test: string } & (T extends object ? { +>Something : Symbol(Something, Decl(conditionalTypesExcessProperties.ts, 0, 0)) +>T : Symbol(T, Decl(conditionalTypesExcessProperties.ts, 0, 15)) +>test : Symbol(test, Decl(conditionalTypesExcessProperties.ts, 0, 21)) +>T : Symbol(T, Decl(conditionalTypesExcessProperties.ts, 0, 15)) + + arg: T +>arg : Symbol(arg, Decl(conditionalTypesExcessProperties.ts, 0, 61)) +>T : Symbol(T, Decl(conditionalTypesExcessProperties.ts, 0, 15)) + +} : { + arg?: undefined +>arg : Symbol(arg, Decl(conditionalTypesExcessProperties.ts, 2, 5)) + + }); + +function testFunc2(a: A, sa: Something) { +>testFunc2 : Symbol(testFunc2, Decl(conditionalTypesExcessProperties.ts, 4, 7)) +>A : Symbol(A, Decl(conditionalTypesExcessProperties.ts, 6, 19)) +>a : Symbol(a, Decl(conditionalTypesExcessProperties.ts, 6, 37)) +>A : Symbol(A, Decl(conditionalTypesExcessProperties.ts, 6, 19)) +>sa : Symbol(sa, Decl(conditionalTypesExcessProperties.ts, 6, 42)) +>Something : Symbol(Something, Decl(conditionalTypesExcessProperties.ts, 0, 0)) +>A : Symbol(A, Decl(conditionalTypesExcessProperties.ts, 6, 19)) + + sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable) +>sa : Symbol(sa, Decl(conditionalTypesExcessProperties.ts, 6, 42)) +>test : Symbol(test, Decl(conditionalTypesExcessProperties.ts, 7, 10)) +>arg : Symbol(arg, Decl(conditionalTypesExcessProperties.ts, 7, 22)) +>a : Symbol(a, Decl(conditionalTypesExcessProperties.ts, 6, 37)) + + sa = { test: 'bye', arg: a, arr: a } // excess +>sa : Symbol(sa, Decl(conditionalTypesExcessProperties.ts, 6, 42)) +>test : Symbol(test, Decl(conditionalTypesExcessProperties.ts, 8, 10)) +>arg : Symbol(arg, Decl(conditionalTypesExcessProperties.ts, 8, 23)) +>a : Symbol(a, Decl(conditionalTypesExcessProperties.ts, 6, 37)) +>arr : Symbol(arr, Decl(conditionalTypesExcessProperties.ts, 8, 31)) +>a : Symbol(a, Decl(conditionalTypesExcessProperties.ts, 6, 37)) +} + diff --git a/tests/baselines/reference/conditionalTypesExcessProperties.types b/tests/baselines/reference/conditionalTypesExcessProperties.types new file mode 100644 index 0000000000000..7bbab8bfa1a46 --- /dev/null +++ b/tests/baselines/reference/conditionalTypesExcessProperties.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/types/conditional/conditionalTypesExcessProperties.ts === +type Something = { test: string } & (T extends object ? { +>Something : Something +>T : T +>test : string +>T : T + + arg: T +>arg : T +>T : T + +} : { + arg?: undefined +>arg : undefined + + }); + +function testFunc2(a: A, sa: Something) { +>testFunc2 : (a: A, sa: Something) => void +>A : A +>a : A +>A : A +>sa : Something +>Something : Something +>A : A + + sa = { test: 'hi', arg: a }; // not excess (but currently still not assignable) +>sa = { test: 'hi', arg: a } : { test: string; arg: A; } +>sa : Something +>{ test: 'hi', arg: a } : { test: string; arg: A; } +>test : string +>'hi' : "hi" +>arg : A +>a : A + + sa = { test: 'bye', arg: a, arr: a } // excess +>sa = { test: 'bye', arg: a, arr: a } : { test: string; arg: A; arr: A; } +>sa : Something +>{ test: 'bye', arg: a, arr: a } : { test: string; arg: A; arr: A; } +>test : string +>'bye' : "bye" +>arg : A +>a : A +>arr : A +>a : A +} + diff --git a/tests/baselines/reference/conflictingCommonJSES2015Exports.symbols b/tests/baselines/reference/conflictingCommonJSES2015Exports.symbols index b022439bf31cf..658650944eb85 100644 --- a/tests/baselines/reference/conflictingCommonJSES2015Exports.symbols +++ b/tests/baselines/reference/conflictingCommonJSES2015Exports.symbols @@ -6,7 +6,9 @@ export function abc(a, b, c) { return 5; } >c : Symbol(c, Decl(bug24934.js, 0, 25)) module.exports = { abc }; ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/bug24934", Decl(bug24934.js, 0, 0)) +>module : Symbol(module, Decl(bug24934.js, 0, 42)) +>exports : Symbol("tests/cases/conformance/salsa/bug24934", Decl(bug24934.js, 0, 0)) >abc : Symbol(abc, Decl(bug24934.js, 1, 18)) === tests/cases/conformance/salsa/use.js === diff --git a/tests/baselines/reference/conflictingCommonJSES2015Exports.types b/tests/baselines/reference/conflictingCommonJSES2015Exports.types index a9dc1ce80bd7c..2d49406a96438 100644 --- a/tests/baselines/reference/conflictingCommonJSES2015Exports.types +++ b/tests/baselines/reference/conflictingCommonJSES2015Exports.types @@ -7,11 +7,11 @@ export function abc(a, b, c) { return 5; } >5 : 5 module.exports = { abc }; ->module.exports = { abc } : { [x: string]: any; abc: (a: any, b: any, c: any) => number; } ->module.exports : any ->module : any ->exports : any ->{ abc } : { [x: string]: any; abc: (a: any, b: any, c: any) => number; } +>module.exports = { abc } : typeof import("tests/cases/conformance/salsa/bug24934") +>module.exports : typeof import("tests/cases/conformance/salsa/bug24934") +>module : { "tests/cases/conformance/salsa/bug24934": typeof import("tests/cases/conformance/salsa/bug24934"); } +>exports : typeof import("tests/cases/conformance/salsa/bug24934") +>{ abc } : { abc: (a: any, b: any, c: any) => number; } >abc : (a: any, b: any, c: any) => number === tests/cases/conformance/salsa/use.js === diff --git a/tests/baselines/reference/constDeclarations-useBeforeDefinition.errors.txt b/tests/baselines/reference/constDeclarations-useBeforeDefinition.errors.txt index a4d33065b5946..242bb75f503ab 100644 --- a/tests/baselines/reference/constDeclarations-useBeforeDefinition.errors.txt +++ b/tests/baselines/reference/constDeclarations-useBeforeDefinition.errors.txt @@ -7,6 +7,7 @@ tests/cases/compiler/constDeclarations-useBeforeDefinition.ts(8,5): error TS2448 c1; ~~ !!! error TS2448: Block-scoped variable 'c1' used before its declaration. +!!! related TS2728 tests/cases/compiler/constDeclarations-useBeforeDefinition.ts:3:11: 'c1' is declared here. const c1 = 0; } @@ -15,6 +16,7 @@ tests/cases/compiler/constDeclarations-useBeforeDefinition.ts(8,5): error TS2448 v1; ~~ !!! error TS2448: Block-scoped variable 'v1' used before its declaration. +!!! related TS2728 tests/cases/compiler/constDeclarations-useBeforeDefinition.ts:9:11: 'v1' is declared here. const v1 = 0; } \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations-useBeforeDefinition2.errors.txt b/tests/baselines/reference/constDeclarations-useBeforeDefinition2.errors.txt index bbcc3b2c8f8be..930cf63358ead 100644 --- a/tests/baselines/reference/constDeclarations-useBeforeDefinition2.errors.txt +++ b/tests/baselines/reference/constDeclarations-useBeforeDefinition2.errors.txt @@ -5,6 +5,7 @@ tests/cases/compiler/file1.ts(1,1): error TS2448: Block-scoped variable 'c' used c; ~ !!! error TS2448: Block-scoped variable 'c' used before its declaration. +!!! related TS2728 tests/cases/compiler/file2.ts:1:7: 'c' is declared here. ==== tests/cases/compiler/file2.ts (0 errors) ==== const c = 0; \ No newline at end of file diff --git a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js new file mode 100644 index 0000000000000..c1c676b1137d7 --- /dev/null +++ b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js @@ -0,0 +1,27 @@ +//// [constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts] +// https://github.com/Microsoft/TypeScript/issues/25379 + +interface Map { + // ... +} + +export type ImmutableTypes = IImmutableMap; + +export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; + +export interface IImmutableMap> extends Map { + set(key: K, value: T[K]): IImmutableMap; +} + +export type ImmutableTypes2 = IImmutableMap2; +type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; +export type ImmutableModel2 = { [K in keyof T]: isImmutableType }; +export interface IImmutableMap2> extends Map { + set(key: K, value: T[K]): IImmutableMap2; +} + + +//// [constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js] +"use strict"; +// https://github.com/Microsoft/TypeScript/issues/25379 +exports.__esModule = true; diff --git a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.symbols b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.symbols new file mode 100644 index 0000000000000..b60d7a05ae6fe --- /dev/null +++ b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.symbols @@ -0,0 +1,86 @@ +=== tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts === +// https://github.com/Microsoft/TypeScript/issues/25379 + +interface Map { +>Map : Symbol(Map, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 0, 0)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 2, 14)) +>V : Symbol(V, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 2, 16)) + + // ... +} + +export type ImmutableTypes = IImmutableMap; +>ImmutableTypes : Symbol(ImmutableTypes, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 4, 1)) +>IImmutableMap : Symbol(IImmutableMap, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 95)) + +export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; +>ImmutableModel : Symbol(ImmutableModel, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 6, 48)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 35)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 27)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 35)) +>ImmutableTypes : Symbol(ImmutableTypes, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 4, 1)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 35)) + +export interface IImmutableMap> extends Map { +>IImmutableMap : Symbol(IImmutableMap, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 95)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +>ImmutableModel : Symbol(ImmutableModel, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 6, 48)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +>Map : Symbol(Map, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 0, 0)) + + set(key: K, value: T[K]): IImmutableMap; +>set : Symbol(IImmutableMap.set, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 86)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 8)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +>key : Symbol(key, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 8)) +>value : Symbol(value, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 34)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 11, 8)) +>IImmutableMap : Symbol(IImmutableMap, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 8, 95)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 10, 31)) +} + +export type ImmutableTypes2 = IImmutableMap2; +>ImmutableTypes2 : Symbol(ImmutableTypes2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 12, 1)) +>IImmutableMap2 : Symbol(IImmutableMap2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 75)) + +type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; +>isImmutableType : Symbol(isImmutableType, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 14, 50)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 21)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 21)) +>ImmutableTypes2 : Symbol(ImmutableTypes2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 12, 1)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 21)) + +export type ImmutableModel2 = { [K in keyof T]: isImmutableType }; +>ImmutableModel2 : Symbol(ImmutableModel2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 68)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 28)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 36)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 28)) +>isImmutableType : Symbol(isImmutableType, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 14, 50)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 28)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 36)) + +export interface IImmutableMap2> extends Map { +>IImmutableMap2 : Symbol(IImmutableMap2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 75)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +>ImmutableModel2 : Symbol(ImmutableModel2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 15, 68)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +>Map : Symbol(Map, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 0, 0)) + + set(key: K, value: T[K]): IImmutableMap2; +>set : Symbol(IImmutableMap2.set, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 88)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 8)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +>key : Symbol(key, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 27)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 8)) +>value : Symbol(value, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 34)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +>K : Symbol(K, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 18, 8)) +>IImmutableMap2 : Symbol(IImmutableMap2, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 16, 75)) +>T : Symbol(T, Decl(constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts, 17, 32)) +} + diff --git a/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types new file mode 100644 index 0000000000000..1e9d3f99e21ac --- /dev/null +++ b/tests/baselines/reference/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types @@ -0,0 +1,86 @@ +=== tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts === +// https://github.com/Microsoft/TypeScript/issues/25379 + +interface Map { +>Map : Map +>K : K +>V : V + + // ... +} + +export type ImmutableTypes = IImmutableMap; +>ImmutableTypes : IImmutableMap +>IImmutableMap : IImmutableMap + +export type ImmutableModel = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never }; +>ImmutableModel : ImmutableModel +>T : T +>K : K +>T : T +>T : T +>K : K +>ImmutableTypes : IImmutableMap +>T : T +>K : K + +export interface IImmutableMap> extends Map { +>IImmutableMap : IImmutableMap +>T : T +>ImmutableModel : ImmutableModel +>T : T +>Map : Map + + set(key: K, value: T[K]): IImmutableMap; +>set : (key: K, value: T[K]) => IImmutableMap +>K : K +>T : T +>key : K +>K : K +>value : T[K] +>T : T +>K : K +>IImmutableMap : IImmutableMap +>T : T +} + +export type ImmutableTypes2 = IImmutableMap2; +>ImmutableTypes2 : IImmutableMap2 +>IImmutableMap2 : IImmutableMap2 + +type isImmutableType = [T] extends [ImmutableTypes2] ? T : never; +>isImmutableType : isImmutableType +>T : T +>T : T +>ImmutableTypes2 : IImmutableMap2 +>T : T + +export type ImmutableModel2 = { [K in keyof T]: isImmutableType }; +>ImmutableModel2 : ImmutableModel2 +>T : T +>K : K +>T : T +>isImmutableType : isImmutableType +>T : T +>K : K + +export interface IImmutableMap2> extends Map { +>IImmutableMap2 : IImmutableMap2 +>T : T +>ImmutableModel2 : ImmutableModel2 +>T : T +>Map : Map + + set(key: K, value: T[K]): IImmutableMap2; +>set : (key: K, value: T[K]) => IImmutableMap2 +>K : K +>T : T +>key : K +>K : K +>value : T[K] +>T : T +>K : K +>IImmutableMap2 : IImmutableMap2 +>T : T +} + diff --git a/tests/baselines/reference/constructorFunctions2.symbols b/tests/baselines/reference/constructorFunctions2.symbols index a01826b1c9994..033a428e6e593 100644 --- a/tests/baselines/reference/constructorFunctions2.symbols +++ b/tests/baselines/reference/constructorFunctions2.symbols @@ -52,6 +52,7 @@ function A() { this.id = 1; } >id : Symbol(A.id, Decl(other.js, 0, 14)) module.exports = A; +>module.exports : Symbol("tests/cases/conformance/salsa/other", Decl(other.js, 0, 0)) >module : Symbol(export=, Decl(other.js, 0, 29)) >exports : Symbol(export=, Decl(other.js, 0, 29)) >A : Symbol(A, Decl(other.js, 0, 0)) diff --git a/tests/baselines/reference/constructorFunctions2.types b/tests/baselines/reference/constructorFunctions2.types index c5c59c25dbabc..b35b5ce2f2ffe 100644 --- a/tests/baselines/reference/constructorFunctions2.types +++ b/tests/baselines/reference/constructorFunctions2.types @@ -70,8 +70,8 @@ function A() { this.id = 1; } module.exports = A; >module.exports = A : typeof A ->module.exports : any ->module : any ->exports : any +>module.exports : typeof A +>module : { "tests/cases/conformance/salsa/other": typeof A; } +>exports : typeof A >A : typeof A diff --git a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt index ef1765eb017a1..6d3644eabb035 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -1,9 +1,7 @@ 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,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,18): error TS2322: Type 'number' is not assignable to type 'T'. ==== tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts (4 errors) ==== @@ -38,11 +36,10 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl constructor() { return { x: 1 }; // error ~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ x: number; }' is not assignable to type 'F'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'T'. - ~~~~~~~~~~~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'T'. +!!! related TS6500 tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts:24:5: The expected type comes from property 'x' which is declared here on type 'F' } } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index a55c3af655549..46eaa413c2e8f 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -466,6 +466,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS return this.method1(2); ~~~~~~~ !!! error TS2551: Property 'method1' does not exist on type 'B'. Did you mean 'method2'? +!!! related TS2728 tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts:245:16: 'method2' is declared here. } } diff --git a/tests/baselines/reference/contextualTypeAny.errors.txt b/tests/baselines/reference/contextualTypeAny.errors.txt index 09970be986ddb..90f11f7c0140b 100644 --- a/tests/baselines/reference/contextualTypeAny.errors.txt +++ b/tests/baselines/reference/contextualTypeAny.errors.txt @@ -1,15 +1,12 @@ -tests/cases/compiler/contextualTypeAny.ts(3,5): error TS2322: Type '{ p: string; q: any; }' is not assignable to type '{ [s: string]: number; }'. - Property 'p' is incompatible with index signature. - Type 'string' is not assignable to type 'number'. +tests/cases/compiler/contextualTypeAny.ts(3,38): error TS2322: Type 'string' is not assignable to type 'number'. ==== tests/cases/compiler/contextualTypeAny.ts (1 errors) ==== var x: any; var obj: { [s: string]: number } = { p: "", q: x }; - ~~~ -!!! error TS2322: Type '{ p: string; q: any; }' is not assignable to type '{ [s: string]: number; }'. -!!! error TS2322: Property 'p' is incompatible with index signature. -!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6501 tests/cases/compiler/contextualTypeAny.ts:3:12: The expected type comes from this index signature. var arr: number[] = ["", x]; \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypeWithTuple.errors.txt b/tests/baselines/reference/contextualTypeWithTuple.errors.txt index 58a90919c5b29..9d9c015457bbc 100644 --- a/tests/baselines/reference/contextualTypeWithTuple.errors.txt +++ b/tests/baselines/reference/contextualTypeWithTuple.errors.txt @@ -2,9 +2,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS232 Types of property 'length' are incompatible. Type '3' is not assignable to type '2'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'. -tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'. - Type '{}' is not assignable to type '{ a: string; }'. - Property 'a' is missing in type '{}'. +tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,17): error TS2322: Type '{}' is not assignable to type '{ a: string; }'. + Property 'a' is missing in type '{}'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(19,1): error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'. Property '2' is missing in type '[number, string]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(20,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]'. @@ -45,10 +44,9 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23 // error objNumTuple = [ {}, 5]; - ~~~~~~~~~~~ -!!! error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'. -!!! error TS2322: Type '{}' is not assignable to type '{ a: string; }'. -!!! error TS2322: Property 'a' is missing in type '{}'. + ~~ +!!! error TS2322: Type '{}' is not assignable to type '{ a: string; }'. +!!! error TS2322: Property 'a' is missing in type '{}'. numStrBoolTuple = numStrTuple; ~~~~~~~~~~~~~~~ !!! error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'. diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt b/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt index 651d4f5381f4d..e4ffa209e6fd2 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt +++ b/tests/baselines/reference/contextualTypeWithUnionTypeObjectLiteral.errors.txt @@ -21,12 +21,10 @@ tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts( Types of property 'prop' are incompatible. Type 'string | number' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(57,5): error TS2322: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I11 | I21'. - Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I21'. - Types of property 'commonMethodDifferentReturnType' are incompatible. - Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts(58,5): error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '((a: string, b: number) => string) | ((a: string, b: number) => number)'. + Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'. + Type 'string | number' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts (6 errors) ==== @@ -115,12 +113,11 @@ tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts( }; var strOrNumber: string | number; var i11Ori21: I11 | I21 = { // Like i1 and i2 both - ~~~~~~~~ -!!! error TS2322: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I11 | I21'. -!!! error TS2322: Type '{ commonMethodDifferentReturnType: (a: string, b: number) => string | number; }' is not assignable to type 'I21'. -!!! error TS2322: Types of property 'commonMethodDifferentReturnType' are incompatible. -!!! error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. commonMethodDifferentReturnType: (a, b) => strOrNumber, + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '((a: string, b: number) => string) | ((a: string, b: number) => number)'. +!!! error TS2322: Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'. +!!! error TS2322: Type 'string | number' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/types/union/contextualTypeWithUnionTypeObjectLiteral.ts:35:5: The expected type comes from property 'commonMethodDifferentReturnType' which is declared here on type 'I11 | I21' }; \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypedSpecialAssignment.symbols b/tests/baselines/reference/contextualTypedSpecialAssignment.symbols new file mode 100644 index 0000000000000..375c5e939190f --- /dev/null +++ b/tests/baselines/reference/contextualTypedSpecialAssignment.symbols @@ -0,0 +1,179 @@ +=== tests/cases/conformance/salsa/test.js === +/** @typedef {{ + status: 'done' + m(n: number): void +}} DoneStatus */ + +// property assignment +var ns = {} +>ns : Symbol(ns, Decl(test.js, 6, 3)) + +/** @type {DoneStatus} */ +ns.x = { +>ns.x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) +>ns : Symbol(ns, Decl(test.js, 6, 3)) +>x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) + + status: 'done', +>status : Symbol(status, Decl(test.js, 8, 8)) + + m(n) { } +>m : Symbol(m, Decl(test.js, 9, 19)) +>n : Symbol(n, Decl(test.js, 10, 6)) +} + +ns.x = { +>ns.x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) +>ns : Symbol(ns, Decl(test.js, 6, 3)) +>x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) + + status: 'done', +>status : Symbol(status, Decl(test.js, 13, 8)) + + m(n) { } +>m : Symbol(m, Decl(test.js, 14, 19)) +>n : Symbol(n, Decl(test.js, 15, 6)) +} +ns.x +>ns.x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) +>ns : Symbol(ns, Decl(test.js, 6, 3)) +>x : Symbol(ns.x, Decl(test.js, 6, 11), Decl(test.js, 11, 1)) + + +// this-property assignment +class Thing { +>Thing : Symbol(Thing, Decl(test.js, 17, 4)) + + constructor() { + /** @type {DoneStatus} */ + this.s = { +>this.s : Symbol(Thing.s, Decl(test.js, 22, 19), Decl(test.js, 30, 12)) +>this : Symbol(Thing, Decl(test.js, 17, 4)) +>s : Symbol(Thing.s, Decl(test.js, 22, 19), Decl(test.js, 30, 12)) + + status: 'done', +>status : Symbol(status, Decl(test.js, 24, 18)) + + m(n) { } +>m : Symbol(m, Decl(test.js, 25, 27)) +>n : Symbol(n, Decl(test.js, 26, 14)) + } + } + + fail() { +>fail : Symbol(Thing.fail, Decl(test.js, 28, 5)) + + this.s = { +>this.s : Symbol(Thing.s, Decl(test.js, 22, 19), Decl(test.js, 30, 12)) +>this : Symbol(Thing, Decl(test.js, 17, 4)) +>s : Symbol(Thing.s, Decl(test.js, 22, 19), Decl(test.js, 30, 12)) + + status: 'done', +>status : Symbol(status, Decl(test.js, 31, 18)) + + m(n) { } +>m : Symbol(m, Decl(test.js, 32, 27)) +>n : Symbol(n, Decl(test.js, 33, 14)) + } + } +} + +// exports-property assignment + +/** @type {DoneStatus} */ +exports.x = { +>exports.x : Symbol(x, Decl(test.js, 36, 1)) +>exports : Symbol(x, Decl(test.js, 36, 1)) +>x : Symbol(x, Decl(test.js, 36, 1)) + + status: "done", +>status : Symbol(status, Decl(test.js, 41, 13)) + + m(n) { } +>m : Symbol(m, Decl(test.js, 42, 19)) +>n : Symbol(n, Decl(test.js, 43, 6)) +} +exports.x +>exports.x : Symbol(x, Decl(test.js, 36, 1)) +>exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0)) +>x : Symbol(x, Decl(test.js, 36, 1)) + +/** @type {DoneStatus} */ +module.exports.y = { +>module.exports.y : Symbol(y, Decl(test.js, 45, 9)) +>module.exports : Symbol(y, Decl(test.js, 45, 9)) +>module : Symbol(module, Decl(test.js, 45, 9), Decl(test.js, 51, 1)) +>exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0)) +>y : Symbol(y, Decl(test.js, 45, 9)) + + status: "done", +>status : Symbol(status, Decl(test.js, 48, 20)) + + m(n) { } +>m : Symbol(m, Decl(test.js, 49, 19)) +>n : Symbol(n, Decl(test.js, 50, 6)) +} +module.exports.y +>module.exports.y : Symbol(y, Decl(test.js, 45, 9)) +>module.exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0)) +>module : Symbol(module, Decl(test.js, 45, 9), Decl(test.js, 51, 1)) +>exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0)) +>y : Symbol(y, Decl(test.js, 45, 9)) + +// prototype-property assignment +/** @type {DoneStatus} */ +Thing.prototype.x = { +>Thing.prototype.x : Symbol(Thing.x, Decl(test.js, 52, 16)) +>Thing.prototype : Symbol(Thing.x, Decl(test.js, 52, 16)) +>Thing : Symbol(Thing, Decl(test.js, 17, 4)) +>prototype : Symbol(Thing.prototype) +>x : Symbol(Thing.x, Decl(test.js, 52, 16)) + + status: 'done', +>status : Symbol(status, Decl(test.js, 56, 21)) + + m(n) { } +>m : Symbol(m, Decl(test.js, 57, 19)) +>n : Symbol(n, Decl(test.js, 58, 6)) +} +Thing.prototype.x +>Thing.prototype.x : Symbol(Thing.x, Decl(test.js, 52, 16)) +>Thing.prototype : Symbol(Thing.prototype) +>Thing : Symbol(Thing, Decl(test.js, 17, 4)) +>prototype : Symbol(Thing.prototype) +>x : Symbol(Thing.x, Decl(test.js, 52, 16)) + +// prototype assignment +function F() { +>F : Symbol(F, Decl(test.js, 60, 17), Decl(test.js, 64, 1)) +} +/** @type {DoneStatus} */ +F.prototype = { +>F.prototype : Symbol(F.prototype, Decl(test.js, 64, 1)) +>F : Symbol(F, Decl(test.js, 60, 17), Decl(test.js, 64, 1)) +>prototype : Symbol(F.prototype, Decl(test.js, 64, 1)) + + status: "done", +>status : Symbol(status, Decl(test.js, 66, 15)) + + m(n) { } +>m : Symbol(m, Decl(test.js, 67, 19)) +>n : Symbol(n, Decl(test.js, 68, 6)) +} + +=== tests/cases/conformance/salsa/mod.js === +// module.exports assignment +/** @type {{ status: 'done', m(n: number): void }} */ +module.exports = { +>module.exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) +>module : Symbol(export=, Decl(mod.js, 0, 0)) +>exports : Symbol(export=, Decl(mod.js, 0, 0)) + + status: "done", +>status : Symbol(status, Decl(mod.js, 2, 18)) + + m(n) { } +>m : Symbol(m, Decl(mod.js, 3, 19)) +>n : Symbol(n, Decl(mod.js, 4, 6)) +} + diff --git a/tests/baselines/reference/contextualTypedSpecialAssignment.types b/tests/baselines/reference/contextualTypedSpecialAssignment.types new file mode 100644 index 0000000000000..c178799c94dda --- /dev/null +++ b/tests/baselines/reference/contextualTypedSpecialAssignment.types @@ -0,0 +1,207 @@ +=== tests/cases/conformance/salsa/test.js === +/** @typedef {{ + status: 'done' + m(n: number): void +}} DoneStatus */ + +// property assignment +var ns = {} +>ns : { [x: string]: any; x: { status: "done"; m(n: number): void; }; } +>{} : { [x: string]: any; } + +/** @type {DoneStatus} */ +ns.x = { +>ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } +>ns.x : { status: "done"; m(n: number): void; } +>ns : { [x: string]: any; x: { status: "done"; m(n: number): void; }; } +>x : { status: "done"; m(n: number): void; } +>{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } + + status: 'done', +>status : "done" +>'done' : "done" + + m(n) { } +>m : (n: number) => void +>n : number +} + +ns.x = { +>ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } +>ns.x : { status: "done"; m(n: number): void; } +>ns : { [x: string]: any; x: { status: "done"; m(n: number): void; }; } +>x : { status: "done"; m(n: number): void; } +>{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } + + status: 'done', +>status : "done" +>'done' : "done" + + m(n) { } +>m : (n: number) => void +>n : number +} +ns.x +>ns.x : { status: "done"; m(n: number): void; } +>ns : { [x: string]: any; x: { status: "done"; m(n: number): void; }; } +>x : { status: "done"; m(n: number): void; } + + +// this-property assignment +class Thing { +>Thing : Thing + + constructor() { + /** @type {DoneStatus} */ + this.s = { +>this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } +>this.s : { status: "done"; m(n: number): void; } +>this : this +>s : { status: "done"; m(n: number): void; } +>{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } + + status: 'done', +>status : "done" +>'done' : "done" + + m(n) { } +>m : (n: number) => void +>n : number + } + } + + fail() { +>fail : () => void + + this.s = { +>this.s = { status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } +>this.s : { status: "done"; m(n: number): void; } +>this : this +>s : { status: "done"; m(n: number): void; } +>{ status: 'done', m(n) { } } : { status: "done"; m(n: number): void; } + + status: 'done', +>status : "done" +>'done' : "done" + + m(n) { } +>m : (n: number) => void +>n : number + } + } +} + +// exports-property assignment + +/** @type {DoneStatus} */ +exports.x = { +>exports.x = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } +>exports.x : { status: "done"; m(n: number): void; } +>exports : typeof import("tests/cases/conformance/salsa/test") +>x : { status: "done"; m(n: number): void; } +>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } + + status: "done", +>status : "done" +>"done" : "done" + + m(n) { } +>m : (n: number) => void +>n : number +} +exports.x +>exports.x : { status: "done"; m(n: number): void; } +>exports : typeof import("tests/cases/conformance/salsa/test") +>x : { status: "done"; m(n: number): void; } + +/** @type {DoneStatus} */ +module.exports.y = { +>module.exports.y = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } +>module.exports.y : { status: "done"; m(n: number): void; } +>module.exports : typeof import("tests/cases/conformance/salsa/test") +>module : { "tests/cases/conformance/salsa/test": typeof import("tests/cases/conformance/salsa/test"); } +>exports : typeof import("tests/cases/conformance/salsa/test") +>y : { status: "done"; m(n: number): void; } +>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } + + status: "done", +>status : "done" +>"done" : "done" + + m(n) { } +>m : (n: number) => void +>n : number +} +module.exports.y +>module.exports.y : { status: "done"; m(n: number): void; } +>module.exports : typeof import("tests/cases/conformance/salsa/test") +>module : { "tests/cases/conformance/salsa/test": typeof import("tests/cases/conformance/salsa/test"); } +>exports : typeof import("tests/cases/conformance/salsa/test") +>y : { status: "done"; m(n: number): void; } + +// prototype-property assignment +/** @type {DoneStatus} */ +Thing.prototype.x = { +>Thing.prototype.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } +>Thing.prototype.x : { status: "done"; m(n: number): void; } +>Thing.prototype : Thing +>Thing : typeof Thing +>prototype : Thing +>x : { status: "done"; m(n: number): void; } +>{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } + + status: 'done', +>status : "done" +>'done' : "done" + + m(n) { } +>m : (n: number) => void +>n : number +} +Thing.prototype.x +>Thing.prototype.x : { status: "done"; m(n: number): void; } +>Thing.prototype : Thing +>Thing : typeof Thing +>prototype : Thing +>x : { status: "done"; m(n: number): void; } + +// prototype assignment +function F() { +>F : typeof F +} +/** @type {DoneStatus} */ +F.prototype = { +>F.prototype = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } +>F.prototype : { status: "done"; m(n: number): void; } +>F : typeof F +>prototype : { status: "done"; m(n: number): void; } +>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } + + status: "done", +>status : "done" +>"done" : "done" + + m(n) { } +>m : (n: number) => void +>n : number +} + +=== tests/cases/conformance/salsa/mod.js === +// module.exports assignment +/** @type {{ status: 'done', m(n: number): void }} */ +module.exports = { +>module.exports = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; } +>module.exports : { status: "done"; m(n: number): void; } +>module : { "tests/cases/conformance/salsa/mod": { status: "done"; m(n: number): void; }; } +>exports : { status: "done"; m(n: number): void; } +>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; } + + status: "done", +>status : "done" +>"done" : "done" + + m(n) { } +>m : (n: number) => void +>n : number +} + diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt new file mode 100644 index 0000000000000..1bc381ec39db0 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt @@ -0,0 +1,62 @@ +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(4,20): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(5,23): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(6,25): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(11,40): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(16,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(21,22): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(26,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. + + +==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts (7 errors) ==== + interface Show { + show: (x: number) => string; + } + function f({ show: showRename = v => v }: Show) {} + ~~~~~~~~~~ +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + function f2({ "show": showRename = v => v }: Show) {} + ~~~~~~~~~~ +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + function f3({ ["show"]: showRename = v => v }: Show) {} + ~~~~~~~~~~ +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + interface Nested { + nested: Show + } + function ff({ nested: nestedRename = { show: v => v } }: Nested) {} + ~~~~ +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts:2:5: The expected type comes from property 'show' which is declared here on type 'Show' + + interface StringIdentity { + stringIdentity(s: string): string; + } + let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; + ~~ +!!! error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + interface Tuples { + prop: [string, number]; + } + function g({ prop = [101, 1234] }: Tuples) {} + ~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + interface StringUnion { + prop: "foo" | "bar"; + } + function h({ prop = "baz" }: StringUnion) {} + ~~~~ +!!! error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. + \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types index 1548e626e6da1..f53d29b56a278 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types @@ -9,7 +9,7 @@ interface Show { function f({ show: showRename = v => v }: Show) {} >f : ({ show: showRename }: Show) => void >show : any ->showRename : ((x: number) => string) | ((v: number) => number) +>showRename : (x: number) => string >v => v : (v: number) => number >v : number >v : number @@ -17,7 +17,7 @@ function f({ show: showRename = v => v }: Show) {} function f2({ "show": showRename = v => v }: Show) {} >f2 : ({ "show": showRename }: Show) => void ->showRename : ((x: number) => string) | ((v: number) => number) +>showRename : (x: number) => string >v => v : (v: number) => number >v : number >v : number @@ -26,7 +26,7 @@ function f2({ "show": showRename = v => v }: Show) {} function f3({ ["show"]: showRename = v => v }: Show) {} >f3 : ({ ["show"]: showRename }: Show) => void >"show" : "show" ->showRename : ((x: number) => string) | ((v: number) => number) +>showRename : (x: number) => string >v => v : (v: number) => number >v : number >v : number @@ -42,7 +42,7 @@ interface Nested { function ff({ nested: nestedRename = { show: v => v } }: Nested) {} >ff : ({ nested: nestedRename }: Nested) => void >nested : any ->nestedRename : Show | { show: (v: number) => number; } +>nestedRename : Show >{ show: v => v } : { show: (v: number) => number; } >show : (v: number) => number >v => v : (v: number) => number @@ -59,7 +59,7 @@ interface StringIdentity { } let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; >stringIdentity : any ->id : ((s: string) => string) | ((arg: string) => number) +>id : (s: string) => string >arg => arg.length : (arg: string) => number >arg : string >arg.length : number @@ -80,7 +80,7 @@ interface Tuples { } function g({ prop = [101, 1234] }: Tuples) {} >g : ({ prop }: Tuples) => void ->prop : [string, number] | [number, number] +>prop : [string, number] >[101, 1234] : [number, number] >101 : 101 >1234 : 1234 @@ -94,7 +94,7 @@ interface StringUnion { } function h({ prop = "baz" }: StringUnion) {} >h : ({ prop }: StringUnion) => void ->prop : "foo" | "bar" | "baz" +>prop : "foo" | "bar" >"baz" : "baz" >StringUnion : StringUnion diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index 7b86fe1f33786..df0b788459476 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -101,12 +101,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) => numbers.every(n => n > 0)) : (numbers_0: number, numbers_1: number, numbers_2: number) => boolean +>(...numbers) => numbers.every(n => n > 0) : (numbers_0: number, numbers_1: number, numbers_2: number) => boolean +>numbers : [number, number, number] >numbers.every(n => n > 0) : boolean >numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->numbers : number[] +>numbers : [number, number, number] >every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean >n => n > 0 : (n: number) => boolean >n : number @@ -119,12 +119,12 @@ ((...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) => mixed.every(n => !!n)) : (mixed_0: number, mixed_1: string, mixed_2: string) => boolean +>(...mixed) => mixed.every(n => !!n) : (mixed_0: number, mixed_1: string, mixed_2: string) => boolean +>mixed : [number, string, string] >mixed.every(n => !!n) : boolean >mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean ->mixed : (string | number)[] +>mixed : [number, string, string] >every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean >n => !!n : (n: string | number) => boolean >n : string | number @@ -137,31 +137,31 @@ ((...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) => noNumbers.some(n => n > 0)) : () => boolean +>(...noNumbers) => noNumbers.some(n => n > 0) : () => boolean +>noNumbers : [] >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 +>noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>noNumbers : [] +>some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: never) => boolean +>n : never >n > 0 : boolean ->n : any +>n : never >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, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, rest_0: number, rest_1: number) => boolean[] +>(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, rest_0: number, rest_1: number) => boolean[] >first : number ->rest : number[] +>rest : [number, number] >first ? [] : rest.map(n => n > 0) : boolean[] >first : number >[] : undefined[] >rest.map(n => n > 0) : boolean[] >rest.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] ->rest : number[] +>rest : [number, number] >map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >n => n > 0 : (n: number) => boolean >n : number diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types index 5a8a33ac41df2..e20c08a20debf 100644 --- a/tests/baselines/reference/contextuallyTypedIifeStrict.types +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -101,12 +101,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) => numbers.every(n => n > 0)) : (numbers_0: number, numbers_1: number, numbers_2: number) => boolean +>(...numbers) => numbers.every(n => n > 0) : (numbers_0: number, numbers_1: number, numbers_2: number) => boolean +>numbers : [number, number, number] >numbers.every(n => n > 0) : boolean >numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->numbers : number[] +>numbers : [number, number, number] >every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean >n => n > 0 : (n: number) => boolean >n : number @@ -119,12 +119,12 @@ ((...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) => mixed.every(n => !!n)) : (mixed_0: number, mixed_1: string, mixed_2: string) => boolean +>(...mixed) => mixed.every(n => !!n) : (mixed_0: number, mixed_1: string, mixed_2: string) => boolean +>mixed : [number, string, string] >mixed.every(n => !!n) : boolean >mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean ->mixed : (string | number)[] +>mixed : [number, string, string] >every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean >n => !!n : (n: string | number) => boolean >n : string | number @@ -137,31 +137,31 @@ ((...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) => noNumbers.some(n => n > 0)) : () => boolean +>(...noNumbers) => noNumbers.some(n => n > 0) : () => boolean +>noNumbers : [] >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 +>noNumbers.some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>noNumbers : [] +>some : (callbackfn: (value: never, index: number, array: never[]) => boolean, thisArg?: any) => boolean +>n => n > 0 : (n: never) => boolean +>n : never >n > 0 : boolean ->n : any +>n : never >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, ...rest) => first ? [] : rest.map(n => n > 0)) : (first: number, rest_0: number, rest_1: number) => boolean[] +>(first, ...rest) => first ? [] : rest.map(n => n > 0) : (first: number, rest_0: number, rest_1: number) => boolean[] >first : number ->rest : number[] +>rest : [number, number] >first ? [] : rest.map(n => n > 0) : boolean[] >first : number >[] : never[] >rest.map(n => n > 0) : boolean[] >rest.map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] ->rest : number[] +>rest : [number, number] >map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >n => n > 0 : (n: number) => boolean >n : number diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt index a3ddd397a6495..bfd0462953a81 100644 --- a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.errors.txt @@ -1,7 +1,5 @@ -tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(15,15): error TS2326: Types of property 'foo' are incompatible. - Type '"f"' is not assignable to type '"A" | "B" | "C"'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(16,15): error TS2326: Types of property 'foo' are incompatible. - Type '"f"' is not assignable to type '"A" | "B" | "C"'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(15,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 '"f"' is not assignable to type '"A" | "B" | "C"'. ==== tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx (2 errors) ==== @@ -20,10 +18,10 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStr ; ; - ~~~~~~~~~ -!!! error TS2326: Types of property 'foo' are incompatible. -!!! error TS2326: Type '"f"' is not assignable to type '"A" | "B" | "C"'. + ~~~ +!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'. +!!! related TS6500 tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx:10:32: The expected type comes from property 'foo' which is declared here on type '{ foo: "A" | "B" | "C"; }' ; - ~~~~~~~ -!!! error TS2326: Types of property 'foo' are incompatible. -!!! error TS2326: Type '"f"' is not assignable to type '"A" | "B" | "C"'. \ No newline at end of file + ~~~ +!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'. +!!! related TS6500 tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx:10:32: The expected type comes from property 'foo' which is declared here on type '{ foo: "A" | "B" | "C"; }' \ No newline at end of file diff --git a/tests/baselines/reference/declFileImportedTypeUseInTypeArgPosition.types b/tests/baselines/reference/declFileImportedTypeUseInTypeArgPosition.types index 705cb99417d6d..61b175fc47860 100644 --- a/tests/baselines/reference/declFileImportedTypeUseInTypeArgPosition.types +++ b/tests/baselines/reference/declFileImportedTypeUseInTypeArgPosition.types @@ -4,7 +4,7 @@ class List { } >T : T declare module 'mod1' { ->'mod1' : typeof 'mod1' +>'mod1' : typeof import("mod1") class Foo { >Foo : Foo @@ -12,7 +12,7 @@ declare module 'mod1' { } declare module 'moo' { ->'moo' : typeof 'moo' +>'moo' : typeof import("moo") import x = require('mod1'); >x : typeof x diff --git a/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.js b/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.js new file mode 100644 index 0000000000000..ede9906598625 --- /dev/null +++ b/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/declarationEmitCrossFileImportTypeOfAmbientModule.ts] //// + +//// [component.d.ts] +declare module '@namespace/component' { + export class Foo {} +} +//// [index.d.ts] +import { Foo } from "@namespace/component"; +export declare const item: typeof Foo; +//// [index.ts] +import { item } from "../somepackage"; +export const reeexported = item; + + +//// [index.js] +"use strict"; +exports.__esModule = true; +var somepackage_1 = require("../somepackage"); +exports.reeexported = somepackage_1.item; + + +//// [index.d.ts] +/// +export declare const reeexported: typeof import("@namespace/component").Foo; diff --git a/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.symbols b/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.symbols new file mode 100644 index 0000000000000..368ebcf365093 --- /dev/null +++ b/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/types/component.d.ts === +declare module '@namespace/component' { +>'@namespace/component' : Symbol('@namespace/component', Decl(component.d.ts, 0, 0)) + + export class Foo {} +>Foo : Symbol(Foo, Decl(component.d.ts, 0, 39)) +} +=== tests/cases/compiler/packages/somepackage/index.d.ts === +import { Foo } from "@namespace/component"; +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 8)) + +export declare const item: typeof Foo; +>item : Symbol(item, Decl(index.d.ts, 1, 20)) +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 8)) + +=== tests/cases/compiler/packages/secondpackage/index.ts === +import { item } from "../somepackage"; +>item : Symbol(item, Decl(index.ts, 0, 8)) + +export const reeexported = item; +>reeexported : Symbol(reeexported, Decl(index.ts, 1, 12)) +>item : Symbol(item, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.types b/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.types new file mode 100644 index 0000000000000..10077e2e96ac8 --- /dev/null +++ b/tests/baselines/reference/declarationEmitCrossFileImportTypeOfAmbientModule.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/types/component.d.ts === +declare module '@namespace/component' { +>'@namespace/component' : typeof import("@namespace/component") + + export class Foo {} +>Foo : Foo +} +=== tests/cases/compiler/packages/somepackage/index.d.ts === +import { Foo } from "@namespace/component"; +>Foo : typeof Foo + +export declare const item: typeof Foo; +>item : typeof Foo +>Foo : typeof Foo + +=== tests/cases/compiler/packages/secondpackage/index.ts === +import { item } from "../somepackage"; +>item : typeof import("@namespace/component").Foo + +export const reeexported = item; +>reeexported : typeof import("@namespace/component").Foo +>item : typeof import("@namespace/component").Foo + diff --git a/tests/baselines/reference/declarationEmitHasTypesRefOnNamespaceUse.js b/tests/baselines/reference/declarationEmitHasTypesRefOnNamespaceUse.js index c95366c765fd9..751ca63bebe92 100644 --- a/tests/baselines/reference/declarationEmitHasTypesRefOnNamespaceUse.js +++ b/tests/baselines/reference/declarationEmitHasTypesRefOnNamespaceUse.js @@ -25,28 +25,3 @@ var Src = /** @class */ (function () { /// declare class Src implements NS.Dep { } - - -//// [DtsFileErrors] - - -error TS2688: Cannot find type definition file for 'dep'. -/src/index.d.ts(1,23): error TS2688: Cannot find type definition file for 'dep'. -/src/index.d.ts(2,30): error TS2503: Cannot find namespace 'NS'. - - -!!! error TS2688: Cannot find type definition file for 'dep'. -==== /src/index.d.ts (2 errors) ==== - /// - ~~~ -!!! error TS2688: Cannot find type definition file for 'dep'. - declare class Src implements NS.Dep { - ~~ -!!! error TS2503: Cannot find namespace 'NS'. - } - -==== /deps/dep/dep.d.ts (0 errors) ==== - declare namespace NS { - interface Dep { - } - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitUnnessesaryTypeReferenceNotAdded.js b/tests/baselines/reference/declarationEmitUnnessesaryTypeReferenceNotAdded.js index f3ea5920983c3..739b67e2cde6a 100644 --- a/tests/baselines/reference/declarationEmitUnnessesaryTypeReferenceNotAdded.js +++ b/tests/baselines/reference/declarationEmitUnnessesaryTypeReferenceNotAdded.js @@ -44,30 +44,3 @@ exports.default = parseArgs; //// [index.d.ts] import minimist = require('minimist'); export default function parseArgs(): minimist.ParsedArgs; - - -//// [DtsFileErrors] - - -error TS2688: Cannot find type definition file for 'minimist'. -error TS2688: Cannot find type definition file for 'process'. -/index.d.ts(1,27): error TS2307: Cannot find module 'minimist'. - - -!!! error TS2688: Cannot find type definition file for 'minimist'. -!!! error TS2688: Cannot find type definition file for 'process'. -==== /index.d.ts (1 errors) ==== - import minimist = require('minimist'); - ~~~~~~~~~~ -!!! error TS2307: Cannot find module 'minimist'. - export default function parseArgs(): minimist.ParsedArgs; - -==== /node_modules/@types/minimist/minimist.d.ts (0 errors) ==== - declare namespace thing { - interface ParsedArgs {} - } - declare function thing(x: any): thing.ParsedArgs; - export = thing; -==== /node_modules/@types/process/process.d.ts (0 errors) ==== - declare const thing: any; - export = thing; \ No newline at end of file diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping.baseline deleted file mode 100644 index 5fae8ec8c9914..0000000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping.baseline +++ /dev/null @@ -1,34 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -FileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../tests/cases/fourslash/index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping2.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping2.baseline deleted file mode 100644 index 151713a03bd45..0000000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping2.baseline +++ /dev/null @@ -1,35 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js.map -{"version":3,"file":"index.js","sourceRoot":"/tests/cases/fourslash/","sources":["index.ts"],"names":[],"mappings":";;AAAA;IAAA;IASA,CAAC;IAPG,wBAAU,GAAV,UAAW,QAAkB,IAAS,CAAC;IACvC,yBAAW,GAAX;QACI,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE;YACrB,OAAO,EAAC,CAAC,EAAE,EAAE,EAAC,CAAC;SAClB;QACD,OAAO,EAAC,CAAC,EAAE,KAAK,EAAC,CAAC;IACtB,CAAC;IACL,UAAC;AAAD,CAAC,AATD,IASC;AATY,kBAAG"}FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -//# sourceMappingURL=index.js.mapFileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"/tests/cases/fourslash/","sources":["index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping3.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping3.baseline deleted file mode 100644 index f05cbbd4c351b..0000000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping3.baseline +++ /dev/null @@ -1,34 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -FileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"/tests/cases/fourslash/","sources":["index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInline.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInline.baseline deleted file mode 100644 index ad51be6ddc0f5..0000000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInline.baseline +++ /dev/null @@ -1,34 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90ZXN0cy9jYXNlcy9mb3Vyc2xhc2gvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTtJQUFBO0lBU0EsQ0FBQztJQVBHLHdCQUFVLEdBQVYsVUFBVyxRQUFrQixJQUFTLENBQUM7SUFDdkMseUJBQVcsR0FBWDtRQUNJLElBQUksSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLEdBQUcsRUFBRTtZQUNyQixPQUFPLEVBQUMsQ0FBQyxFQUFFLEVBQUUsRUFBQyxDQUFDO1NBQ2xCO1FBQ0QsT0FBTyxFQUFDLENBQUMsRUFBRSxLQUFLLEVBQUMsQ0FBQztJQUN0QixDQUFDO0lBQ0wsVUFBQztBQUFELENBQUMsQUFURCxJQVNDO0FBVFksa0JBQUcifQ==FileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../tests/cases/fourslash/index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInlineSources.baseline b/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInlineSources.baseline deleted file mode 100644 index 8f6440b29dc78..0000000000000 --- a/tests/baselines/reference/declarationMapsGeneratedMapsEnableMapping_NoInlineSources.baseline +++ /dev/null @@ -1,34 +0,0 @@ -EmitSkipped: false -FileName : ./dist/index.js -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var Foo = /** @class */ (function () { - function Foo() { - } - Foo.prototype.methodName = function (propName) { }; - Foo.prototype.otherMethod = function () { - if (Math.random() > 0.5) { - return { x: 42 }; - } - return { y: "yes" }; - }; - return Foo; -}()); -exports.Foo = Foo; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90ZXN0cy9jYXNlcy9mb3Vyc2xhc2gvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTtJQUFBO0lBU0EsQ0FBQztJQVBHLHdCQUFVLEdBQVYsVUFBVyxRQUFrQixJQUFTLENBQUM7SUFDdkMseUJBQVcsR0FBWDtRQUNJLElBQUksSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLEdBQUcsRUFBRTtZQUNyQixPQUFPLEVBQUMsQ0FBQyxFQUFFLEVBQUUsRUFBQyxDQUFDO1NBQ2xCO1FBQ0QsT0FBTyxFQUFDLENBQUMsRUFBRSxLQUFLLEVBQUMsQ0FBQztJQUN0QixDQUFDO0lBQ0wsVUFBQztBQUFELENBQUMsQUFURCxJQVNDO0FBVFksa0JBQUciLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY2xhc3MgRm9vIHtcbiAgICBtZW1iZXI6IHN0cmluZztcbiAgICBtZXRob2ROYW1lKHByb3BOYW1lOiBTb21lVHlwZSk6IHZvaWQge31cbiAgICBvdGhlck1ldGhvZCgpIHtcbiAgICAgICAgaWYgKE1hdGgucmFuZG9tKCkgPiAwLjUpIHtcbiAgICAgICAgICAgIHJldHVybiB7eDogNDJ9O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7eTogXCJ5ZXNcIn07XG4gICAgfVxufVxuXG5leHBvcnQgaW50ZXJmYWNlIFNvbWVUeXBlIHtcbiAgICBtZW1iZXI6IG51bWJlcjtcbn0iXX0=FileName : ./dist/index.d.ts.map -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../tests/cases/fourslash/index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACpC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}FileName : ./dist/index.d.ts -export declare class Foo { - member: string; - methodName(propName: SomeType): void; - otherMethod(): { - x: number; - y?: undefined; - } | { - y: string; - x?: undefined; - }; -} -export interface SomeType { - member: number; -} -//# sourceMappingURL=index.d.ts.map diff --git a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt index b02b93e17b082..9902b1223a0a3 100644 --- a/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt +++ b/tests/baselines/reference/declaredClassMergedwithSelf.errors.txt @@ -32,8 +32,10 @@ tests/cases/conformance/classes/classDeclarations/file3.ts(1,15): error TS2300: declare class C3 { } ~~ !!! error TS2300: Duplicate identifier 'C3'. +!!! related TS6203 tests/cases/conformance/classes/classDeclarations/file3.ts:1:15: 'C3' was also declared here. ==== tests/cases/conformance/classes/classDeclarations/file3.ts (1 errors) ==== declare class C3 { } ~~ -!!! error TS2300: Duplicate identifier 'C3'. \ No newline at end of file +!!! error TS2300: Duplicate identifier 'C3'. +!!! related TS6203 tests/cases/conformance/classes/classDeclarations/file2.ts:1:15: 'C3' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/declaredExternalModule.types b/tests/baselines/reference/declaredExternalModule.types index 4ac6fcb8be58b..d899c9fc64d8b 100644 --- a/tests/baselines/reference/declaredExternalModule.types +++ b/tests/baselines/reference/declaredExternalModule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declaredExternalModule.ts === declare module 'connect' { ->'connect' : typeof 'connect' +>'connect' : typeof import("connect") interface connectModule { >connectModule : connectModule diff --git a/tests/baselines/reference/declaredExternalModuleWithExportAssignment.types b/tests/baselines/reference/declaredExternalModuleWithExportAssignment.types index b020c11ab624b..ddda19ade108f 100644 --- a/tests/baselines/reference/declaredExternalModuleWithExportAssignment.types +++ b/tests/baselines/reference/declaredExternalModuleWithExportAssignment.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declaredExternalModuleWithExportAssignment.ts === declare module 'connect' { ->'connect' : typeof 'connect' +>'connect' : typeof import("connect") interface connectModule { >connectModule : connectModule diff --git a/tests/baselines/reference/decoratorMetadataNoLibIsolatedModulesTypes.js b/tests/baselines/reference/decoratorMetadataNoLibIsolatedModulesTypes.js index d3c8f42066610..00d0a831c932b 100644 --- a/tests/baselines/reference/decoratorMetadataNoLibIsolatedModulesTypes.js +++ b/tests/baselines/reference/decoratorMetadataNoLibIsolatedModulesTypes.js @@ -23,7 +23,7 @@ var B = /** @class */ (function () { var _a; __decorate([ Decorate, - __metadata("design:type", typeof (_a = typeof Map !== "undefined" && Map) === "function" && _a || Object) + __metadata("design:type", typeof (_a = typeof Map !== "undefined" && Map) === "function" ? _a : Object) ], B.prototype, "member"); return B; }()); diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js index a20ff821148d5..7d2bf07862d9f 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -49,7 +49,7 @@ var MyClass = /** @class */ (function () { var _a; MyClass = __decorate([ someDecorator, - __metadata("design:paramtypes", [typeof (_a = (typeof db_1.default !== "undefined" && db_1.default).db) === "function" && _a || Object]) + __metadata("design:paramtypes", [typeof (_a = typeof db_1.default !== "undefined" && db_1.default.db) === "function" ? _a : Object]) ], MyClass); return MyClass; }()); diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js index 7acbff2beb7e7..b58f48d03416f 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -49,7 +49,7 @@ var MyClass = /** @class */ (function () { var _a; MyClass = __decorate([ someDecorator, - __metadata("design:paramtypes", [typeof (_a = (typeof db_1.default !== "undefined" && db_1.default).db) === "function" && _a || Object]) + __metadata("design:paramtypes", [typeof (_a = typeof db_1.default !== "undefined" && db_1.default.db) === "function" ? _a : Object]) ], MyClass); return MyClass; }()); diff --git a/tests/baselines/reference/deeplyNestedAssignabilityIssue.errors.txt b/tests/baselines/reference/deeplyNestedAssignabilityIssue.errors.txt new file mode 100644 index 0000000000000..cf243a1e5bd8a --- /dev/null +++ b/tests/baselines/reference/deeplyNestedAssignabilityIssue.errors.txt @@ -0,0 +1,61 @@ +tests/cases/compiler/deeplyNestedAssignabilityIssue.ts:22:17 - error TS2322: Type '{}' is not assignable to type 'A'. + Property 'a' is missing in type '{}'. + +22 thing: {} +   ~~~~~ + + tests/cases/compiler/deeplyNestedAssignabilityIssue.ts:9:17 + 9 thing: A; +    ~~~~~ + The expected type comes from property 'thing' which is declared here on type '{ thing: A; }' +tests/cases/compiler/deeplyNestedAssignabilityIssue.ts:25:17 - error TS2322: Type '{}' is not assignable to type 'A'. + Property 'a' is missing in type '{}'. + +25 another: {} +   ~~~~~~~ + + tests/cases/compiler/deeplyNestedAssignabilityIssue.ts:12:17 + 12 another: A; +    ~~~~~~~ + The expected type comes from property 'another' which is declared here on type '{ another: A; }' + + +==== tests/cases/compiler/deeplyNestedAssignabilityIssue.ts (2 errors) ==== + interface A { + a: number; + } + + interface Large { + something: { + another: { + more: { + thing: A; + } + yetstill: { + another: A; + } + } + } + } + + const x: Large = { + something: { + another: { + more: { + thing: {} + ~~~~~ +!!! error TS2322: Type '{}' is not assignable to type 'A'. +!!! error TS2322: Property 'a' is missing in type '{}'. +!!! related TS6500 tests/cases/compiler/deeplyNestedAssignabilityIssue.ts:9:17: The expected type comes from property 'thing' which is declared here on type '{ thing: A; }' + }, + yetstill: { + another: {} + ~~~~~~~ +!!! error TS2322: Type '{}' is not assignable to type 'A'. +!!! error TS2322: Property 'a' is missing in type '{}'. +!!! related TS6500 tests/cases/compiler/deeplyNestedAssignabilityIssue.ts:12:17: The expected type comes from property 'another' which is declared here on type '{ another: A; }' + } + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/deeplyNestedAssignabilityIssue.js b/tests/baselines/reference/deeplyNestedAssignabilityIssue.js new file mode 100644 index 0000000000000..8d7ed1ec2edd9 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedAssignabilityIssue.js @@ -0,0 +1,45 @@ +//// [deeplyNestedAssignabilityIssue.ts] +interface A { + a: number; +} + +interface Large { + something: { + another: { + more: { + thing: A; + } + yetstill: { + another: A; + } + } + } +} + +const x: Large = { + something: { + another: { + more: { + thing: {} + }, + yetstill: { + another: {} + } + } + } +} + + +//// [deeplyNestedAssignabilityIssue.js] +var x = { + something: { + another: { + more: { + thing: {} + }, + yetstill: { + another: {} + } + } + } +}; diff --git a/tests/baselines/reference/deeplyNestedAssignabilityIssue.symbols b/tests/baselines/reference/deeplyNestedAssignabilityIssue.symbols new file mode 100644 index 0000000000000..b77c310cfc870 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedAssignabilityIssue.symbols @@ -0,0 +1,62 @@ +=== tests/cases/compiler/deeplyNestedAssignabilityIssue.ts === +interface A { +>A : Symbol(A, Decl(deeplyNestedAssignabilityIssue.ts, 0, 0)) + + a: number; +>a : Symbol(A.a, Decl(deeplyNestedAssignabilityIssue.ts, 0, 13)) +} + +interface Large { +>Large : Symbol(Large, Decl(deeplyNestedAssignabilityIssue.ts, 2, 1)) + + something: { +>something : Symbol(Large.something, Decl(deeplyNestedAssignabilityIssue.ts, 4, 17)) + + another: { +>another : Symbol(another, Decl(deeplyNestedAssignabilityIssue.ts, 5, 16)) + + more: { +>more : Symbol(more, Decl(deeplyNestedAssignabilityIssue.ts, 6, 18)) + + thing: A; +>thing : Symbol(thing, Decl(deeplyNestedAssignabilityIssue.ts, 7, 19)) +>A : Symbol(A, Decl(deeplyNestedAssignabilityIssue.ts, 0, 0)) + } + yetstill: { +>yetstill : Symbol(yetstill, Decl(deeplyNestedAssignabilityIssue.ts, 9, 13)) + + another: A; +>another : Symbol(another, Decl(deeplyNestedAssignabilityIssue.ts, 10, 23)) +>A : Symbol(A, Decl(deeplyNestedAssignabilityIssue.ts, 0, 0)) + } + } + } +} + +const x: Large = { +>x : Symbol(x, Decl(deeplyNestedAssignabilityIssue.ts, 17, 5)) +>Large : Symbol(Large, Decl(deeplyNestedAssignabilityIssue.ts, 2, 1)) + + something: { +>something : Symbol(something, Decl(deeplyNestedAssignabilityIssue.ts, 17, 18)) + + another: { +>another : Symbol(another, Decl(deeplyNestedAssignabilityIssue.ts, 18, 16)) + + more: { +>more : Symbol(more, Decl(deeplyNestedAssignabilityIssue.ts, 19, 18)) + + thing: {} +>thing : Symbol(thing, Decl(deeplyNestedAssignabilityIssue.ts, 20, 19)) + + }, + yetstill: { +>yetstill : Symbol(yetstill, Decl(deeplyNestedAssignabilityIssue.ts, 22, 14)) + + another: {} +>another : Symbol(another, Decl(deeplyNestedAssignabilityIssue.ts, 23, 23)) + } + } + } +} + diff --git a/tests/baselines/reference/deeplyNestedAssignabilityIssue.types b/tests/baselines/reference/deeplyNestedAssignabilityIssue.types new file mode 100644 index 0000000000000..4c358bc47a454 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedAssignabilityIssue.types @@ -0,0 +1,69 @@ +=== tests/cases/compiler/deeplyNestedAssignabilityIssue.ts === +interface A { +>A : A + + a: number; +>a : number +} + +interface Large { +>Large : Large + + something: { +>something : { another: { more: { thing: A; }; yetstill: { another: A; }; }; } + + another: { +>another : { more: { thing: A; }; yetstill: { another: A; }; } + + more: { +>more : { thing: A; } + + thing: A; +>thing : A +>A : A + } + yetstill: { +>yetstill : { another: A; } + + another: A; +>another : A +>A : A + } + } + } +} + +const x: Large = { +>x : Large +>Large : Large +>{ something: { another: { more: { thing: {} }, yetstill: { another: {} } } }} : { something: { another: { more: { thing: {}; }; yetstill: { another: {}; }; }; }; } + + something: { +>something : { another: { more: { thing: {}; }; yetstill: { another: {}; }; }; } +>{ another: { more: { thing: {} }, yetstill: { another: {} } } } : { another: { more: { thing: {}; }; yetstill: { another: {}; }; }; } + + another: { +>another : { more: { thing: {}; }; yetstill: { another: {}; }; } +>{ more: { thing: {} }, yetstill: { another: {} } } : { more: { thing: {}; }; yetstill: { another: {}; }; } + + more: { +>more : { thing: {}; } +>{ thing: {} } : { thing: {}; } + + thing: {} +>thing : {} +>{} : {} + + }, + yetstill: { +>yetstill : { another: {}; } +>{ another: {} } : { another: {}; } + + another: {} +>another : {} +>{} : {} + } + } + } +} + diff --git a/tests/baselines/reference/derivedClasses.errors.txt b/tests/baselines/reference/derivedClasses.errors.txt index ff6946df2ca72..f7bee106d7324 100644 --- a/tests/baselines/reference/derivedClasses.errors.txt +++ b/tests/baselines/reference/derivedClasses.errors.txt @@ -5,6 +5,7 @@ tests/cases/compiler/derivedClasses.ts(1,19): error TS2449: Class 'Color' used b class Red extends Color { ~~~~~ !!! error TS2449: Class 'Color' used before its declaration. +!!! related TS2728 tests/cases/compiler/derivedClasses.ts:8:7: 'Color' is declared here. public shade() { var getHue = () => { return this.hue(); }; return getHue() + " red"; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index 848093e11616a..78f5720894bb2 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -3,8 +3,7 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. - Type 'number' is not assignable to type 'boolean'. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,51): error TS2322: Type 'number' is not assignable to type 'boolean'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'. Property '0' is missing in type 'number[]'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'. @@ -32,9 +31,8 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss // 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]: [number, boolean, string] = [1, 2, "string"]; // Error - ~~~~~~~~~~~~ -!!! error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. interface J extends Array { 2: number; } diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt index a68affcf73de8..eff1e1a65938b 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt @@ -9,9 +9,11 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss const [c, d = c, e = e] = [1]; // error for e = e ~ !!! error TS2448: Block-scoped variable 'e' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts:2:18: 'e' is declared here. const [f, g = f, h = i, i = f] = [1]; // error for h = i ~ !!! error TS2448: Block-scoped variable 'i' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts:3:25: 'i' is declared here. (function ([a, b = a]) { // ok })([1]); diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.errors.txt index 6a3f0f2b4572b..54930648be93a 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.errors.txt +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment4.errors.txt @@ -11,8 +11,10 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs e = f, // error ~ !!! error TS2448: Block-scoped variable 'f' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts:7:5: 'f' is declared here. f = f // error ~ !!! error TS2448: Block-scoped variable 'f' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts:7:5: 'f' is declared here. } = { } as any; \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 6cd6c92ca62d6..d5a0d34e1a1b4 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -48,6 +48,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? +!!! related TS2728 /.ts/lib.es5.d.ts:1298:15: 'Array' is declared here. a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. diff --git a/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt new file mode 100644 index 0000000000000..0b333efe901fa --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration8.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(4,5): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(5,15): error TS2322: Type '"c"' is not assignable to type '"a" | "b"'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(17,6): error TS2345: Argument of type '{ method: "z"; nested: { p: "b"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. + Types of property 'method' are incompatible. + Type '"z"' is not assignable to type '"x" | "y"'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts(18,6): error TS2345: Argument of type '{ method: "one"; nested: { p: "a"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. + Types of property 'method' are incompatible. + Type '"one"' is not assignable to type '"x" | "y"'. + + +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts (4 errors) ==== + // explicit type annotation should cause `method` to have type 'x' | 'y' + // both inside and outside `test`. + function test({ + method = 'z', + ~~~~~~ +!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. + nested: { p = 'c' } + ~ +!!! error TS2322: Type '"c"' is not assignable to type '"a" | "b"'. + }: { + method?: 'x' | 'y', + nested?: { p: 'a' | 'b' } + }) + { + method + p + } + + test({}); + test({ method: 'x', nested: { p: 'a' } }) + test({ method: 'z', nested: { p: 'b' } }) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ method: "z"; nested: { p: "b"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. +!!! error TS2345: Types of property 'method' are incompatible. +!!! error TS2345: Type '"z"' is not assignable to type '"x" | "y"'. + test({ method: 'one', nested: { p: 'a' } }) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '{ method: "one"; nested: { p: "a"; }; }' is not assignable to parameter of type '{ method?: "x" | "y"; nested?: { p: "a" | "b"; }; }'. +!!! error TS2345: Types of property 'method' are incompatible. +!!! error TS2345: Type '"one"' is not assignable to type '"x" | "y"'. + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringParameterDeclaration8.js b/tests/baselines/reference/destructuringParameterDeclaration8.js new file mode 100644 index 0000000000000..4856306ecaec0 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration8.js @@ -0,0 +1,33 @@ +//// [destructuringParameterDeclaration8.ts] +// explicit type annotation should cause `method` to have type 'x' | 'y' +// both inside and outside `test`. +function test({ + method = 'z', + nested: { p = 'c' } +}: { + method?: 'x' | 'y', + nested?: { p: 'a' | 'b' } +}) +{ + method + p +} + +test({}); +test({ method: 'x', nested: { p: 'a' } }) +test({ method: 'z', nested: { p: 'b' } }) +test({ method: 'one', nested: { p: 'a' } }) + + +//// [destructuringParameterDeclaration8.js] +// explicit type annotation should cause `method` to have type 'x' | 'y' +// both inside and outside `test`. +function test(_a) { + var _b = _a.method, method = _b === void 0 ? 'z' : _b, _c = _a.nested.p, p = _c === void 0 ? 'c' : _c; + method; + p; +} +test({}); +test({ method: 'x', nested: { p: 'a' } }); +test({ method: 'z', nested: { p: 'b' } }); +test({ method: 'one', nested: { p: 'a' } }); diff --git a/tests/baselines/reference/destructuringParameterDeclaration8.symbols b/tests/baselines/reference/destructuringParameterDeclaration8.symbols new file mode 100644 index 0000000000000..f65e200fdac98 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration8.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts === +// explicit type annotation should cause `method` to have type 'x' | 'y' +// both inside and outside `test`. +function test({ +>test : Symbol(test, Decl(destructuringParameterDeclaration8.ts, 0, 0)) + + method = 'z', +>method : Symbol(method, Decl(destructuringParameterDeclaration8.ts, 2, 15)) + + nested: { p = 'c' } +>nested : Symbol(nested, Decl(destructuringParameterDeclaration8.ts, 6, 23)) +>p : Symbol(p, Decl(destructuringParameterDeclaration8.ts, 4, 13)) + +}: { + method?: 'x' | 'y', +>method : Symbol(method, Decl(destructuringParameterDeclaration8.ts, 5, 4)) + + nested?: { p: 'a' | 'b' } +>nested : Symbol(nested, Decl(destructuringParameterDeclaration8.ts, 6, 23)) +>p : Symbol(p, Decl(destructuringParameterDeclaration8.ts, 7, 14)) + +}) +{ + method +>method : Symbol(method, Decl(destructuringParameterDeclaration8.ts, 2, 15)) + + p +>p : Symbol(p, Decl(destructuringParameterDeclaration8.ts, 4, 13)) +} + +test({}); +>test : Symbol(test, Decl(destructuringParameterDeclaration8.ts, 0, 0)) + +test({ method: 'x', nested: { p: 'a' } }) +>test : Symbol(test, Decl(destructuringParameterDeclaration8.ts, 0, 0)) +>method : Symbol(method, Decl(destructuringParameterDeclaration8.ts, 15, 6)) +>nested : Symbol(nested, Decl(destructuringParameterDeclaration8.ts, 15, 19)) +>p : Symbol(p, Decl(destructuringParameterDeclaration8.ts, 15, 29)) + +test({ method: 'z', nested: { p: 'b' } }) +>test : Symbol(test, Decl(destructuringParameterDeclaration8.ts, 0, 0)) +>method : Symbol(method, Decl(destructuringParameterDeclaration8.ts, 16, 6)) +>nested : Symbol(nested, Decl(destructuringParameterDeclaration8.ts, 16, 19)) +>p : Symbol(p, Decl(destructuringParameterDeclaration8.ts, 16, 29)) + +test({ method: 'one', nested: { p: 'a' } }) +>test : Symbol(test, Decl(destructuringParameterDeclaration8.ts, 0, 0)) +>method : Symbol(method, Decl(destructuringParameterDeclaration8.ts, 17, 6)) +>nested : Symbol(nested, Decl(destructuringParameterDeclaration8.ts, 17, 21)) +>p : Symbol(p, Decl(destructuringParameterDeclaration8.ts, 17, 31)) + diff --git a/tests/baselines/reference/destructuringParameterDeclaration8.types b/tests/baselines/reference/destructuringParameterDeclaration8.types new file mode 100644 index 0000000000000..6ca691fcff158 --- /dev/null +++ b/tests/baselines/reference/destructuringParameterDeclaration8.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration8.ts === +// explicit type annotation should cause `method` to have type 'x' | 'y' +// both inside and outside `test`. +function test({ +>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void + + method = 'z', +>method : "x" | "y" +>'z' : "z" + + nested: { p = 'c' } +>nested : any +>p : "a" | "b" +>'c' : "c" + +}: { + method?: 'x' | 'y', +>method : "x" | "y" + + nested?: { p: 'a' | 'b' } +>nested : { p: "a" | "b"; } +>p : "a" | "b" + +}) +{ + method +>method : "x" | "y" + + p +>p : "a" | "b" +} + +test({}); +>test({}) : void +>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void +>{} : {} + +test({ method: 'x', nested: { p: 'a' } }) +>test({ method: 'x', nested: { p: 'a' } }) : void +>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void +>{ method: 'x', nested: { p: 'a' } } : { method: "x"; nested: { p: "a"; }; } +>method : "x" +>'x' : "x" +>nested : { p: "a"; } +>{ p: 'a' } : { p: "a"; } +>p : "a" +>'a' : "a" + +test({ method: 'z', nested: { p: 'b' } }) +>test({ method: 'z', nested: { p: 'b' } }) : void +>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void +>{ method: 'z', nested: { p: 'b' } } : { method: string; nested: { p: string; }; } +>method : string +>'z' : "z" +>nested : { p: string; } +>{ p: 'b' } : { p: string; } +>p : string +>'b' : "b" + +test({ method: 'one', nested: { p: 'a' } }) +>test({ method: 'one', nested: { p: 'a' } }) : void +>test : ({ method, nested: { p } }: { method?: "x" | "y"; nested?: { p: "a" | "b"; }; }) => void +>{ method: 'one', nested: { p: 'a' } } : { method: string; nested: { p: string; }; } +>method : string +>'one' : "one" +>nested : { p: string; } +>{ p: 'a' } : { p: string; } +>p : string +>'a' : "a" + diff --git a/tests/baselines/reference/destructuringTempOccursAfterPrologue.js b/tests/baselines/reference/destructuringTempOccursAfterPrologue.js index a739070856097..62786ec422504 100644 --- a/tests/baselines/reference/destructuringTempOccursAfterPrologue.js +++ b/tests/baselines/reference/destructuringTempOccursAfterPrologue.js @@ -1,12 +1,14 @@ //// [destructuringTempOccursAfterPrologue.ts] function test(p: any) { 'use strict'; + 'use strong'; p = { prop: p } = p; } //// [destructuringTempOccursAfterPrologue.js] function test(p) { 'use strict'; + 'use strong'; var _a; p = (_a = p, p = _a.prop, _a); } diff --git a/tests/baselines/reference/destructuringTempOccursAfterPrologue.symbols b/tests/baselines/reference/destructuringTempOccursAfterPrologue.symbols index 0e68259e6cf5c..0328f00601c3f 100644 --- a/tests/baselines/reference/destructuringTempOccursAfterPrologue.symbols +++ b/tests/baselines/reference/destructuringTempOccursAfterPrologue.symbols @@ -4,9 +4,10 @@ function test(p: any) { >p : Symbol(p, Decl(destructuringTempOccursAfterPrologue.ts, 0, 14)) 'use strict'; + 'use strong'; p = { prop: p } = p; >p : Symbol(p, Decl(destructuringTempOccursAfterPrologue.ts, 0, 14)) ->prop : Symbol(prop, Decl(destructuringTempOccursAfterPrologue.ts, 2, 9)) +>prop : Symbol(prop, Decl(destructuringTempOccursAfterPrologue.ts, 3, 9)) >p : Symbol(p, Decl(destructuringTempOccursAfterPrologue.ts, 0, 14)) >p : Symbol(p, Decl(destructuringTempOccursAfterPrologue.ts, 0, 14)) } diff --git a/tests/baselines/reference/destructuringTempOccursAfterPrologue.types b/tests/baselines/reference/destructuringTempOccursAfterPrologue.types index 8a62e25b6856c..426345838f11c 100644 --- a/tests/baselines/reference/destructuringTempOccursAfterPrologue.types +++ b/tests/baselines/reference/destructuringTempOccursAfterPrologue.types @@ -6,6 +6,9 @@ function test(p: any) { 'use strict'; >'use strict' : "use strict" + 'use strong'; +>'use strong' : "use strong" + p = { prop: p } = p; >p = { prop: p } = p : any >p : any diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt index fe8255ca55652..104c95bc427c7 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt @@ -1,26 +1,23 @@ -tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3,5): error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'. - Types of property 'a1' are incompatible. - Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,5): error TS2322: Type '[number, [[boolean]], true]' is not assignable to type '[number, [[string]], boolean]'. - Type '[[boolean]]' is not assignable to type '[[string]]'. - Type '[boolean]' is not assignable to type '[string]'. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3,46): error TS2322: Type 'true' is not assignable to type 'number'. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3,56): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,61): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(19,10): error TS2322: Type 'string[]' is not assignable to type 'number[]'. + Type 'string' is not assignable to type 'number'. -==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (4 errors) ==== // 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: true, a2: 1 } // Error - ~~~~~~~~ -!!! error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'. -!!! error TS2322: Types of property 'a1' are incompatible. -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. + ~~ +!!! error TS2322: Type 'true' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts:3:17: The expected type comes from property 'a1' which is declared here on type '{ a1: number; a2: string; }' + ~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts:3:29: The expected type comes from property 'a2' which is declared here on type '{ a1: number; a2: string; }' var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error - ~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '[number, [[boolean]], true]' is not assignable to type '[number, [[string]], boolean]'. -!!! error TS2322: Type '[[boolean]]' is not assignable to type '[[string]]'. -!!! error TS2322: Type '[boolean]' is not assignable to type '[string]'. -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. + ~~~~~ +!!! error TS2322: Type 'false' is not assignable to type 'string'. // 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. @@ -35,4 +32,7 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4 // 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 {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error \ No newline at end of file + var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error + ~~ +!!! error TS2322: Type 'string[]' is not assignable to type 'number[]'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.types b/tests/baselines/reference/destructuringVariableDeclaration2.types index 8af7ddb7628a4..43b83a4d74f86 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.types +++ b/tests/baselines/reference/destructuringVariableDeclaration2.types @@ -74,7 +74,7 @@ var [c1, c2, { c3: c4, c5 }, , ...c6] = [1, 2, { c3: 4, c5: 0 }]; // Error // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error >d : any ->d1 : string[] | number[] +>d1 : number[] >["string", null] : string[] >"string" : "string" >null : null diff --git a/tests/baselines/reference/discriminatedUnionTypes1.errors.txt b/tests/baselines/reference/discriminatedUnionTypes1.errors.txt index ac2bd4d3b1973..be5bd96740300 100644 --- a/tests/baselines/reference/discriminatedUnionTypes1.errors.txt +++ b/tests/baselines/reference/discriminatedUnionTypes1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/union/discriminatedUnionTypes1.ts(89,9): error TS2365: Operator '===' cannot be applied to types '"A" | "B" | "C" | "D"' and '"X"'. +tests/cases/conformance/types/union/discriminatedUnionTypes1.ts(89,9): error TS2367: This condition will always return 'false' since the types '"A" | "B" | "C" | "D"' and '"X"' have no overlap. ==== tests/cases/conformance/types/union/discriminatedUnionTypes1.ts (1 errors) ==== @@ -92,7 +92,7 @@ tests/cases/conformance/types/union/discriminatedUnionTypes1.ts(89,9): error TS2 function f3(m: Message) { if (m.kind === "X") { ~~~~~~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types '"A" | "B" | "C" | "D"' and '"X"'. +!!! error TS2367: This condition will always return 'false' since the types '"A" | "B" | "C" | "D"' and '"X"' have no overlap. m; // never } } diff --git a/tests/baselines/reference/duplicateDefaultExport.errors.txt b/tests/baselines/reference/duplicateDefaultExport.errors.txt new file mode 100644 index 0000000000000..e35e416ff6b97 --- /dev/null +++ b/tests/baselines/reference/duplicateDefaultExport.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/duplicateDefaultExport.ts(1,1): error TS2528: A module cannot have multiple default exports. +tests/cases/compiler/duplicateDefaultExport.ts(2,1): error TS2528: A module cannot have multiple default exports. + + +==== tests/cases/compiler/duplicateDefaultExport.ts (2 errors) ==== + export default 0; + ~~~~~~~~~~~~~~~~~ +!!! error TS2528: A module cannot have multiple default exports. + export default function() {} + ~~~~~~ +!!! error TS2528: A module cannot have multiple default exports. + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateDefaultExport.js b/tests/baselines/reference/duplicateDefaultExport.js new file mode 100644 index 0000000000000..af0994bb8332d --- /dev/null +++ b/tests/baselines/reference/duplicateDefaultExport.js @@ -0,0 +1,11 @@ +//// [duplicateDefaultExport.ts] +export default 0; +export default function() {} + + +//// [duplicateDefaultExport.js] +"use strict"; +exports.__esModule = true; +exports["default"] = 0; +function default_1() { } +exports["default"] = default_1; diff --git a/tests/baselines/reference/duplicateDefaultExport.symbols b/tests/baselines/reference/duplicateDefaultExport.symbols new file mode 100644 index 0000000000000..6f978e28e78d4 --- /dev/null +++ b/tests/baselines/reference/duplicateDefaultExport.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/duplicateDefaultExport.ts === +export default 0; +No type information for this code.export default function() {} +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/duplicateDefaultExport.types b/tests/baselines/reference/duplicateDefaultExport.types new file mode 100644 index 0000000000000..6f978e28e78d4 --- /dev/null +++ b/tests/baselines/reference/duplicateDefaultExport.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/duplicateDefaultExport.ts === +export default 0; +No type information for this code.export default function() {} +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierEnum.errors.txt b/tests/baselines/reference/duplicateIdentifierEnum.errors.txt index 69266cc5ba457..d5102255bb4f7 100644 --- a/tests/baselines/reference/duplicateIdentifierEnum.errors.txt +++ b/tests/baselines/reference/duplicateIdentifierEnum.errors.txt @@ -48,11 +48,13 @@ tests/cases/compiler/duplicateIdentifierEnum_B.ts(4,6): error TS2567: Enum decla enum D { ~ !!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! related TS6203 tests/cases/compiler/duplicateIdentifierEnum_B.ts:1:10: 'D' was also declared here. bar } class E { ~ !!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! related TS6203 tests/cases/compiler/duplicateIdentifierEnum_B.ts:4:6: 'E' was also declared here. foo: number; } // also make sure the error appears when trying to merge an enum in a separate file. @@ -60,10 +62,12 @@ tests/cases/compiler/duplicateIdentifierEnum_B.ts(4,6): error TS2567: Enum decla function D() { ~ !!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! related TS6203 tests/cases/compiler/duplicateIdentifierEnum_A.ts:23:6: 'D' was also declared here. return 0; } enum E { ~ !!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. +!!! related TS6203 tests/cases/compiler/duplicateIdentifierEnum_A.ts:26:7: 'E' was also declared here. bar } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans1.errors.txt b/tests/baselines/reference/duplicateIdentifierRelatedSpans1.errors.txt new file mode 100644 index 0000000000000..62b4774f4f72b --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans1.errors.txt @@ -0,0 +1,94 @@ +tests/cases/compiler/file1.ts:1:7 - error TS2300: Duplicate identifier 'Foo'. + +1 class Foo { } +   ~~~ + + tests/cases/compiler/file2.ts:1:6 + 1 type Foo = number; +    ~~~ + 'Foo' was also declared here. + tests/cases/compiler/file3.ts:1:6 + 1 type Foo = 54; +    ~~~ + and here. +tests/cases/compiler/file1.ts:2:7 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. + +2 const Bar = 3; +   ~~~ + + tests/cases/compiler/file2.ts:2:7 + 2 class Bar {} +    ~~~ + 'Bar' was also declared here. + tests/cases/compiler/file3.ts:2:5 + 2 let Bar = 42 +    ~~~ + and here. +tests/cases/compiler/file2.ts:1:6 - error TS2300: Duplicate identifier 'Foo'. + +1 type Foo = number; +   ~~~ + + tests/cases/compiler/file1.ts:1:7 + 1 class Foo { } +    ~~~ + 'Foo' was also declared here. +tests/cases/compiler/file2.ts:2:7 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. + +2 class Bar {} +   ~~~ + + tests/cases/compiler/file1.ts:2:7 + 2 const Bar = 3; +    ~~~ + 'Bar' was also declared here. +tests/cases/compiler/file3.ts:1:6 - error TS2300: Duplicate identifier 'Foo'. + +1 type Foo = 54; +   ~~~ + + tests/cases/compiler/file1.ts:1:7 + 1 class Foo { } +    ~~~ + 'Foo' was also declared here. +tests/cases/compiler/file3.ts:2:5 - error TS2451: Cannot redeclare block-scoped variable 'Bar'. + +2 let Bar = 42 +   ~~~ + + tests/cases/compiler/file1.ts:2:7 + 2 const Bar = 3; +    ~~~ + 'Bar' was also declared here. + + +==== tests/cases/compiler/file1.ts (2 errors) ==== + class Foo { } + ~~~ +!!! error TS2300: Duplicate identifier 'Foo'. +!!! related TS6203 tests/cases/compiler/file2.ts:1:6: 'Foo' was also declared here. +!!! related TS6204 tests/cases/compiler/file3.ts:1:6: and here. + const Bar = 3; + ~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. +!!! related TS6203 tests/cases/compiler/file2.ts:2:7: 'Bar' was also declared here. +!!! related TS6204 tests/cases/compiler/file3.ts:2:5: and here. +==== tests/cases/compiler/file2.ts (2 errors) ==== + type Foo = number; + ~~~ +!!! error TS2300: Duplicate identifier 'Foo'. +!!! related TS6203 tests/cases/compiler/file1.ts:1:7: 'Foo' was also declared here. + class Bar {} + ~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. +!!! related TS6203 tests/cases/compiler/file1.ts:2:7: 'Bar' was also declared here. +==== tests/cases/compiler/file3.ts (2 errors) ==== + type Foo = 54; + ~~~ +!!! error TS2300: Duplicate identifier 'Foo'. +!!! related TS6203 tests/cases/compiler/file1.ts:1:7: 'Foo' was also declared here. + let Bar = 42 + ~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'Bar'. +!!! related TS6203 tests/cases/compiler/file1.ts:2:7: 'Bar' was also declared here. + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans1.js b/tests/baselines/reference/duplicateIdentifierRelatedSpans1.js new file mode 100644 index 0000000000000..899c87fffd5bb --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans1.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/duplicateIdentifierRelatedSpans1.ts] //// + +//// [file1.ts] +class Foo { } +const Bar = 3; +//// [file2.ts] +type Foo = number; +class Bar {} +//// [file3.ts] +type Foo = 54; +let Bar = 42 + + +//// [file1.js] +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +var Bar = 3; +//// [file2.js] +var Bar = /** @class */ (function () { + function Bar() { + } + return Bar; +}()); +//// [file3.js] +var Bar = 42; diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans1.symbols b/tests/baselines/reference/duplicateIdentifierRelatedSpans1.symbols new file mode 100644 index 0000000000000..8131264ca21b7 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans1.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/file1.ts === +class Foo { } +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) + +const Bar = 3; +>Bar : Symbol(Bar, Decl(file1.ts, 1, 5)) + +=== tests/cases/compiler/file2.ts === +type Foo = number; +>Foo : Symbol(Foo, Decl(file2.ts, 0, 0)) + +class Bar {} +>Bar : Symbol(Bar, Decl(file2.ts, 0, 18)) + +=== tests/cases/compiler/file3.ts === +type Foo = 54; +>Foo : Symbol(Foo, Decl(file3.ts, 0, 0)) + +let Bar = 42 +>Bar : Symbol(Bar, Decl(file3.ts, 1, 3)) + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans1.types b/tests/baselines/reference/duplicateIdentifierRelatedSpans1.types new file mode 100644 index 0000000000000..fff94f44081aa --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans1.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/file1.ts === +class Foo { } +>Foo : Foo + +const Bar = 3; +>Bar : 3 +>3 : 3 + +=== tests/cases/compiler/file2.ts === +type Foo = number; +>Foo : number + +class Bar {} +>Bar : Bar + +=== tests/cases/compiler/file3.ts === +type Foo = 54; +>Foo : 54 + +let Bar = 42 +>Bar : number +>42 : 42 + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans2.errors.txt b/tests/baselines/reference/duplicateIdentifierRelatedSpans2.errors.txt new file mode 100644 index 0000000000000..2925b636d2d22 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans2.errors.txt @@ -0,0 +1,47 @@ +tests/cases/compiler/file1.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: A, B, C, D, E, F, G, H, I + +1 class A { } +  ~~~~~ + + tests/cases/compiler/file2.ts:1:1 + 1 class A { } +   ~~~~~ + Conflicts are in this file. +tests/cases/compiler/file2.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: A, B, C, D, E, F, G, H, I + +1 class A { } +  ~~~~~ + + tests/cases/compiler/file1.ts:1:1 + 1 class A { } +   ~~~~~ + Conflicts are in this file. + + +==== tests/cases/compiler/file1.ts (1 errors) ==== + class A { } + ~~~~~ +!!! error TS6200: Definitions of the following identifiers conflict with those in another file: A, B, C, D, E, F, G, H, I +!!! related TS6201 tests/cases/compiler/file2.ts:1:1: Conflicts are in this file. + class B { } + class C { } + class D { } + class E { } + class F { } + class G { } + class H { } + class I { } +==== tests/cases/compiler/file2.ts (1 errors) ==== + class A { } + ~~~~~ +!!! error TS6200: Definitions of the following identifiers conflict with those in another file: A, B, C, D, E, F, G, H, I +!!! related TS6201 tests/cases/compiler/file1.ts:1:1: Conflicts are in this file. + class B { } + class C { } + class D { } + class E { } + class F { } + class G { } + class H { } + class I { } + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans2.js b/tests/baselines/reference/duplicateIdentifierRelatedSpans2.js new file mode 100644 index 0000000000000..318bd4d135e2e --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans2.js @@ -0,0 +1,116 @@ +//// [tests/cases/compiler/duplicateIdentifierRelatedSpans2.ts] //// + +//// [file1.ts] +class A { } +class B { } +class C { } +class D { } +class E { } +class F { } +class G { } +class H { } +class I { } +//// [file2.ts] +class A { } +class B { } +class C { } +class D { } +class E { } +class F { } +class G { } +class H { } +class I { } + + +//// [file1.js] +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +var B = /** @class */ (function () { + function B() { + } + return B; +}()); +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +var D = /** @class */ (function () { + function D() { + } + return D; +}()); +var E = /** @class */ (function () { + function E() { + } + return E; +}()); +var F = /** @class */ (function () { + function F() { + } + return F; +}()); +var G = /** @class */ (function () { + function G() { + } + return G; +}()); +var H = /** @class */ (function () { + function H() { + } + return H; +}()); +var I = /** @class */ (function () { + function I() { + } + return I; +}()); +//// [file2.js] +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +var B = /** @class */ (function () { + function B() { + } + return B; +}()); +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +var D = /** @class */ (function () { + function D() { + } + return D; +}()); +var E = /** @class */ (function () { + function E() { + } + return E; +}()); +var F = /** @class */ (function () { + function F() { + } + return F; +}()); +var G = /** @class */ (function () { + function G() { + } + return G; +}()); +var H = /** @class */ (function () { + function H() { + } + return H; +}()); +var I = /** @class */ (function () { + function I() { + } + return I; +}()); diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans2.symbols b/tests/baselines/reference/duplicateIdentifierRelatedSpans2.symbols new file mode 100644 index 0000000000000..aabbe5898c5eb --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans2.symbols @@ -0,0 +1,56 @@ +=== tests/cases/compiler/file1.ts === +class A { } +>A : Symbol(A, Decl(file1.ts, 0, 0)) + +class B { } +>B : Symbol(B, Decl(file1.ts, 0, 11)) + +class C { } +>C : Symbol(C, Decl(file1.ts, 1, 11)) + +class D { } +>D : Symbol(D, Decl(file1.ts, 2, 11)) + +class E { } +>E : Symbol(E, Decl(file1.ts, 3, 11)) + +class F { } +>F : Symbol(F, Decl(file1.ts, 4, 11)) + +class G { } +>G : Symbol(G, Decl(file1.ts, 5, 11)) + +class H { } +>H : Symbol(H, Decl(file1.ts, 6, 11)) + +class I { } +>I : Symbol(I, Decl(file1.ts, 7, 11)) + +=== tests/cases/compiler/file2.ts === +class A { } +>A : Symbol(A, Decl(file2.ts, 0, 0)) + +class B { } +>B : Symbol(B, Decl(file2.ts, 0, 11)) + +class C { } +>C : Symbol(C, Decl(file2.ts, 1, 11)) + +class D { } +>D : Symbol(D, Decl(file2.ts, 2, 11)) + +class E { } +>E : Symbol(E, Decl(file2.ts, 3, 11)) + +class F { } +>F : Symbol(F, Decl(file2.ts, 4, 11)) + +class G { } +>G : Symbol(G, Decl(file2.ts, 5, 11)) + +class H { } +>H : Symbol(H, Decl(file2.ts, 6, 11)) + +class I { } +>I : Symbol(I, Decl(file2.ts, 7, 11)) + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans2.types b/tests/baselines/reference/duplicateIdentifierRelatedSpans2.types new file mode 100644 index 0000000000000..caea2d91f4fba --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans2.types @@ -0,0 +1,56 @@ +=== tests/cases/compiler/file1.ts === +class A { } +>A : A + +class B { } +>B : B + +class C { } +>C : C + +class D { } +>D : D + +class E { } +>E : E + +class F { } +>F : F + +class G { } +>G : G + +class H { } +>H : H + +class I { } +>I : I + +=== tests/cases/compiler/file2.ts === +class A { } +>A : A + +class B { } +>B : B + +class C { } +>C : C + +class D { } +>D : D + +class E { } +>E : E + +class F { } +>F : F + +class G { } +>G : G + +class H { } +>H : H + +class I { } +>I : I + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans3.errors.txt b/tests/baselines/reference/duplicateIdentifierRelatedSpans3.errors.txt new file mode 100644 index 0000000000000..a97ce217928d7 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans3.errors.txt @@ -0,0 +1,87 @@ +tests/cases/compiler/file1.ts:2:5 - error TS2300: Duplicate identifier 'duplicate1'. + +2 duplicate1: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:2:5 + 2 duplicate1(): number; +    ~~~~~~~~~~ + 'duplicate1' was also declared here. +tests/cases/compiler/file1.ts:3:5 - error TS2300: Duplicate identifier 'duplicate2'. + +3 duplicate2: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:3:5 + 3 duplicate2(): number; +    ~~~~~~~~~~ + 'duplicate2' was also declared here. +tests/cases/compiler/file1.ts:4:5 - error TS2300: Duplicate identifier 'duplicate3'. + +4 duplicate3: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:4:5 + 4 duplicate3(): number; +    ~~~~~~~~~~ + 'duplicate3' was also declared here. +tests/cases/compiler/file2.ts:2:5 - error TS2300: Duplicate identifier 'duplicate1'. + +2 duplicate1(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:2:5 + 2 duplicate1: () => string; +    ~~~~~~~~~~ + 'duplicate1' was also declared here. +tests/cases/compiler/file2.ts:3:5 - error TS2300: Duplicate identifier 'duplicate2'. + +3 duplicate2(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:3:5 + 3 duplicate2: () => string; +    ~~~~~~~~~~ + 'duplicate2' was also declared here. +tests/cases/compiler/file2.ts:4:5 - error TS2300: Duplicate identifier 'duplicate3'. + +4 duplicate3(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:4:5 + 4 duplicate3: () => string; +    ~~~~~~~~~~ + 'duplicate3' was also declared here. + + +==== tests/cases/compiler/file1.ts (3 errors) ==== + interface TopLevel { + duplicate1: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate1'. +!!! related TS6203 tests/cases/compiler/file2.ts:2:5: 'duplicate1' was also declared here. + duplicate2: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate2'. +!!! related TS6203 tests/cases/compiler/file2.ts:3:5: 'duplicate2' was also declared here. + duplicate3: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate3'. +!!! related TS6203 tests/cases/compiler/file2.ts:4:5: 'duplicate3' was also declared here. + } +==== tests/cases/compiler/file2.ts (3 errors) ==== + interface TopLevel { + duplicate1(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate1'. +!!! related TS6203 tests/cases/compiler/file1.ts:2:5: 'duplicate1' was also declared here. + duplicate2(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate2'. +!!! related TS6203 tests/cases/compiler/file1.ts:3:5: 'duplicate2' was also declared here. + duplicate3(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate3'. +!!! related TS6203 tests/cases/compiler/file1.ts:4:5: 'duplicate3' was also declared here. + } + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans3.js b/tests/baselines/reference/duplicateIdentifierRelatedSpans3.js new file mode 100644 index 0000000000000..978b5013570c3 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans3.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/duplicateIdentifierRelatedSpans3.ts] //// + +//// [file1.ts] +interface TopLevel { + duplicate1: () => string; + duplicate2: () => string; + duplicate3: () => string; +} +//// [file2.ts] +interface TopLevel { + duplicate1(): number; + duplicate2(): number; + duplicate3(): number; +} + + +//// [file1.js] +//// [file2.js] diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans3.symbols b/tests/baselines/reference/duplicateIdentifierRelatedSpans3.symbols new file mode 100644 index 0000000000000..b24820d317ab7 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans3.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/file1.ts === +interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 0), Decl(file2.ts, 0, 0)) + + duplicate1: () => string; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file1.ts, 0, 20)) + + duplicate2: () => string; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file1.ts, 1, 29)) + + duplicate3: () => string; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file1.ts, 2, 29)) +} +=== tests/cases/compiler/file2.ts === +interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 0), Decl(file2.ts, 0, 0)) + + duplicate1(): number; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file2.ts, 0, 20)) + + duplicate2(): number; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file2.ts, 1, 25)) + + duplicate3(): number; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file2.ts, 2, 25)) +} + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans3.types b/tests/baselines/reference/duplicateIdentifierRelatedSpans3.types new file mode 100644 index 0000000000000..84de4d9d8bfae --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans3.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/file1.ts === +interface TopLevel { +>TopLevel : TopLevel + + duplicate1: () => string; +>duplicate1 : () => string + + duplicate2: () => string; +>duplicate2 : () => string + + duplicate3: () => string; +>duplicate3 : () => string +} +=== tests/cases/compiler/file2.ts === +interface TopLevel { +>TopLevel : TopLevel + + duplicate1(): number; +>duplicate1 : () => number + + duplicate2(): number; +>duplicate2 : () => number + + duplicate3(): number; +>duplicate3 : () => number +} + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans4.errors.txt b/tests/baselines/reference/duplicateIdentifierRelatedSpans4.errors.txt new file mode 100644 index 0000000000000..da50e3ad4a3dc --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans4.errors.txt @@ -0,0 +1,49 @@ +tests/cases/compiler/file1.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: duplicate1, duplicate2, duplicate3, duplicate4, duplicate5, duplicate6, duplicate7, duplicate8 + +1 interface TopLevel { +  ~~~~~~~~~ + + tests/cases/compiler/file2.ts:1:1 + 1 interface TopLevel { +   ~~~~~~~~~ + Conflicts are in this file. +tests/cases/compiler/file2.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: duplicate1, duplicate2, duplicate3, duplicate4, duplicate5, duplicate6, duplicate7, duplicate8 + +1 interface TopLevel { +  ~~~~~~~~~ + + tests/cases/compiler/file1.ts:1:1 + 1 interface TopLevel { +   ~~~~~~~~~ + Conflicts are in this file. + + +==== tests/cases/compiler/file1.ts (1 errors) ==== + interface TopLevel { + ~~~~~~~~~ +!!! error TS6200: Definitions of the following identifiers conflict with those in another file: duplicate1, duplicate2, duplicate3, duplicate4, duplicate5, duplicate6, duplicate7, duplicate8 +!!! related TS6201 tests/cases/compiler/file2.ts:1:1: Conflicts are in this file. + duplicate1: () => string; + duplicate2: () => string; + duplicate3: () => string; + duplicate4: () => string; + duplicate5: () => string; + duplicate6: () => string; + duplicate7: () => string; + duplicate8: () => string; + } +==== tests/cases/compiler/file2.ts (1 errors) ==== + interface TopLevel { + ~~~~~~~~~ +!!! error TS6200: Definitions of the following identifiers conflict with those in another file: duplicate1, duplicate2, duplicate3, duplicate4, duplicate5, duplicate6, duplicate7, duplicate8 +!!! related TS6201 tests/cases/compiler/file1.ts:1:1: Conflicts are in this file. + duplicate1(): number; + duplicate2(): number; + duplicate3(): number; + duplicate4(): number; + duplicate5(): number; + duplicate6(): number; + duplicate7(): number; + duplicate8(): number; + } + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans4.js b/tests/baselines/reference/duplicateIdentifierRelatedSpans4.js new file mode 100644 index 0000000000000..113e488c7bb24 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans4.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/duplicateIdentifierRelatedSpans4.ts] //// + +//// [file1.ts] +interface TopLevel { + duplicate1: () => string; + duplicate2: () => string; + duplicate3: () => string; + duplicate4: () => string; + duplicate5: () => string; + duplicate6: () => string; + duplicate7: () => string; + duplicate8: () => string; +} +//// [file2.ts] +interface TopLevel { + duplicate1(): number; + duplicate2(): number; + duplicate3(): number; + duplicate4(): number; + duplicate5(): number; + duplicate6(): number; + duplicate7(): number; + duplicate8(): number; +} + + +//// [file1.js] +//// [file2.js] diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans4.symbols b/tests/baselines/reference/duplicateIdentifierRelatedSpans4.symbols new file mode 100644 index 0000000000000..cef2fb78aca60 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans4.symbols @@ -0,0 +1,57 @@ +=== tests/cases/compiler/file1.ts === +interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 0), Decl(file2.ts, 0, 0)) + + duplicate1: () => string; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file1.ts, 0, 20)) + + duplicate2: () => string; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file1.ts, 1, 29)) + + duplicate3: () => string; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file1.ts, 2, 29)) + + duplicate4: () => string; +>duplicate4 : Symbol(TopLevel.duplicate4, Decl(file1.ts, 3, 29)) + + duplicate5: () => string; +>duplicate5 : Symbol(TopLevel.duplicate5, Decl(file1.ts, 4, 29)) + + duplicate6: () => string; +>duplicate6 : Symbol(TopLevel.duplicate6, Decl(file1.ts, 5, 29)) + + duplicate7: () => string; +>duplicate7 : Symbol(TopLevel.duplicate7, Decl(file1.ts, 6, 29)) + + duplicate8: () => string; +>duplicate8 : Symbol(TopLevel.duplicate8, Decl(file1.ts, 7, 29)) +} +=== tests/cases/compiler/file2.ts === +interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 0), Decl(file2.ts, 0, 0)) + + duplicate1(): number; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file2.ts, 0, 20)) + + duplicate2(): number; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file2.ts, 1, 25)) + + duplicate3(): number; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file2.ts, 2, 25)) + + duplicate4(): number; +>duplicate4 : Symbol(TopLevel.duplicate4, Decl(file2.ts, 3, 25)) + + duplicate5(): number; +>duplicate5 : Symbol(TopLevel.duplicate5, Decl(file2.ts, 4, 25)) + + duplicate6(): number; +>duplicate6 : Symbol(TopLevel.duplicate6, Decl(file2.ts, 5, 25)) + + duplicate7(): number; +>duplicate7 : Symbol(TopLevel.duplicate7, Decl(file2.ts, 6, 25)) + + duplicate8(): number; +>duplicate8 : Symbol(TopLevel.duplicate8, Decl(file2.ts, 7, 25)) +} + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans4.types b/tests/baselines/reference/duplicateIdentifierRelatedSpans4.types new file mode 100644 index 0000000000000..b81a27617bdeb --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans4.types @@ -0,0 +1,57 @@ +=== tests/cases/compiler/file1.ts === +interface TopLevel { +>TopLevel : TopLevel + + duplicate1: () => string; +>duplicate1 : () => string + + duplicate2: () => string; +>duplicate2 : () => string + + duplicate3: () => string; +>duplicate3 : () => string + + duplicate4: () => string; +>duplicate4 : () => string + + duplicate5: () => string; +>duplicate5 : () => string + + duplicate6: () => string; +>duplicate6 : () => string + + duplicate7: () => string; +>duplicate7 : () => string + + duplicate8: () => string; +>duplicate8 : () => string +} +=== tests/cases/compiler/file2.ts === +interface TopLevel { +>TopLevel : TopLevel + + duplicate1(): number; +>duplicate1 : () => number + + duplicate2(): number; +>duplicate2 : () => number + + duplicate3(): number; +>duplicate3 : () => number + + duplicate4(): number; +>duplicate4 : () => number + + duplicate5(): number; +>duplicate5 : () => number + + duplicate6(): number; +>duplicate6 : () => number + + duplicate7(): number; +>duplicate7 : () => number + + duplicate8(): number; +>duplicate8 : () => number +} + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans5.errors.txt b/tests/baselines/reference/duplicateIdentifierRelatedSpans5.errors.txt new file mode 100644 index 0000000000000..2cbd4fa9629f5 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans5.errors.txt @@ -0,0 +1,94 @@ +tests/cases/compiler/file1.ts:3:9 - error TS2300: Duplicate identifier 'duplicate1'. + +3 duplicate1: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:4:9 + 4 duplicate1(): number; +    ~~~~~~~~~~ + 'duplicate1' was also declared here. +tests/cases/compiler/file1.ts:4:9 - error TS2300: Duplicate identifier 'duplicate2'. + +4 duplicate2: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:5:9 + 5 duplicate2(): number; +    ~~~~~~~~~~ + 'duplicate2' was also declared here. +tests/cases/compiler/file1.ts:5:9 - error TS2300: Duplicate identifier 'duplicate3'. + +5 duplicate3: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:6:9 + 6 duplicate3(): number; +    ~~~~~~~~~~ + 'duplicate3' was also declared here. +tests/cases/compiler/file2.ts:4:9 - error TS2300: Duplicate identifier 'duplicate1'. + +4 duplicate1(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:3:9 + 3 duplicate1: () => string; +    ~~~~~~~~~~ + 'duplicate1' was also declared here. +tests/cases/compiler/file2.ts:5:9 - error TS2300: Duplicate identifier 'duplicate2'. + +5 duplicate2(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:4:9 + 4 duplicate2: () => string; +    ~~~~~~~~~~ + 'duplicate2' was also declared here. +tests/cases/compiler/file2.ts:6:9 - error TS2300: Duplicate identifier 'duplicate3'. + +6 duplicate3(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:5:9 + 5 duplicate3: () => string; +    ~~~~~~~~~~ + 'duplicate3' was also declared here. + + +==== tests/cases/compiler/file1.ts (3 errors) ==== + declare global { + interface TopLevel { + duplicate1: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate1'. +!!! related TS6203 tests/cases/compiler/file2.ts:4:9: 'duplicate1' was also declared here. + duplicate2: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate2'. +!!! related TS6203 tests/cases/compiler/file2.ts:5:9: 'duplicate2' was also declared here. + duplicate3: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate3'. +!!! related TS6203 tests/cases/compiler/file2.ts:6:9: 'duplicate3' was also declared here. + } + } + export {} +==== tests/cases/compiler/file2.ts (3 errors) ==== + import "./file1"; + declare global { + interface TopLevel { + duplicate1(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate1'. +!!! related TS6203 tests/cases/compiler/file1.ts:3:9: 'duplicate1' was also declared here. + duplicate2(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate2'. +!!! related TS6203 tests/cases/compiler/file1.ts:4:9: 'duplicate2' was also declared here. + duplicate3(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate3'. +!!! related TS6203 tests/cases/compiler/file1.ts:5:9: 'duplicate3' was also declared here. + } + } + export {} + \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans5.js b/tests/baselines/reference/duplicateIdentifierRelatedSpans5.js new file mode 100644 index 0000000000000..681d435c0d330 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans5.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/duplicateIdentifierRelatedSpans5.ts] //// + +//// [file1.ts] +declare global { + interface TopLevel { + duplicate1: () => string; + duplicate2: () => string; + duplicate3: () => string; + } +} +export {} +//// [file2.ts] +import "./file1"; +declare global { + interface TopLevel { + duplicate1(): number; + duplicate2(): number; + duplicate3(): number; + } +} +export {} + + +//// [file1.js] +"use strict"; +exports.__esModule = true; +//// [file2.js] +"use strict"; +exports.__esModule = true; +require("./file1"); diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans5.symbols b/tests/baselines/reference/duplicateIdentifierRelatedSpans5.symbols new file mode 100644 index 0000000000000..1364d5667dce6 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans5.symbols @@ -0,0 +1,38 @@ +=== tests/cases/compiler/file1.ts === +declare global { +>global : Symbol(global, Decl(file1.ts, 0, 0)) + + interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 16), Decl(file2.ts, 1, 16)) + + duplicate1: () => string; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file1.ts, 1, 24)) + + duplicate2: () => string; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file1.ts, 2, 33)) + + duplicate3: () => string; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file1.ts, 3, 33)) + } +} +export {} +=== tests/cases/compiler/file2.ts === +import "./file1"; +declare global { +>global : Symbol(global, Decl(file2.ts, 0, 17)) + + interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 16), Decl(file2.ts, 1, 16)) + + duplicate1(): number; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file2.ts, 2, 24)) + + duplicate2(): number; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file2.ts, 3, 29)) + + duplicate3(): number; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file2.ts, 4, 29)) + } +} +export {} + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans5.types b/tests/baselines/reference/duplicateIdentifierRelatedSpans5.types new file mode 100644 index 0000000000000..aa2147f30ab6a --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans5.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/file1.ts === +declare global { +>global : any + + interface TopLevel { +>TopLevel : TopLevel + + duplicate1: () => string; +>duplicate1 : () => string + + duplicate2: () => string; +>duplicate2 : () => string + + duplicate3: () => string; +>duplicate3 : () => string + } +} +export {} +=== tests/cases/compiler/file2.ts === +import "./file1"; +declare global { +>global : any + + interface TopLevel { +>TopLevel : TopLevel + + duplicate1(): number; +>duplicate1 : () => number + + duplicate2(): number; +>duplicate2 : () => number + + duplicate3(): number; +>duplicate3 : () => number + } +} +export {} + diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans6.errors.txt b/tests/baselines/reference/duplicateIdentifierRelatedSpans6.errors.txt new file mode 100644 index 0000000000000..afe6ebe9f42af --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans6.errors.txt @@ -0,0 +1,94 @@ +tests/cases/compiler/file1.ts:3:9 - error TS2300: Duplicate identifier 'duplicate1'. + +3 duplicate1: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:5:9 + 5 duplicate1(): number; +    ~~~~~~~~~~ + 'duplicate1' was also declared here. +tests/cases/compiler/file1.ts:4:9 - error TS2300: Duplicate identifier 'duplicate2'. + +4 duplicate2: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:6:9 + 6 duplicate2(): number; +    ~~~~~~~~~~ + 'duplicate2' was also declared here. +tests/cases/compiler/file1.ts:5:9 - error TS2300: Duplicate identifier 'duplicate3'. + +5 duplicate3: () => string; +   ~~~~~~~~~~ + + tests/cases/compiler/file2.ts:7:9 + 7 duplicate3(): number; +    ~~~~~~~~~~ + 'duplicate3' was also declared here. +tests/cases/compiler/file2.ts:5:9 - error TS2300: Duplicate identifier 'duplicate1'. + +5 duplicate1(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:3:9 + 3 duplicate1: () => string; +    ~~~~~~~~~~ + 'duplicate1' was also declared here. +tests/cases/compiler/file2.ts:6:9 - error TS2300: Duplicate identifier 'duplicate2'. + +6 duplicate2(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:4:9 + 4 duplicate2: () => string; +    ~~~~~~~~~~ + 'duplicate2' was also declared here. +tests/cases/compiler/file2.ts:7:9 - error TS2300: Duplicate identifier 'duplicate3'. + +7 duplicate3(): number; +   ~~~~~~~~~~ + + tests/cases/compiler/file1.ts:5:9 + 5 duplicate3: () => string; +    ~~~~~~~~~~ + 'duplicate3' was also declared here. + + +==== tests/cases/compiler/file2.ts (3 errors) ==== + /// + + declare module "someMod" { + export interface TopLevel { + duplicate1(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate1'. +!!! related TS6203 tests/cases/compiler/file1.ts:3:9: 'duplicate1' was also declared here. + duplicate2(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate2'. +!!! related TS6203 tests/cases/compiler/file1.ts:4:9: 'duplicate2' was also declared here. + duplicate3(): number; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate3'. +!!! related TS6203 tests/cases/compiler/file1.ts:5:9: 'duplicate3' was also declared here. + } + } + export {}; + +==== tests/cases/compiler/file1.ts (3 errors) ==== + declare module "someMod" { + export interface TopLevel { + duplicate1: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate1'. +!!! related TS6203 tests/cases/compiler/file2.ts:5:9: 'duplicate1' was also declared here. + duplicate2: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate2'. +!!! related TS6203 tests/cases/compiler/file2.ts:6:9: 'duplicate2' was also declared here. + duplicate3: () => string; + ~~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'duplicate3'. +!!! related TS6203 tests/cases/compiler/file2.ts:7:9: 'duplicate3' was also declared here. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans6.js b/tests/baselines/reference/duplicateIdentifierRelatedSpans6.js new file mode 100644 index 0000000000000..d6a6501dca592 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans6.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/duplicateIdentifierRelatedSpans6.ts] //// + +//// [file1.ts] +declare module "someMod" { + export interface TopLevel { + duplicate1: () => string; + duplicate2: () => string; + duplicate3: () => string; + } +} +//// [file2.ts] +/// + +declare module "someMod" { + export interface TopLevel { + duplicate1(): number; + duplicate2(): number; + duplicate3(): number; + } +} +export {}; + + +//// [file1.js] +//// [file2.js] +"use strict"; +/// +exports.__esModule = true; diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans6.symbols b/tests/baselines/reference/duplicateIdentifierRelatedSpans6.symbols new file mode 100644 index 0000000000000..0d8d01f1bed0e --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans6.symbols @@ -0,0 +1,38 @@ +=== tests/cases/compiler/file2.ts === +/// + +declare module "someMod" { +>"someMod" : Symbol("someMod", Decl(file1.ts, 0, 0), Decl(file2.ts, 0, 0)) + + export interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 26), Decl(file2.ts, 2, 26)) + + duplicate1(): number; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file2.ts, 3, 31)) + + duplicate2(): number; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file2.ts, 4, 29)) + + duplicate3(): number; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file2.ts, 5, 29)) + } +} +export {}; + +=== tests/cases/compiler/file1.ts === +declare module "someMod" { +>"someMod" : Symbol("someMod", Decl(file1.ts, 0, 0), Decl(file2.ts, 0, 0)) + + export interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 26), Decl(file2.ts, 2, 26)) + + duplicate1: () => string; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file1.ts, 1, 31)) + + duplicate2: () => string; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file1.ts, 2, 33)) + + duplicate3: () => string; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file1.ts, 3, 33)) + } +} diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans6.types b/tests/baselines/reference/duplicateIdentifierRelatedSpans6.types new file mode 100644 index 0000000000000..446e402d834f8 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans6.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/file2.ts === +/// + +declare module "someMod" { +>"someMod" : typeof import("someMod") + + export interface TopLevel { +>TopLevel : TopLevel + + duplicate1(): number; +>duplicate1 : () => number + + duplicate2(): number; +>duplicate2 : () => number + + duplicate3(): number; +>duplicate3 : () => number + } +} +export {}; + +=== tests/cases/compiler/file1.ts === +declare module "someMod" { +>"someMod" : typeof import("someMod") + + export interface TopLevel { +>TopLevel : TopLevel + + duplicate1: () => string; +>duplicate1 : () => string + + duplicate2: () => string; +>duplicate2 : () => string + + duplicate3: () => string; +>duplicate3 : () => string + } +} diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans7.errors.txt b/tests/baselines/reference/duplicateIdentifierRelatedSpans7.errors.txt new file mode 100644 index 0000000000000..76bb3d9c750b2 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans7.errors.txt @@ -0,0 +1,58 @@ +tests/cases/compiler/file1.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: duplicate1, duplicate2, duplicate3, duplicate4, duplicate5, duplicate6, duplicate7, duplicate8, duplicate9 + +1 declare module "someMod" { +  ~~~~~~~ + + tests/cases/compiler/file2.ts:3:1 + 3 declare module "someMod" { +   ~~~~~~~ + Conflicts are in this file. +tests/cases/compiler/file2.ts:3:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: duplicate1, duplicate2, duplicate3, duplicate4, duplicate5, duplicate6, duplicate7, duplicate8, duplicate9 + +3 declare module "someMod" { +  ~~~~~~~ + + tests/cases/compiler/file1.ts:1:1 + 1 declare module "someMod" { +   ~~~~~~~ + Conflicts are in this file. + + +==== tests/cases/compiler/file2.ts (1 errors) ==== + /// + + declare module "someMod" { + ~~~~~~~ +!!! error TS6200: Definitions of the following identifiers conflict with those in another file: duplicate1, duplicate2, duplicate3, duplicate4, duplicate5, duplicate6, duplicate7, duplicate8, duplicate9 +!!! related TS6201 tests/cases/compiler/file1.ts:1:1: Conflicts are in this file. + export interface TopLevel { + duplicate1(): number; + duplicate2(): number; + duplicate3(): number; + duplicate4(): number; + duplicate5(): number; + duplicate6(): number; + duplicate7(): number; + duplicate8(): number; + duplicate9(): number; + } + } + export {}; + +==== tests/cases/compiler/file1.ts (1 errors) ==== + declare module "someMod" { + ~~~~~~~ +!!! error TS6200: Definitions of the following identifiers conflict with those in another file: duplicate1, duplicate2, duplicate3, duplicate4, duplicate5, duplicate6, duplicate7, duplicate8, duplicate9 +!!! related TS6201 tests/cases/compiler/file2.ts:3:1: Conflicts are in this file. + export interface TopLevel { + duplicate1: () => string; + duplicate2: () => string; + duplicate3: () => string; + duplicate4: () => string; + duplicate5: () => string; + duplicate6: () => string; + duplicate7: () => string; + duplicate8: () => string; + duplicate9: () => string; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans7.js b/tests/baselines/reference/duplicateIdentifierRelatedSpans7.js new file mode 100644 index 0000000000000..9bb8a73bd8d18 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans7.js @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/duplicateIdentifierRelatedSpans7.ts] //// + +//// [file1.ts] +declare module "someMod" { + export interface TopLevel { + duplicate1: () => string; + duplicate2: () => string; + duplicate3: () => string; + duplicate4: () => string; + duplicate5: () => string; + duplicate6: () => string; + duplicate7: () => string; + duplicate8: () => string; + duplicate9: () => string; + } +} +//// [file2.ts] +/// + +declare module "someMod" { + export interface TopLevel { + duplicate1(): number; + duplicate2(): number; + duplicate3(): number; + duplicate4(): number; + duplicate5(): number; + duplicate6(): number; + duplicate7(): number; + duplicate8(): number; + duplicate9(): number; + } +} +export {}; + + +//// [file1.js] +//// [file2.js] +"use strict"; +/// +exports.__esModule = true; diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans7.symbols b/tests/baselines/reference/duplicateIdentifierRelatedSpans7.symbols new file mode 100644 index 0000000000000..e2843e9c2e2d3 --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans7.symbols @@ -0,0 +1,74 @@ +=== tests/cases/compiler/file2.ts === +/// + +declare module "someMod" { +>"someMod" : Symbol("someMod", Decl(file1.ts, 0, 0), Decl(file2.ts, 0, 0)) + + export interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 26), Decl(file2.ts, 2, 26)) + + duplicate1(): number; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file2.ts, 3, 31)) + + duplicate2(): number; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file2.ts, 4, 29)) + + duplicate3(): number; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file2.ts, 5, 29)) + + duplicate4(): number; +>duplicate4 : Symbol(TopLevel.duplicate4, Decl(file2.ts, 6, 29)) + + duplicate5(): number; +>duplicate5 : Symbol(TopLevel.duplicate5, Decl(file2.ts, 7, 29)) + + duplicate6(): number; +>duplicate6 : Symbol(TopLevel.duplicate6, Decl(file2.ts, 8, 29)) + + duplicate7(): number; +>duplicate7 : Symbol(TopLevel.duplicate7, Decl(file2.ts, 9, 29)) + + duplicate8(): number; +>duplicate8 : Symbol(TopLevel.duplicate8, Decl(file2.ts, 10, 29)) + + duplicate9(): number; +>duplicate9 : Symbol(TopLevel.duplicate9, Decl(file2.ts, 11, 29)) + } +} +export {}; + +=== tests/cases/compiler/file1.ts === +declare module "someMod" { +>"someMod" : Symbol("someMod", Decl(file1.ts, 0, 0), Decl(file2.ts, 0, 0)) + + export interface TopLevel { +>TopLevel : Symbol(TopLevel, Decl(file1.ts, 0, 26), Decl(file2.ts, 2, 26)) + + duplicate1: () => string; +>duplicate1 : Symbol(TopLevel.duplicate1, Decl(file1.ts, 1, 31)) + + duplicate2: () => string; +>duplicate2 : Symbol(TopLevel.duplicate2, Decl(file1.ts, 2, 33)) + + duplicate3: () => string; +>duplicate3 : Symbol(TopLevel.duplicate3, Decl(file1.ts, 3, 33)) + + duplicate4: () => string; +>duplicate4 : Symbol(TopLevel.duplicate4, Decl(file1.ts, 4, 33)) + + duplicate5: () => string; +>duplicate5 : Symbol(TopLevel.duplicate5, Decl(file1.ts, 5, 33)) + + duplicate6: () => string; +>duplicate6 : Symbol(TopLevel.duplicate6, Decl(file1.ts, 6, 33)) + + duplicate7: () => string; +>duplicate7 : Symbol(TopLevel.duplicate7, Decl(file1.ts, 7, 33)) + + duplicate8: () => string; +>duplicate8 : Symbol(TopLevel.duplicate8, Decl(file1.ts, 8, 33)) + + duplicate9: () => string; +>duplicate9 : Symbol(TopLevel.duplicate9, Decl(file1.ts, 9, 33)) + } +} diff --git a/tests/baselines/reference/duplicateIdentifierRelatedSpans7.types b/tests/baselines/reference/duplicateIdentifierRelatedSpans7.types new file mode 100644 index 0000000000000..4776b7a0b928b --- /dev/null +++ b/tests/baselines/reference/duplicateIdentifierRelatedSpans7.types @@ -0,0 +1,74 @@ +=== tests/cases/compiler/file2.ts === +/// + +declare module "someMod" { +>"someMod" : typeof import("someMod") + + export interface TopLevel { +>TopLevel : TopLevel + + duplicate1(): number; +>duplicate1 : () => number + + duplicate2(): number; +>duplicate2 : () => number + + duplicate3(): number; +>duplicate3 : () => number + + duplicate4(): number; +>duplicate4 : () => number + + duplicate5(): number; +>duplicate5 : () => number + + duplicate6(): number; +>duplicate6 : () => number + + duplicate7(): number; +>duplicate7 : () => number + + duplicate8(): number; +>duplicate8 : () => number + + duplicate9(): number; +>duplicate9 : () => number + } +} +export {}; + +=== tests/cases/compiler/file1.ts === +declare module "someMod" { +>"someMod" : typeof import("someMod") + + export interface TopLevel { +>TopLevel : TopLevel + + duplicate1: () => string; +>duplicate1 : () => string + + duplicate2: () => string; +>duplicate2 : () => string + + duplicate3: () => string; +>duplicate3 : () => string + + duplicate4: () => string; +>duplicate4 : () => string + + duplicate5: () => string; +>duplicate5 : () => string + + duplicate6: () => string; +>duplicate6 : () => string + + duplicate7: () => string; +>duplicate7 : () => string + + duplicate8: () => string; +>duplicate8 : () => string + + duplicate9: () => string; +>duplicate9 : () => string + } +} diff --git a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt index 400bafa3c1a75..8dca0b9ffcc3c 100644 --- a/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt +++ b/tests/baselines/reference/duplicateIdentifiersAcrossFileBoundaries.errors.txt @@ -13,15 +13,18 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. class C2 { } ~~ !!! error TS2300: Duplicate identifier 'C2'. +!!! related TS6203 tests/cases/compiler/file2.ts:3:10: 'C2' was also declared here. function f() { } ~ !!! error TS2300: Duplicate identifier 'f'. +!!! related TS6203 tests/cases/compiler/file2.ts:4:7: 'f' was also declared here. var v = 3; class Foo { static x: number; ~ !!! error TS2300: Duplicate identifier 'x'. +!!! related TS6203 tests/cases/compiler/file2.ts:8:16: 'x' was also declared here. } module N { @@ -36,9 +39,11 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. function C2() { } // error -- cannot merge function with non-ambient class ~~ !!! error TS2300: Duplicate identifier 'C2'. +!!! related TS6203 tests/cases/compiler/file1.ts:3:7: 'C2' was also declared here. class f { } // error -- cannot merge function with non-ambient class ~ !!! error TS2300: Duplicate identifier 'f'. +!!! related TS6203 tests/cases/compiler/file1.ts:4:10: 'f' was also declared here. var v = 3; module Foo { @@ -47,6 +52,7 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'. export var x: number; // error for redeclaring var in a different parent ~ !!! error TS2300: Duplicate identifier 'x'. +!!! related TS6203 tests/cases/compiler/file1.ts:8:12: 'x' was also declared here. } declare module N { diff --git a/tests/baselines/reference/duplicatePackage_globalMerge.errors.txt b/tests/baselines/reference/duplicatePackage_globalMerge.errors.txt new file mode 100644 index 0000000000000..d7e77340ac100 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_globalMerge.errors.txt @@ -0,0 +1,31 @@ +/node_modules/@types/react/index.d.ts(1,9): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. +/src/index.ts(1,24): error TS2306: File '/node_modules/@types/react/index.d.ts' is not a module. +/tests/index.ts(1,24): error TS2306: File '/tests/node_modules/@types/react/index.d.ts' is not a module. + + +==== /src/bug25410.ts (0 errors) ==== + import { x } from './index' + import { y } from '../tests/index' + +==== /src/index.ts (1 errors) ==== + import * as React from 'react'; + ~~~~~~~ +!!! error TS2306: File '/node_modules/@types/react/index.d.ts' is not a module. + export var x = 1 +==== /tests/index.ts (1 errors) ==== + import * as React from 'react'; + ~~~~~~~ +!!! error TS2306: File '/tests/node_modules/@types/react/index.d.ts' is not a module. + export var y = 2 + +==== /tests/node_modules/@types/react/package.json (0 errors) ==== + { "name": "@types/react", "version": "16.4.6" } +==== /tests/node_modules/@types/react/index.d.ts (0 errors) ==== + +==== /node_modules/@types/react/package.json (0 errors) ==== + { "name": "@types/react", "version": "16.4.6" } +==== /node_modules/@types/react/index.d.ts (1 errors) ==== + declare global { } + ~~~~~~ +!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations. + \ No newline at end of file diff --git a/tests/baselines/reference/duplicatePackage_globalMerge.js b/tests/baselines/reference/duplicatePackage_globalMerge.js new file mode 100644 index 0000000000000..6f12995e022fc --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_globalMerge.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/duplicatePackage_globalMerge.ts] //// + +//// [index.ts] +import * as React from 'react'; +export var x = 1 +//// [index.ts] +import * as React from 'react'; +export var y = 2 + +//// [package.json] +{ "name": "@types/react", "version": "16.4.6" } +//// [index.d.ts] + +//// [package.json] +{ "name": "@types/react", "version": "16.4.6" } +//// [index.d.ts] +declare global { } + +//// [bug25410.ts] +import { x } from './index' +import { y } from '../tests/index' + + +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.x = 1; +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.y = 2; +//// [bug25410.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/duplicatePackage_globalMerge.symbols b/tests/baselines/reference/duplicatePackage_globalMerge.symbols new file mode 100644 index 0000000000000..d17be9ae8554b --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_globalMerge.symbols @@ -0,0 +1,29 @@ +=== /src/bug25410.ts === +import { x } from './index' +>x : Symbol(x, Decl(bug25410.ts, 0, 8)) + +import { y } from '../tests/index' +>y : Symbol(y, Decl(bug25410.ts, 1, 8)) + +=== /src/index.ts === +import * as React from 'react'; +>React : Symbol(React, Decl(index.ts, 0, 6)) + +export var x = 1 +>x : Symbol(x, Decl(index.ts, 1, 10)) + +=== /tests/index.ts === +import * as React from 'react'; +>React : Symbol(React, Decl(index.ts, 0, 6)) + +export var y = 2 +>y : Symbol(y, Decl(index.ts, 1, 10)) + +=== /tests/node_modules/@types/react/index.d.ts === + +>global : Symbol(global, Decl(index.d.ts, 0, 0)) + +=== /node_modules/@types/react/index.d.ts === +declare global { } +>global : Symbol(global, Decl(index.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/duplicatePackage_globalMerge.types b/tests/baselines/reference/duplicatePackage_globalMerge.types new file mode 100644 index 0000000000000..b558538be3d8c --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_globalMerge.types @@ -0,0 +1,31 @@ +=== /src/bug25410.ts === +import { x } from './index' +>x : number + +import { y } from '../tests/index' +>y : number + +=== /src/index.ts === +import * as React from 'react'; +>React : any + +export var x = 1 +>x : number +>1 : 1 + +=== /tests/index.ts === +import * as React from 'react'; +>React : any + +export var y = 2 +>y : number +>2 : 2 + +=== /tests/node_modules/@types/react/index.d.ts === + +>global : typeof global + +=== /node_modules/@types/react/index.d.ts === +declare global { } +>global : typeof global + diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 174aff77424c9..be4cb35bcb50a 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -141,7 +141,7 @@ namespace N { >T5 : T5 } export declare type T7 = { ->T7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>T7 : T7 [N.c2]: number; >[N.c2] : number diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt new file mode 100644 index 0000000000000..dc7e3f10bd120 --- /dev/null +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(4,1): error TS2322: Type '{ foo: { bar: number | undefined; }; }' is not assignable to type '{ foo: { bar: string | null; } | undefined; }'. + Types of property 'foo' are incompatible. + Type '{ bar: number | undefined; }' is not assignable to type '{ bar: string | null; }'. + Types of property 'bar' are incompatible. + Type 'number | undefined' is not assignable to type 'string | null'. + Type 'undefined' is not assignable to type 'string | null'. +tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(6,1): error TS2322: Type '{ foo: { bar: string | null; } | undefined; } | null | undefined' is not assignable to type '{ foo: { bar: number | undefined; }; }'. + Type 'undefined' is not assignable to type '{ foo: { bar: number | undefined; }; }'. + + +==== tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts (2 errors) ==== + export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; + export declare let y: { foo: { bar: number | undefined } }; + + x = y; + ~ +!!! error TS2322: Type '{ foo: { bar: number | undefined; }; }' is not assignable to type '{ foo: { bar: string | null; } | undefined; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type '{ bar: number | undefined; }' is not assignable to type '{ bar: string | null; }'. +!!! error TS2322: Types of property 'bar' are incompatible. +!!! error TS2322: Type 'number | undefined' is not assignable to type 'string | null'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'. + + y = x; + ~ +!!! error TS2322: Type '{ foo: { bar: string | null; } | undefined; } | null | undefined' is not assignable to type '{ foo: { bar: number | undefined; }; }'. +!!! error TS2322: Type 'undefined' is not assignable to type '{ foo: { bar: number | undefined; }; }'. + \ No newline at end of file diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.js b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.js new file mode 100644 index 0000000000000..f4e223c60813f --- /dev/null +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.js @@ -0,0 +1,14 @@ +//// [elaboratedErrorsOnNullableTargets01.ts] +export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; +export declare let y: { foo: { bar: number | undefined } }; + +x = y; + +y = x; + + +//// [elaboratedErrorsOnNullableTargets01.js] +"use strict"; +exports.__esModule = true; +exports.x = exports.y; +exports.y = exports.x; diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.symbols b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.symbols new file mode 100644 index 0000000000000..4f218b2e28f8e --- /dev/null +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts === +export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; +>x : Symbol(x, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 18)) +>foo : Symbol(foo, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 30)) +>bar : Symbol(bar, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 37)) + +export declare let y: { foo: { bar: number | undefined } }; +>y : Symbol(y, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 18)) +>foo : Symbol(foo, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 23)) +>bar : Symbol(bar, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 30)) + +x = y; +>x : Symbol(x, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 18)) +>y : Symbol(y, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 18)) + +y = x; +>y : Symbol(y, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 18)) +>x : Symbol(x, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 18)) + diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.types b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.types new file mode 100644 index 0000000000000..614237644cf1c --- /dev/null +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts === +export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; +>x : { foo: { bar: string | null; } | undefined; } | null | undefined +>null : null +>foo : { bar: string | null; } | undefined +>bar : string | null +>null : null + +export declare let y: { foo: { bar: number | undefined } }; +>y : { foo: { bar: number | undefined; }; } +>foo : { bar: number | undefined; } +>bar : number | undefined + +x = y; +>x = y : { foo: { bar: number | undefined; }; } +>x : { foo: { bar: string | null; } | undefined; } | null | undefined +>y : { foo: { bar: number | undefined; }; } + +y = x; +>y = x : { foo: { bar: string | null; } | undefined; } | null | undefined +>y : { foo: { bar: number | undefined; }; } +>x : { foo: { bar: string | null; } | undefined; } | null | undefined + diff --git a/tests/baselines/reference/emitDefaultParametersFunctionExpression.types b/tests/baselines/reference/emitDefaultParametersFunctionExpression.types index 7546bda0d4169..e8707ba653efc 100644 --- a/tests/baselines/reference/emitDefaultParametersFunctionExpression.types +++ b/tests/baselines/reference/emitDefaultParametersFunctionExpression.types @@ -37,22 +37,22 @@ var x = function (str = "hello", ...rest) { } var y = (function (num = 10, boo = false, ...rest) { })() >y : void >(function (num = 10, boo = false, ...rest) { })() : void ->(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void ->function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void +>(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean) => void +>function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean) => void >num : number >10 : 10 >boo : boolean >false : false ->rest : any[] +>rest : [] var z = (function (num: number, boo = false, ...rest) { })(10) >z : void >(function (num: number, boo = false, ...rest) { })(10) : void ->(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean, ...rest: any[]) => void ->function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void +>(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean) => void +>function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean) => void >num : number >boo : boolean >false : false ->rest : any[] +>rest : [] >10 : 10 diff --git a/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types b/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types index 99ab6a481378c..adf70cde16f74 100644 --- a/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types +++ b/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types @@ -37,22 +37,22 @@ var x = function (str = "hello", ...rest) { } var y = (function (num = 10, boo = false, ...rest) { })() >y : void >(function (num = 10, boo = false, ...rest) { })() : void ->(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void ->function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void +>(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean) => void +>function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean) => void >num : number >10 : 10 >boo : boolean >false : false ->rest : any[] +>rest : [] var z = (function (num: number, boo = false, ...rest) { })(10) >z : void >(function (num: number, boo = false, ...rest) { })(10) : void ->(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean, ...rest: any[]) => void ->function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void +>(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean) => void +>function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean) => void >num : number >boo : boolean >false : false ->rest : any[] +>rest : [] >10 : 10 diff --git a/tests/baselines/reference/emitRestParametersFunctionExpression.types b/tests/baselines/reference/emitRestParametersFunctionExpression.types index 9f08b9d9d83f8..bb3e1c8028b4d 100644 --- a/tests/baselines/reference/emitRestParametersFunctionExpression.types +++ b/tests/baselines/reference/emitRestParametersFunctionExpression.types @@ -18,7 +18,7 @@ var funcExp2 = function (...rest) { } var funcExp3 = (function (...rest) { })() >funcExp3 : void >(function (...rest) { })() : void ->(function (...rest) { }) : (...rest: any[]) => void ->function (...rest) { } : (...rest: any[]) => void ->rest : any[] +>(function (...rest) { }) : () => void +>function (...rest) { } : () => void +>rest : [] diff --git a/tests/baselines/reference/emitRestParametersFunctionExpressionES6.types b/tests/baselines/reference/emitRestParametersFunctionExpressionES6.types index 224cb37367a44..c06b359b89cd7 100644 --- a/tests/baselines/reference/emitRestParametersFunctionExpressionES6.types +++ b/tests/baselines/reference/emitRestParametersFunctionExpressionES6.types @@ -18,7 +18,7 @@ var funcExp2 = function (...rest) { } var funcExp3 = (function (...rest) { })() >funcExp3 : void >(function (...rest) { })() : void ->(function (...rest) { }) : (...rest: any[]) => void ->function (...rest) { } : (...rest: any[]) => void ->rest : any[] +>(function (...rest) { }) : () => void +>function (...rest) { } : () => void +>rest : [] diff --git a/tests/baselines/reference/enumLiteralTypes3.errors.txt b/tests/baselines/reference/enumLiteralTypes3.errors.txt index 62cb4644c7256..8d4007530a8dc 100644 --- a/tests/baselines/reference/enumLiteralTypes3.errors.txt +++ b/tests/baselines/reference/enumLiteralTypes3.errors.txt @@ -7,9 +7,9 @@ tests/cases/conformance/types/literal/enumLiteralTypes3.ts(19,5): error TS2322: tests/cases/conformance/types/literal/enumLiteralTypes3.ts(37,5): error TS2322: Type 'Choice.Unknown' is not assignable to type 'Choice.Yes'. tests/cases/conformance/types/literal/enumLiteralTypes3.ts(39,5): error TS2322: Type 'Choice.No' is not assignable to type 'Choice.Yes'. tests/cases/conformance/types/literal/enumLiteralTypes3.ts(40,5): error TS2322: Type 'Choice.Unknown' is not assignable to type 'YesNo'. -tests/cases/conformance/types/literal/enumLiteralTypes3.ts(52,5): error TS2365: Operator '===' cannot be applied to types 'Choice.Yes' and 'Choice.Unknown'. -tests/cases/conformance/types/literal/enumLiteralTypes3.ts(54,5): error TS2365: Operator '===' cannot be applied to types 'Choice.Yes' and 'Choice.No'. -tests/cases/conformance/types/literal/enumLiteralTypes3.ts(55,5): error TS2365: Operator '===' cannot be applied to types 'YesNo' and 'Choice.Unknown'. +tests/cases/conformance/types/literal/enumLiteralTypes3.ts(52,5): error TS2367: This condition will always return 'false' since the types 'Choice.Yes' and 'Choice.Unknown' have no overlap. +tests/cases/conformance/types/literal/enumLiteralTypes3.ts(54,5): error TS2367: This condition will always return 'false' since the types 'Choice.Yes' and 'Choice.No' have no overlap. +tests/cases/conformance/types/literal/enumLiteralTypes3.ts(55,5): error TS2367: This condition will always return 'false' since the types 'YesNo' and 'Choice.Unknown' have no overlap. tests/cases/conformance/types/literal/enumLiteralTypes3.ts(87,14): error TS2678: Type 'Choice.Unknown' is not comparable to type 'Choice.Yes'. tests/cases/conformance/types/literal/enumLiteralTypes3.ts(89,14): error TS2678: Type 'Choice.No' is not comparable to type 'Choice.Yes'. tests/cases/conformance/types/literal/enumLiteralTypes3.ts(96,14): error TS2678: Type 'Choice.Unknown' is not comparable to type 'YesNo'. @@ -86,14 +86,14 @@ tests/cases/conformance/types/literal/enumLiteralTypes3.ts(96,14): error TS2678: function f6(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { a === Choice.Unknown; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'Choice.Yes' and 'Choice.Unknown'. +!!! error TS2367: This condition will always return 'false' since the types 'Choice.Yes' and 'Choice.Unknown' have no overlap. a === Choice.Yes; a === Choice.No; ~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'Choice.Yes' and 'Choice.No'. +!!! error TS2367: This condition will always return 'false' since the types 'Choice.Yes' and 'Choice.No' have no overlap. b === Choice.Unknown; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'YesNo' and 'Choice.Unknown'. +!!! error TS2367: This condition will always return 'false' since the types 'YesNo' and 'Choice.Unknown' have no overlap. b === Choice.Yes; b === Choice.No; c === Choice.Unknown; diff --git a/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt b/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt index 64e1830b52100..599774f05c0de 100644 --- a/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt +++ b/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt @@ -5,6 +5,7 @@ tests/cases/compiler/enumUsedBeforeDeclaration.ts(1,18): error TS2450: Enum 'Col const v: Color = Color.Green; ~~~~~ !!! error TS2450: Enum 'Color' used before its declaration. +!!! related TS2728 tests/cases/compiler/enumUsedBeforeDeclaration.ts:3:6: 'Color' is declared here. const v2: ConstColor = ConstColor.Green; enum Color { Red, Green, Blue } const enum ConstColor { Red, Green, Blue } diff --git a/tests/baselines/reference/equalityWithIntersectionTypes01.errors.txt b/tests/baselines/reference/equalityWithIntersectionTypes01.errors.txt index 8bffff2218b5c..d9cbc5c767d09 100644 --- a/tests/baselines/reference/equalityWithIntersectionTypes01.errors.txt +++ b/tests/baselines/reference/equalityWithIntersectionTypes01.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(17,5): error TS2365: Operator '===' cannot be applied to types 'I1 & I3' and 'I2'. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(17,16): error TS2365: Operator '===' cannot be applied to types 'I2' and 'I1 & I3'. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(19,10): error TS2365: Operator '!==' cannot be applied to types 'I1 & I3' and 'I2'. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(19,21): error TS2365: Operator '!==' cannot be applied to types 'I2' and 'I1 & I3'. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(21,10): error TS2365: Operator '==' cannot be applied to types 'I1 & I3' and 'I2'. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(21,20): error TS2365: Operator '==' cannot be applied to types 'I2' and 'I1 & I3'. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(23,10): error TS2365: Operator '!=' cannot be applied to types 'I1 & I3' and 'I2'. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(23,20): error TS2365: Operator '!=' cannot be applied to types 'I2' and 'I1 & I3'. +tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(17,5): error TS2367: This condition will always return 'false' since the types 'I1 & I3' and 'I2' have no overlap. +tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(17,16): error TS2367: This condition will always return 'false' since the types 'I2' and 'I1 & I3' have no overlap. +tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(19,10): error TS2367: This condition will always return 'true' since the types 'I1 & I3' and 'I2' have no overlap. +tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(19,21): error TS2367: This condition will always return 'true' since the types 'I2' and 'I1 & I3' have no overlap. +tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(21,10): error TS2367: This condition will always return 'false' since the types 'I1 & I3' and 'I2' have no overlap. +tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(21,20): error TS2367: This condition will always return 'false' since the types 'I2' and 'I1 & I3' have no overlap. +tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(23,10): error TS2367: This condition will always return 'true' since the types 'I1 & I3' and 'I2' have no overlap. +tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(23,20): error TS2367: This condition will always return 'true' since the types 'I2' and 'I1 & I3' have no overlap. ==== tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts (8 errors) ==== @@ -27,25 +27,25 @@ tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersect if (y === z || z === y) { ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'I1 & I3' and 'I2'. +!!! error TS2367: This condition will always return 'false' since the types 'I1 & I3' and 'I2' have no overlap. ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'I2' and 'I1 & I3'. +!!! error TS2367: This condition will always return 'false' since the types 'I2' and 'I1 & I3' have no overlap. } else if (y !== z || z !== y) { ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'I1 & I3' and 'I2'. +!!! error TS2367: This condition will always return 'true' since the types 'I1 & I3' and 'I2' have no overlap. ~~~~~~~ -!!! error TS2365: Operator '!==' cannot be applied to types 'I2' and 'I1 & I3'. +!!! error TS2367: This condition will always return 'true' since the types 'I2' and 'I1 & I3' have no overlap. } else if (y == z || z == y) { ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'I1 & I3' and 'I2'. +!!! error TS2367: This condition will always return 'false' since the types 'I1 & I3' and 'I2' have no overlap. ~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'I2' and 'I1 & I3'. +!!! error TS2367: This condition will always return 'false' since the types 'I2' and 'I1 & I3' have no overlap. } else if (y != z || z != y) { ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'I1 & I3' and 'I2'. +!!! error TS2367: This condition will always return 'true' since the types 'I1 & I3' and 'I2' have no overlap. ~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'I2' and 'I1 & I3'. +!!! error TS2367: This condition will always return 'true' since the types 'I2' and 'I1 & I3' have no overlap. } \ No newline at end of file diff --git a/tests/baselines/reference/errorElaboration.errors.txt b/tests/baselines/reference/errorElaboration.errors.txt index 94742d7d98bc4..57971cad26912 100644 --- a/tests/baselines/reference/errorElaboration.errors.txt +++ b/tests/baselines/reference/errorElaboration.errors.txt @@ -2,9 +2,10 @@ tests/cases/compiler/errorElaboration.ts(12,5): error TS2345: Argument of type ' Type 'Container>' is not assignable to type 'Container>'. Type 'Ref' is not assignable to type 'Ref'. Type 'string' is not assignable to type 'number'. +tests/cases/compiler/errorElaboration.ts(17,11): error TS2322: Type '"bar"' is not assignable to type '"foo"'. -==== tests/cases/compiler/errorElaboration.ts (1 errors) ==== +==== tests/cases/compiler/errorElaboration.ts (2 errors) ==== // Repro for #5712 interface Ref { @@ -22,4 +23,13 @@ tests/cases/compiler/errorElaboration.ts(12,5): error TS2345: Argument of type ' !!! error TS2345: Type 'Container>' is not assignable to type 'Container>'. !!! error TS2345: Type 'Ref' is not assignable to type 'Ref'. !!! error TS2345: Type 'string' is not assignable to type 'number'. + + // Repro for #25498 + + function test(): {[A in "foo"]: A} { + return {foo: "bar"}; + ~~~ +!!! error TS2322: Type '"bar"' is not assignable to type '"foo"'. +!!! related TS6500 tests/cases/compiler/errorElaboration.ts:16:18: The expected type comes from property 'foo' which is declared here on type '{ foo: "foo"; }' + } \ No newline at end of file diff --git a/tests/baselines/reference/errorElaboration.js b/tests/baselines/reference/errorElaboration.js index eed8bbd7c6b89..c1dd0a470d383 100644 --- a/tests/baselines/reference/errorElaboration.js +++ b/tests/baselines/reference/errorElaboration.js @@ -11,9 +11,19 @@ interface Container { declare function foo(x: () => Container>): void; let a: () => Container>; foo(a); + +// Repro for #25498 + +function test(): {[A in "foo"]: A} { + return {foo: "bar"}; +} //// [errorElaboration.js] // Repro for #5712 var a; foo(a); +// Repro for #25498 +function test() { + return { foo: "bar" }; +} diff --git a/tests/baselines/reference/errorElaboration.symbols b/tests/baselines/reference/errorElaboration.symbols index 72206e3caefe7..839b19c05993e 100644 --- a/tests/baselines/reference/errorElaboration.symbols +++ b/tests/baselines/reference/errorElaboration.symbols @@ -38,3 +38,14 @@ foo(a); >foo : Symbol(foo, Decl(errorElaboration.ts, 8, 1)) >a : Symbol(a, Decl(errorElaboration.ts, 10, 3)) +// Repro for #25498 + +function test(): {[A in "foo"]: A} { +>test : Symbol(test, Decl(errorElaboration.ts, 11, 7)) +>A : Symbol(A, Decl(errorElaboration.ts, 15, 19)) +>A : Symbol(A, Decl(errorElaboration.ts, 15, 19)) + + return {foo: "bar"}; +>foo : Symbol(foo, Decl(errorElaboration.ts, 16, 10)) +} + diff --git a/tests/baselines/reference/errorElaboration.types b/tests/baselines/reference/errorElaboration.types index 96aaba6ce3095..385ab481bb2fb 100644 --- a/tests/baselines/reference/errorElaboration.types +++ b/tests/baselines/reference/errorElaboration.types @@ -39,3 +39,16 @@ foo(a); >foo : (x: () => Container>) => void >a : () => Container> +// Repro for #25498 + +function test(): {[A in "foo"]: A} { +>test : () => { foo: "foo"; } +>A : A +>A : A + + return {foo: "bar"}; +>{foo: "bar"} : { foo: "bar"; } +>foo : "bar" +>"bar" : "bar" +} + diff --git a/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt b/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt index 7dffc9053e3cb..fc6b1e8aa18cc 100644 --- a/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt +++ b/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt @@ -12,4 +12,5 @@ tests/cases/compiler/errorMessageOnObjectLiteralType.ts(6,8): error TS2551: Prop !!! error TS2339: Property 'getOwnPropertyNamess' does not exist on type '{ a: string; b: number; }'. Object.getOwnPropertyNamess(null); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2551: Property 'getOwnPropertyNamess' does not exist on type 'ObjectConstructor'. Did you mean 'getOwnPropertyNames'? \ No newline at end of file +!!! error TS2551: Property 'getOwnPropertyNamess' does not exist on type 'ObjectConstructor'. Did you mean 'getOwnPropertyNames'? +!!! related TS2728 /.ts/lib.es5.d.ts:179:5: 'getOwnPropertyNames' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/errorWithTruncatedType.errors.txt b/tests/baselines/reference/errorWithTruncatedType.errors.txt index 33714b8626280..2f6e095a042ae 100644 --- a/tests/baselines/reference/errorWithTruncatedType.errors.txt +++ b/tests/baselines/reference/errorWithTruncatedType.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/errorWithTruncatedType.ts(10,5): error TS2322: Type '{ propertyWithAnExceedinglyLongName1: string; propertyWithAnExceedinglyLongName2: string; propert...' is not assignable to type 'string'. +tests/cases/compiler/errorWithTruncatedType.ts(10,5): error TS2322: Type '{ propertyWithAnExceedinglyLongName1: string; propertyWithAnExceedinglyLongName2: string; propertyWithAnExceedinglyLongName3: string; propertyWithAnExceedinglyLongName4: string; propertyWithAnExceedinglyLongName5: string; }' is not assignable to type 'string'. ==== tests/cases/compiler/errorWithTruncatedType.ts (1 errors) ==== @@ -13,5 +13,5 @@ tests/cases/compiler/errorWithTruncatedType.ts(10,5): error TS2322: Type '{ prop // String representation of type of 'x' should be truncated in error message var s: string = x; ~ -!!! error TS2322: Type '{ propertyWithAnExceedinglyLongName1: string; propertyWithAnExceedinglyLongName2: string; propert...' is not assignable to type 'string'. +!!! error TS2322: Type '{ propertyWithAnExceedinglyLongName1: string; propertyWithAnExceedinglyLongName2: string; propertyWithAnExceedinglyLongName3: string; propertyWithAnExceedinglyLongName4: string; propertyWithAnExceedinglyLongName5: string; }' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt index 045f02e4f36ac..3a8b56fc7e676 100644 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt @@ -5,6 +5,7 @@ tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts(1,21): error TS2449: C var before: C = new C(); ~ !!! error TS2449: Class 'C' used before its declaration. +!!! related TS2728 tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts:3:22: 'C' is declared here. export default class C { method(): C { diff --git a/tests/baselines/reference/esModuleInteropPrettyErrorRelatedInformation.errors.txt b/tests/baselines/reference/esModuleInteropPrettyErrorRelatedInformation.errors.txt index 96a31032d4dde..1d1c983162fc8 100644 --- a/tests/baselines/reference/esModuleInteropPrettyErrorRelatedInformation.errors.txt +++ b/tests/baselines/reference/esModuleInteropPrettyErrorRelatedInformation.errors.txt @@ -21,4 +21,5 @@ ~~~ !!! error TS2345: Argument of type '{ default: () => void; }' is not assignable to parameter of type '() => void'. !!! error TS2345: Type '{ default: () => void; }' provides no match for the signature '(): void'. +!!! related TS7038 tests/cases/compiler/index.ts:1:1: Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead. \ No newline at end of file diff --git a/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt b/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt index 5302f856c6f29..0da83390f8e5b 100644 --- a/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt +++ b/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt @@ -8,9 +8,7 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd Property 'id' is missing in type 'D<{}>'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(42,5): error TS2322: Type 'C' is not assignable to type 'D'. Property 'source' is missing in type 'C'. -tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(43,5): error TS2322: Type '{ id: string; }' is not assignable to type 'I'. - Types of property 'id' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(43,28): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(44,5): error TS2322: Type 'C' is not assignable to type '{ id: string; }'. Types of property 'id' are incompatible. Type 'number' is not assignable to type 'string'. @@ -93,10 +91,9 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd !!! error TS2322: Type 'C' is not assignable to type 'D'. !!! error TS2322: Property 'source' is missing in type 'C'. var anObjectLiteral: I = { id: 'a string' }; - ~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ id: string; }' is not assignable to type 'I'. -!!! error TS2322: Types of property 'id' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts:2:5: The expected type comes from property 'id' which is declared here on type 'I' var anOtherObjectLiteral: { id: string } = new C(); ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'C' is not assignable to type '{ id: string; }'. diff --git a/tests/baselines/reference/exactSpellingSuggestion.errors.txt b/tests/baselines/reference/exactSpellingSuggestion.errors.txt index dbe611590d4bc..0a36f11f01000 100644 --- a/tests/baselines/reference/exactSpellingSuggestion.errors.txt +++ b/tests/baselines/reference/exactSpellingSuggestion.errors.txt @@ -13,4 +13,5 @@ tests/cases/compiler/exactSpellingSuggestion.ts(9,4): error TS2551: Property 'bi U8.bit_2 ~~~~~ !!! error TS2551: Property 'bit_2' does not exist on type 'typeof U8'. Did you mean 'BIT_2'? +!!! related TS2728 tests/cases/compiler/exactSpellingSuggestion.ts:6:5: 'BIT_2' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.errors.txt b/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.errors.txt new file mode 100644 index 0000000000000..556885b52a36a --- /dev/null +++ b/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/usage.ts(2,8): error TS2304: Cannot find name 'decorate'. +tests/cases/compiler/usage.ts(2,31): error TS2694: Namespace 'A.B.C.D' has no exported member 'E'. + + +==== tests/cases/compiler/types.d.ts (0 errors) ==== + declare namespace A { + export namespace B { + export namespace C { + export namespace D { + } + } + } + } +==== tests/cases/compiler/usage.ts (2 errors) ==== + class Foo { + f(@decorate user: A.B.C.D.E): void {} + ~~~~~~~~ +!!! error TS2304: Cannot find name 'decorate'. + ~ +!!! error TS2694: Namespace 'A.B.C.D' has no exported member 'E'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.js b/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.js new file mode 100644 index 0000000000000..062cc48357008 --- /dev/null +++ b/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.js @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.ts] //// + +//// [types.d.ts] +declare namespace A { + export namespace B { + export namespace C { + export namespace D { + } + } + } +} +//// [usage.ts] +class Foo { + f(@decorate user: A.B.C.D.E): void {} +} + + +//// [usage.js] +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); +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +var Foo = /** @class */ (function () { + function Foo() { + } + Foo.prototype.f = function (user) { }; + var _a, _b, _c, _d; + __decorate([ + __param(0, decorate), + __metadata("design:type", Function), + __metadata("design:paramtypes", [typeof (_d = typeof A !== "undefined" && (_a = A.B) !== void 0 && (_b = _a.C) !== void 0 && (_c = _b.D) !== void 0 && _c.E) === "function" ? _d : Object]), + __metadata("design:returntype", void 0) + ], Foo.prototype, "f"); + return Foo; +}()); diff --git a/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.symbols b/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.symbols new file mode 100644 index 0000000000000..0076ba5871c25 --- /dev/null +++ b/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/types.d.ts === +declare namespace A { +>A : Symbol(A, Decl(types.d.ts, 0, 0)) + + export namespace B { +>B : Symbol(B, Decl(types.d.ts, 0, 21)) + + export namespace C { +>C : Symbol(C, Decl(types.d.ts, 1, 24)) + + export namespace D { +>D : Symbol(D, Decl(types.d.ts, 2, 28)) + } + } + } +} +=== tests/cases/compiler/usage.ts === +class Foo { +>Foo : Symbol(Foo, Decl(usage.ts, 0, 0)) + + f(@decorate user: A.B.C.D.E): void {} +>f : Symbol(Foo.f, Decl(usage.ts, 0, 11)) +>user : Symbol(user, Decl(usage.ts, 1, 6)) +>A : Symbol(A, Decl(types.d.ts, 0, 0)) +>B : Symbol(A.B, Decl(types.d.ts, 0, 21)) +>C : Symbol(A.B.C, Decl(types.d.ts, 1, 24)) +>D : Symbol(A.B.C.D, Decl(types.d.ts, 2, 28)) +} + diff --git a/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.types b/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.types new file mode 100644 index 0000000000000..22be4d18018e5 --- /dev/null +++ b/tests/baselines/reference/experimentalDecoratorMetadataUnresolvedTypeObjectInEmit.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/types.d.ts === +declare namespace A { +>A : any + + export namespace B { +>B : any + + export namespace C { +>C : any + + export namespace D { +>D : any + } + } + } +} +=== tests/cases/compiler/usage.ts === +class Foo { +>Foo : Foo + + f(@decorate user: A.B.C.D.E): void {} +>f : (user: any) => void +>decorate : any +>user : any +>A : any +>B : any +>C : any +>D : any +>E : No type information available! +} + diff --git a/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.js b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.js new file mode 100644 index 0000000000000..18011cbcc130d --- /dev/null +++ b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/exportAssignedNamespaceIsVisibleInDeclarationEmit.ts] //// + +//// [thing.d.ts] +declare namespace Foo { + export interface Bar {} + export function f(): Bar; +} +export = Foo; +//// [index.ts] +import { f } from "./thing"; +export const thing = f(); + +//// [index.js] +"use strict"; +exports.__esModule = true; +var thing_1 = require("./thing"); +exports.thing = thing_1.f(); + + +//// [index.d.ts] +export declare const thing: import("./thing").Bar; diff --git a/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.symbols b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.symbols new file mode 100644 index 0000000000000..1f5fd46cf571f --- /dev/null +++ b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/thing.d.ts === +declare namespace Foo { +>Foo : Symbol(Foo, Decl(thing.d.ts, 0, 0)) + + export interface Bar {} +>Bar : Symbol(Bar, Decl(thing.d.ts, 0, 23)) + + export function f(): Bar; +>f : Symbol(f, Decl(thing.d.ts, 1, 27)) +>Bar : Symbol(Bar, Decl(thing.d.ts, 0, 23)) +} +export = Foo; +>Foo : Symbol(Foo, Decl(thing.d.ts, 0, 0)) + +=== tests/cases/compiler/index.ts === +import { f } from "./thing"; +>f : Symbol(f, Decl(index.ts, 0, 8)) + +export const thing = f(); +>thing : Symbol(thing, Decl(index.ts, 1, 12)) +>f : Symbol(f, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.types b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.types new file mode 100644 index 0000000000000..5dfd9611ccafe --- /dev/null +++ b/tests/baselines/reference/exportAssignedNamespaceIsVisibleInDeclarationEmit.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/thing.d.ts === +declare namespace Foo { +>Foo : typeof Foo + + export interface Bar {} +>Bar : Bar + + export function f(): Bar; +>f : () => Bar +>Bar : Bar +} +export = Foo; +>Foo : typeof Foo + +=== tests/cases/compiler/index.ts === +import { f } from "./thing"; +>f : () => import("tests/cases/compiler/thing").Bar + +export const thing = f(); +>thing : import("tests/cases/compiler/thing").Bar +>f() : import("tests/cases/compiler/thing").Bar +>f : () => import("tests/cases/compiler/thing").Bar + diff --git a/tests/baselines/reference/exportAssignmentImportMergeNoCrash.errors.txt b/tests/baselines/reference/exportAssignmentImportMergeNoCrash.errors.txt index 12a7586a84882..222d52679653b 100644 --- a/tests/baselines/reference/exportAssignmentImportMergeNoCrash.errors.txt +++ b/tests/baselines/reference/exportAssignmentImportMergeNoCrash.errors.txt @@ -21,4 +21,5 @@ tests/cases/compiler/user.ts(3,25): error TS2448: Block-scoped variable 'Obj' us !!! error TS2395: Individual declarations in merged declaration 'Obj' must be all exported or all local. ~~~ !!! error TS2448: Block-scoped variable 'Obj' used before its declaration. +!!! related TS2728 tests/cases/compiler/user.ts:3:14: 'Obj' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.types b/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.types index 74efa10e4d28e..9a5d3b5bc65e7 100644 --- a/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.types +++ b/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.types @@ -3,7 +3,7 @@ export = foo; >foo : any declare namespace foo { ->foo : typeof foo +>foo : typeof import("o") export type T = number; >T : number diff --git a/tests/baselines/reference/exportBinding.errors.txt b/tests/baselines/reference/exportBinding.errors.txt index 552c048faf7a3..1225ef3aa1338 100644 --- a/tests/baselines/reference/exportBinding.errors.txt +++ b/tests/baselines/reference/exportBinding.errors.txt @@ -9,6 +9,7 @@ tests/cases/conformance/es6/modules/exportVars.ts(3,16): error TS2454: Variable export default x; ~ !!! error TS2448: Block-scoped variable 'x' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/modules/exportConsts.ts:5:7: 'x' is declared here. ~ !!! error TS2454: Variable 'x' is used before being assigned. diff --git a/tests/baselines/reference/exportDefaultVariable.types b/tests/baselines/reference/exportDefaultVariable.types index 109ff9e0f93ce..5a0a34eb4c962 100644 --- a/tests/baselines/reference/exportDefaultVariable.types +++ b/tests/baselines/reference/exportDefaultVariable.types @@ -5,7 +5,7 @@ declare var io: any; >io : any declare module 'module' { ->'module' : typeof 'module' +>'module' : typeof import("module") export default io; >io : any diff --git a/tests/baselines/reference/exportEqualsOfModule.types b/tests/baselines/reference/exportEqualsOfModule.types index 8356742f0e57c..bb7ba762c2265 100644 --- a/tests/baselines/reference/exportEqualsOfModule.types +++ b/tests/baselines/reference/exportEqualsOfModule.types @@ -1,13 +1,13 @@ === tests/cases/compiler/exportEqualsOfModule.ts === declare module '~popsicle/dist/request' { ->'~popsicle/dist/request' : typeof '~popsicle/dist/request' +>'~popsicle/dist/request' : typeof import("~popsicle/dist/request") export class Request {} >Request : Request } declare module '~popsicle/dist/common' { ->'~popsicle/dist/common' : typeof '~popsicle/dist/common' +>'~popsicle/dist/common' : typeof import("~popsicle/dist/common") import { Request } from '~popsicle/dist/request'; >Request : typeof Request @@ -17,7 +17,7 @@ declare module '~popsicle/dist/common' { } declare module 'popsicle' { ->'popsicle' : typeof 'popsicle' +>'popsicle' : typeof import("popsicle") import alias = require('~popsicle/dist/common'); >alias : typeof alias @@ -27,7 +27,7 @@ declare module 'popsicle' { } declare module 'popsicle-proxy-agent' { ->'popsicle-proxy-agent' : typeof 'popsicle-proxy-agent' +>'popsicle-proxy-agent' : typeof import("popsicle-proxy-agent") import { Request } from 'popsicle'; >Request : typeof Request diff --git a/tests/baselines/reference/exportPropertyAssignmentNameResolution.symbols b/tests/baselines/reference/exportPropertyAssignmentNameResolution.symbols index e7da3bfc2b4ea..df6d56766bcc3 100644 --- a/tests/baselines/reference/exportPropertyAssignmentNameResolution.symbols +++ b/tests/baselines/reference/exportPropertyAssignmentNameResolution.symbols @@ -1,7 +1,9 @@ === tests/cases/conformance/salsa/bug24492.js === module.exports.D = class { } +>module.exports.D : Symbol(D, Decl(bug24492.js, 0, 0)) >module.exports : Symbol(D, Decl(bug24492.js, 0, 0)) ->module : Symbol(module) +>module : Symbol(module, Decl(bug24492.js, 0, 0)) +>exports : Symbol("tests/cases/conformance/salsa/bug24492", Decl(bug24492.js, 0, 0)) >D : Symbol(D, Decl(bug24492.js, 0, 0)) new D() diff --git a/tests/baselines/reference/exportPropertyAssignmentNameResolution.types b/tests/baselines/reference/exportPropertyAssignmentNameResolution.types index 24553ae18c5d1..0cd1490c88611 100644 --- a/tests/baselines/reference/exportPropertyAssignmentNameResolution.types +++ b/tests/baselines/reference/exportPropertyAssignmentNameResolution.types @@ -1,11 +1,11 @@ === tests/cases/conformance/salsa/bug24492.js === module.exports.D = class { } >module.exports.D = class { } : typeof D ->module.exports.D : any ->module.exports : any ->module : any ->exports : any ->D : any +>module.exports.D : typeof D +>module.exports : typeof import("tests/cases/conformance/salsa/bug24492") +>module : { "tests/cases/conformance/salsa/bug24492": typeof import("tests/cases/conformance/salsa/bug24492"); } +>exports : typeof import("tests/cases/conformance/salsa/bug24492") +>D : typeof D >class { } : typeof D new D() diff --git a/tests/baselines/reference/exportSpellingSuggestion.errors.txt b/tests/baselines/reference/exportSpellingSuggestion.errors.txt index fefae723515a6..cf8011fec458e 100644 --- a/tests/baselines/reference/exportSpellingSuggestion.errors.txt +++ b/tests/baselines/reference/exportSpellingSuggestion.errors.txt @@ -10,4 +10,5 @@ tests/cases/conformance/es6/modules/b.ts(1,10): error TS2724: Module '"tests/cas import { assertNevar } from "./a"; ~~~~~~~~~~~ !!! error TS2724: Module '"tests/cases/conformance/es6/modules/a"' has no exported member 'assertNevar'. Did you mean 'assertNever'? +!!! related TS2728 tests/cases/conformance/es6/modules/a.ts:1:17: 'assertNever' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/exportedBlockScopedDeclarations.errors.txt b/tests/baselines/reference/exportedBlockScopedDeclarations.errors.txt index 06d832c86e15b..8cdcdd8cc6663 100644 --- a/tests/baselines/reference/exportedBlockScopedDeclarations.errors.txt +++ b/tests/baselines/reference/exportedBlockScopedDeclarations.errors.txt @@ -12,33 +12,41 @@ tests/cases/compiler/exportedBlockScopedDeclarations.ts(16,21): error TS2448: Bl const foo = foo; // compile error ~~~ !!! error TS2448: Block-scoped variable 'foo' used before its declaration. +!!! related TS2728 tests/cases/compiler/exportedBlockScopedDeclarations.ts:1:7: 'foo' is declared here. export const bar = bar; // should be compile error ~~~ !!! error TS2448: Block-scoped variable 'bar' used before its declaration. +!!! related TS2728 tests/cases/compiler/exportedBlockScopedDeclarations.ts:2:14: 'bar' is declared here. function f() { const bar = bar; // compile error ~~~ !!! error TS2448: Block-scoped variable 'bar' used before its declaration. +!!! related TS2728 tests/cases/compiler/exportedBlockScopedDeclarations.ts:4:9: 'bar' is declared here. } namespace NS { export const bar = bar; // should be compile error ~~~ !!! error TS2448: Block-scoped variable 'bar' used before its declaration. +!!! related TS2728 tests/cases/compiler/exportedBlockScopedDeclarations.ts:7:16: 'bar' is declared here. } let foo1 = foo1; // compile error ~~~~ !!! error TS2448: Block-scoped variable 'foo1' used before its declaration. +!!! related TS2728 tests/cases/compiler/exportedBlockScopedDeclarations.ts:10:5: 'foo1' is declared here. export let bar1 = bar1; // should be compile error ~~~~ !!! error TS2448: Block-scoped variable 'bar1' used before its declaration. +!!! related TS2728 tests/cases/compiler/exportedBlockScopedDeclarations.ts:11:12: 'bar1' is declared here. function f1() { let bar1 = bar1; // compile error ~~~~ !!! error TS2448: Block-scoped variable 'bar1' used before its declaration. +!!! related TS2728 tests/cases/compiler/exportedBlockScopedDeclarations.ts:13:7: 'bar1' is declared here. } namespace NS1 { export let bar1 = bar1; // should be compile error ~~~~ !!! error TS2448: Block-scoped variable 'bar1' used before its declaration. +!!! related TS2728 tests/cases/compiler/exportedBlockScopedDeclarations.ts:16:14: 'bar1' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/expr.errors.txt b/tests/baselines/reference/expr.errors.txt index 23215cac6bae2..05e9ad9c3b476 100644 --- a/tests/baselines/reference/expr.errors.txt +++ b/tests/baselines/reference/expr.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/expr.ts(87,5): error TS2365: Operator '==' cannot be applied to types 'number' and 'string'. -tests/cases/compiler/expr.ts(88,5): error TS2365: Operator '==' cannot be applied to types 'number' and 'boolean'. -tests/cases/compiler/expr.ts(94,5): error TS2365: Operator '==' cannot be applied to types 'string' and 'number'. -tests/cases/compiler/expr.ts(95,5): error TS2365: Operator '==' cannot be applied to types 'string' and 'boolean'. -tests/cases/compiler/expr.ts(98,5): error TS2365: Operator '==' cannot be applied to types 'string' and 'E'. -tests/cases/compiler/expr.ts(115,5): error TS2365: Operator '==' cannot be applied to types 'E' and 'string'. -tests/cases/compiler/expr.ts(116,5): error TS2365: Operator '==' cannot be applied to types 'E' and 'false'. +tests/cases/compiler/expr.ts(87,5): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. +tests/cases/compiler/expr.ts(88,5): error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. +tests/cases/compiler/expr.ts(94,5): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +tests/cases/compiler/expr.ts(95,5): error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. +tests/cases/compiler/expr.ts(98,5): error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. +tests/cases/compiler/expr.ts(115,5): error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +tests/cases/compiler/expr.ts(116,5): error TS2367: This condition will always return 'false' since the types 'E' and 'false' have no overlap. tests/cases/compiler/expr.ts(142,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'false'. tests/cases/compiler/expr.ts(143,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'I'. tests/cases/compiler/expr.ts(161,5): error TS2365: Operator '+' cannot be applied to types 'I' and 'number'. @@ -158,10 +158,10 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari n==a; n==s; ~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'number' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. n==b; ~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'number' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. n==i; n==n; n==e; @@ -169,15 +169,15 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari s==a; s==n; ~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'string' and 'number'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. s==b; ~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'string' and 'boolean'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. s==i; s==s; s==e; ~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'string' and 'E'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. a==n; a==s; @@ -196,10 +196,10 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari e==n; e==s; ~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'E' and 'string'. +!!! error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. e==b; ~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'E' and 'false'. +!!! error TS2367: This condition will always return 'false' since the types 'E' and 'false' have no overlap. e==a; e==i; e==e; diff --git a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt index 64e5c7d3ef34c..c4de998333adc 100644 --- a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt +++ b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt @@ -5,5 +5,6 @@ tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts(1,23): error TS2449: Cl class derived extends base { } ~~~~ !!! error TS2449: Class 'base' used before its declaration. +!!! related TS2728 tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts:3:7: 'base' is declared here. class base { constructor (public n: number) { } } \ No newline at end of file diff --git a/tests/baselines/reference/extendingSetWithCheckJs.symbols b/tests/baselines/reference/extendingSetWithCheckJs.symbols new file mode 100644 index 0000000000000..63bc853976373 --- /dev/null +++ b/tests/baselines/reference/extendingSetWithCheckJs.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/extendingSetWithCheckJs.ts === +class MySet extends Set { +>MySet : Symbol(MySet, Decl(extendingSetWithCheckJs.ts, 0, 0)) +>Set : Symbol(Set, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + constructor() { + super(); +>super : Symbol(SetConstructor, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + } +} + +class MyWeakSet extends WeakSet { +>MyWeakSet : Symbol(MyWeakSet, Decl(extendingSetWithCheckJs.ts, 4, 1)) +>WeakSet : Symbol(WeakSet, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + constructor() { + super(); +>super : Symbol(WeakSetConstructor, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + } +} + +class MyMap extends Map { +>MyMap : Symbol(MyMap, Decl(extendingSetWithCheckJs.ts, 10, 1)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + constructor() { + super(); +>super : Symbol(MapConstructor, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + } +} + +class MyWeakMap extends WeakMap { +>MyWeakMap : Symbol(MyWeakMap, Decl(extendingSetWithCheckJs.ts, 16, 1)) +>WeakMap : Symbol(WeakMap, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + constructor() { + super(); +>super : Symbol(WeakMapConstructor, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + } +} diff --git a/tests/baselines/reference/extendingSetWithCheckJs.types b/tests/baselines/reference/extendingSetWithCheckJs.types new file mode 100644 index 0000000000000..dd10731e023ae --- /dev/null +++ b/tests/baselines/reference/extendingSetWithCheckJs.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/extendingSetWithCheckJs.ts === +class MySet extends Set { +>MySet : MySet +>Set : Set + + constructor() { + super(); +>super() : void +>super : SetConstructor + } +} + +class MyWeakSet extends WeakSet { +>MyWeakSet : MyWeakSet +>WeakSet : WeakSet + + constructor() { + super(); +>super() : void +>super : WeakSetConstructor + } +} + +class MyMap extends Map { +>MyMap : MyMap +>Map : Map + + constructor() { + super(); +>super() : void +>super : MapConstructor + } +} + +class MyWeakMap extends WeakMap { +>MyWeakMap : MyWeakMap +>WeakMap : WeakMap + + constructor() { + super(); +>super() : void +>super : WeakMapConstructor + } +} diff --git a/tests/baselines/reference/externModule.errors.txt b/tests/baselines/reference/externModule.errors.txt index d6659c1d548ca..329ef0a8862dc 100644 --- a/tests/baselines/reference/externModule.errors.txt +++ b/tests/baselines/reference/externModule.errors.txt @@ -69,16 +69,20 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat var d=new XDate(); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? +!!! related TS2728 /.ts/lib.es5.d.ts:837:15: 'Date' is declared here. d.getDay(); d=new XDate(1978,2); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? +!!! related TS2728 /.ts/lib.es5.d.ts:837:15: 'Date' is declared here. d.getXDate(); var n=XDate.parse("3/2/2004"); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? +!!! related TS2728 /.ts/lib.es5.d.ts:837:15: 'Date' is declared here. n=XDate.UTC(1964,2,1); ~~~~~ !!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'? +!!! related TS2728 /.ts/lib.es5.d.ts:837:15: 'Date' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/externalModuleReferenceDoubleUnderscore1.types b/tests/baselines/reference/externalModuleReferenceDoubleUnderscore1.types index 5452c6afcbb44..ec4e07af5e055 100644 --- a/tests/baselines/reference/externalModuleReferenceDoubleUnderscore1.types +++ b/tests/baselines/reference/externalModuleReferenceDoubleUnderscore1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/externalModuleReferenceDoubleUnderscore1.ts === declare module 'timezonecomplete' { ->'timezonecomplete' : typeof 'timezonecomplete' +>'timezonecomplete' : typeof import("timezonecomplete") import basics = require("__timezonecomplete/basics"); >basics : typeof basics @@ -12,7 +12,7 @@ declare module 'timezonecomplete' { } declare module '__timezonecomplete/basics' { ->'__timezonecomplete/basics' : typeof '__timezonecomplete/basics' +>'__timezonecomplete/basics' : typeof import("__timezonecomplete/basics") export enum TimeUnit { >TimeUnit : TimeUnit diff --git a/tests/baselines/reference/extractConstant/extractConstant_ExpressionStatementInNestedScope.js b/tests/baselines/reference/extractConstant/extractConstant_ExpressionStatementInNestedScope.js index 23cdfee82812a..2813287690332 100644 --- a/tests/baselines/reference/extractConstant/extractConstant_ExpressionStatementInNestedScope.js +++ b/tests/baselines/reference/extractConstant/extractConstant_ExpressionStatementInNestedScope.js @@ -17,6 +17,5 @@ function F() { let i = 0; const /*RENAME*/newLocal = i++; function F() { - } \ No newline at end of file diff --git a/tests/baselines/reference/extractConstant/extractConstant_ExpressionStatementInNestedScope.ts b/tests/baselines/reference/extractConstant/extractConstant_ExpressionStatementInNestedScope.ts index 23cdfee82812a..2813287690332 100644 --- a/tests/baselines/reference/extractConstant/extractConstant_ExpressionStatementInNestedScope.ts +++ b/tests/baselines/reference/extractConstant/extractConstant_ExpressionStatementInNestedScope.ts @@ -17,6 +17,5 @@ function F() { let i = 0; const /*RENAME*/newLocal = i++; function F() { - } \ No newline at end of file diff --git a/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt b/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt index a47ea077d95d8..efe6e0985894c 100644 --- a/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt +++ b/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(4,16): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(5,16): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(6,9): error TS2365: Operator '===' cannot be applied to types 'string' and 'number'. +tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(6,9): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(8,16): error TS2339: Property 'unknownProperty' does not exist on type 'string'. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(12,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'number', but here has type 'string'. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(16,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'j' must be of type 'any', but here has type 'string'. @@ -18,7 +18,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors. !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. if (x === 1) { ~~~~~~~ -!!! error TS2365: Operator '===' cannot be applied to types 'string' and 'number'. +!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. } let a3 = x.unknownProperty; ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/for-of55.errors.txt b/tests/baselines/reference/for-of55.errors.txt index aa1285afbd6ce..74d55636bfe8c 100644 --- a/tests/baselines/reference/for-of55.errors.txt +++ b/tests/baselines/reference/for-of55.errors.txt @@ -6,5 +6,6 @@ tests/cases/conformance/es6/for-ofStatements/for-of55.ts(2,15): error TS2448: Bl for (let v of v) { ~ !!! error TS2448: Block-scoped variable 'v' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/for-ofStatements/for-of55.ts:2:10: 'v' is declared here. v; } \ No newline at end of file diff --git a/tests/baselines/reference/forwardRefInClassProperties.errors.txt b/tests/baselines/reference/forwardRefInClassProperties.errors.txt index dcf153076ed63..1958791804eba 100644 --- a/tests/baselines/reference/forwardRefInClassProperties.errors.txt +++ b/tests/baselines/reference/forwardRefInClassProperties.errors.txt @@ -1,5 +1,5 @@ -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(3,15): error TS2729: Property '_a' is used before its initialization. +tests/cases/compiler/forwardRefInClassProperties.ts(6,22): error TS2729: Property '_A' is used before its initialization. tests/cases/compiler/forwardRefInClassProperties.ts(11,17): error TS2448: Block-scoped variable 'b' used before its declaration. @@ -8,19 +8,22 @@ tests/cases/compiler/forwardRefInClassProperties.ts(11,17): error TS2448: Block- { _b = this._a; // undefined, no error/warning ~~ -!!! error TS2448: Block-scoped variable '_a' used before its declaration. +!!! error TS2729: Property '_a' is used before its initialization. +!!! related TS2728 tests/cases/compiler/forwardRefInClassProperties.ts:4:5: '_a' is declared here. _a = 3; static _B = Test._A; // undefined, no error/warning ~~ -!!! error TS2448: Block-scoped variable '_A' used before its declaration. +!!! error TS2729: Property '_A' is used before its initialization. +!!! related TS2728 tests/cases/compiler/forwardRefInClassProperties.ts:7:12: '_A' is declared here. static _A = 3; method() { - let a = b; // Block-scoped variable 'b' used before its declaration + let a = b; // Property 'b' is used before its initialization. ~ !!! error TS2448: Block-scoped variable 'b' used before its declaration. +!!! related TS2728 tests/cases/compiler/forwardRefInClassProperties.ts:12:13: 'b' is declared here. let b = 3; } } diff --git a/tests/baselines/reference/forwardRefInClassProperties.js b/tests/baselines/reference/forwardRefInClassProperties.js index 48cbd4af6f771..02e53e708b934 100644 --- a/tests/baselines/reference/forwardRefInClassProperties.js +++ b/tests/baselines/reference/forwardRefInClassProperties.js @@ -9,7 +9,7 @@ class Test method() { - let a = b; // Block-scoped variable 'b' used before its declaration + let a = b; // Property 'b' is used before its initialization. let b = 3; } } @@ -22,7 +22,7 @@ var Test = /** @class */ (function () { this._a = 3; } Test.prototype.method = function () { - var a = b; // Block-scoped variable 'b' used before its declaration + var a = b; // Property 'b' is used before its initialization. var b = 3; }; Test._B = Test._A; // undefined, no error/warning diff --git a/tests/baselines/reference/forwardRefInClassProperties.symbols b/tests/baselines/reference/forwardRefInClassProperties.symbols index bef27dd78868b..e55d767714548 100644 --- a/tests/baselines/reference/forwardRefInClassProperties.symbols +++ b/tests/baselines/reference/forwardRefInClassProperties.symbols @@ -23,7 +23,7 @@ class Test method() >method : Symbol(Test.method, Decl(forwardRefInClassProperties.ts, 6, 18)) { - let a = b; // Block-scoped variable 'b' used before its declaration + let a = b; // Property 'b' is used before its initialization. >a : Symbol(a, Decl(forwardRefInClassProperties.ts, 10, 11)) >b : Symbol(b, Decl(forwardRefInClassProperties.ts, 11, 11)) diff --git a/tests/baselines/reference/forwardRefInClassProperties.types b/tests/baselines/reference/forwardRefInClassProperties.types index d5dc9495b7076..ccfa071e43ef7 100644 --- a/tests/baselines/reference/forwardRefInClassProperties.types +++ b/tests/baselines/reference/forwardRefInClassProperties.types @@ -25,7 +25,7 @@ class Test method() >method : () => void { - let a = b; // Block-scoped variable 'b' used before its declaration + let a = b; // Property 'b' is used before its initialization. >a : number >b : number diff --git a/tests/baselines/reference/functionParameterArityMismatch.errors.txt b/tests/baselines/reference/functionParameterArityMismatch.errors.txt new file mode 100644 index 0000000000000..07c9c8845c68e --- /dev/null +++ b/tests/baselines/reference/functionParameterArityMismatch.errors.txt @@ -0,0 +1,39 @@ +tests/cases/compiler/functionParameterArityMismatch.ts(3,1): error TS2554: Expected 1-3 arguments, but got 0. +tests/cases/compiler/functionParameterArityMismatch.ts(4,1): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 3 arguments. +tests/cases/compiler/functionParameterArityMismatch.ts(5,1): error TS2554: Expected 1-3 arguments, but got 4. +tests/cases/compiler/functionParameterArityMismatch.ts(11,1): error TS2575: No overload expects 1 arguments, but overloads do exist that expect either 0 or 2 arguments. +tests/cases/compiler/functionParameterArityMismatch.ts(12,1): error TS2575: No overload expects 3 arguments, but overloads do exist that expect either 2 or 4 arguments. +tests/cases/compiler/functionParameterArityMismatch.ts(13,1): error TS2575: No overload expects 5 arguments, but overloads do exist that expect either 4 or 6 arguments. +tests/cases/compiler/functionParameterArityMismatch.ts(14,1): error TS2554: Expected 0-6 arguments, but got 7. + + +==== tests/cases/compiler/functionParameterArityMismatch.ts (7 errors) ==== + declare function f1(a: number); + declare function f1(a: number, b: number, c: number); + f1(); + ~~~~ +!!! error TS2554: Expected 1-3 arguments, but got 0. + f1(1, 2); + ~~~~~~~~ +!!! error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 3 arguments. + f1(1, 2, 3, 4); + ~~~~~~~~~~~~~~ +!!! error TS2554: Expected 1-3 arguments, but got 4. + + declare function f2(); + declare function f2(a: number, b: number); + declare function f2(a: number, b: number, c: number, d: number); + declare function f2(a: number, b: number, c: number, d: number, e: number, f: number); + f2(1); + ~~~~~ +!!! error TS2575: No overload expects 1 arguments, but overloads do exist that expect either 0 or 2 arguments. + f2(1, 2, 3); + ~~~~~~~~~~~ +!!! error TS2575: No overload expects 3 arguments, but overloads do exist that expect either 2 or 4 arguments. + f2(1, 2, 3, 4, 5); + ~~~~~~~~~~~~~~~~~ +!!! error TS2575: No overload expects 5 arguments, but overloads do exist that expect either 4 or 6 arguments. + f2(1, 2, 3, 4, 5, 6, 7); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 0-6 arguments, but got 7. + \ No newline at end of file diff --git a/tests/baselines/reference/functionParameterArityMismatch.js b/tests/baselines/reference/functionParameterArityMismatch.js new file mode 100644 index 0000000000000..cfbe27d5f29e5 --- /dev/null +++ b/tests/baselines/reference/functionParameterArityMismatch.js @@ -0,0 +1,25 @@ +//// [functionParameterArityMismatch.ts] +declare function f1(a: number); +declare function f1(a: number, b: number, c: number); +f1(); +f1(1, 2); +f1(1, 2, 3, 4); + +declare function f2(); +declare function f2(a: number, b: number); +declare function f2(a: number, b: number, c: number, d: number); +declare function f2(a: number, b: number, c: number, d: number, e: number, f: number); +f2(1); +f2(1, 2, 3); +f2(1, 2, 3, 4, 5); +f2(1, 2, 3, 4, 5, 6, 7); + + +//// [functionParameterArityMismatch.js] +f1(); +f1(1, 2); +f1(1, 2, 3, 4); +f2(1); +f2(1, 2, 3); +f2(1, 2, 3, 4, 5); +f2(1, 2, 3, 4, 5, 6, 7); diff --git a/tests/baselines/reference/functionParameterArityMismatch.symbols b/tests/baselines/reference/functionParameterArityMismatch.symbols new file mode 100644 index 0000000000000..5615ac694ef25 --- /dev/null +++ b/tests/baselines/reference/functionParameterArityMismatch.symbols @@ -0,0 +1,56 @@ +=== tests/cases/compiler/functionParameterArityMismatch.ts === +declare function f1(a: number); +>f1 : Symbol(f1, Decl(functionParameterArityMismatch.ts, 0, 0), Decl(functionParameterArityMismatch.ts, 0, 31)) +>a : Symbol(a, Decl(functionParameterArityMismatch.ts, 0, 20)) + +declare function f1(a: number, b: number, c: number); +>f1 : Symbol(f1, Decl(functionParameterArityMismatch.ts, 0, 0), Decl(functionParameterArityMismatch.ts, 0, 31)) +>a : Symbol(a, Decl(functionParameterArityMismatch.ts, 1, 20)) +>b : Symbol(b, Decl(functionParameterArityMismatch.ts, 1, 30)) +>c : Symbol(c, Decl(functionParameterArityMismatch.ts, 1, 41)) + +f1(); +>f1 : Symbol(f1, Decl(functionParameterArityMismatch.ts, 0, 0), Decl(functionParameterArityMismatch.ts, 0, 31)) + +f1(1, 2); +>f1 : Symbol(f1, Decl(functionParameterArityMismatch.ts, 0, 0), Decl(functionParameterArityMismatch.ts, 0, 31)) + +f1(1, 2, 3, 4); +>f1 : Symbol(f1, Decl(functionParameterArityMismatch.ts, 0, 0), Decl(functionParameterArityMismatch.ts, 0, 31)) + +declare function f2(); +>f2 : Symbol(f2, Decl(functionParameterArityMismatch.ts, 4, 15), Decl(functionParameterArityMismatch.ts, 6, 22), Decl(functionParameterArityMismatch.ts, 7, 42), Decl(functionParameterArityMismatch.ts, 8, 64)) + +declare function f2(a: number, b: number); +>f2 : Symbol(f2, Decl(functionParameterArityMismatch.ts, 4, 15), Decl(functionParameterArityMismatch.ts, 6, 22), Decl(functionParameterArityMismatch.ts, 7, 42), Decl(functionParameterArityMismatch.ts, 8, 64)) +>a : Symbol(a, Decl(functionParameterArityMismatch.ts, 7, 20)) +>b : Symbol(b, Decl(functionParameterArityMismatch.ts, 7, 30)) + +declare function f2(a: number, b: number, c: number, d: number); +>f2 : Symbol(f2, Decl(functionParameterArityMismatch.ts, 4, 15), Decl(functionParameterArityMismatch.ts, 6, 22), Decl(functionParameterArityMismatch.ts, 7, 42), Decl(functionParameterArityMismatch.ts, 8, 64)) +>a : Symbol(a, Decl(functionParameterArityMismatch.ts, 8, 20)) +>b : Symbol(b, Decl(functionParameterArityMismatch.ts, 8, 30)) +>c : Symbol(c, Decl(functionParameterArityMismatch.ts, 8, 41)) +>d : Symbol(d, Decl(functionParameterArityMismatch.ts, 8, 52)) + +declare function f2(a: number, b: number, c: number, d: number, e: number, f: number); +>f2 : Symbol(f2, Decl(functionParameterArityMismatch.ts, 4, 15), Decl(functionParameterArityMismatch.ts, 6, 22), Decl(functionParameterArityMismatch.ts, 7, 42), Decl(functionParameterArityMismatch.ts, 8, 64)) +>a : Symbol(a, Decl(functionParameterArityMismatch.ts, 9, 20)) +>b : Symbol(b, Decl(functionParameterArityMismatch.ts, 9, 30)) +>c : Symbol(c, Decl(functionParameterArityMismatch.ts, 9, 41)) +>d : Symbol(d, Decl(functionParameterArityMismatch.ts, 9, 52)) +>e : Symbol(e, Decl(functionParameterArityMismatch.ts, 9, 63)) +>f : Symbol(f, Decl(functionParameterArityMismatch.ts, 9, 74)) + +f2(1); +>f2 : Symbol(f2, Decl(functionParameterArityMismatch.ts, 4, 15), Decl(functionParameterArityMismatch.ts, 6, 22), Decl(functionParameterArityMismatch.ts, 7, 42), Decl(functionParameterArityMismatch.ts, 8, 64)) + +f2(1, 2, 3); +>f2 : Symbol(f2, Decl(functionParameterArityMismatch.ts, 4, 15), Decl(functionParameterArityMismatch.ts, 6, 22), Decl(functionParameterArityMismatch.ts, 7, 42), Decl(functionParameterArityMismatch.ts, 8, 64)) + +f2(1, 2, 3, 4, 5); +>f2 : Symbol(f2, Decl(functionParameterArityMismatch.ts, 4, 15), Decl(functionParameterArityMismatch.ts, 6, 22), Decl(functionParameterArityMismatch.ts, 7, 42), Decl(functionParameterArityMismatch.ts, 8, 64)) + +f2(1, 2, 3, 4, 5, 6, 7); +>f2 : Symbol(f2, Decl(functionParameterArityMismatch.ts, 4, 15), Decl(functionParameterArityMismatch.ts, 6, 22), Decl(functionParameterArityMismatch.ts, 7, 42), Decl(functionParameterArityMismatch.ts, 8, 64)) + diff --git a/tests/baselines/reference/functionParameterArityMismatch.types b/tests/baselines/reference/functionParameterArityMismatch.types new file mode 100644 index 0000000000000..f7117a2eef3c4 --- /dev/null +++ b/tests/baselines/reference/functionParameterArityMismatch.types @@ -0,0 +1,85 @@ +=== tests/cases/compiler/functionParameterArityMismatch.ts === +declare function f1(a: number); +>f1 : { (a: number): any; (a: number, b: number, c: number): any; } +>a : number + +declare function f1(a: number, b: number, c: number); +>f1 : { (a: number): any; (a: number, b: number, c: number): any; } +>a : number +>b : number +>c : number + +f1(); +>f1() : any +>f1 : { (a: number): any; (a: number, b: number, c: number): any; } + +f1(1, 2); +>f1(1, 2) : any +>f1 : { (a: number): any; (a: number, b: number, c: number): any; } +>1 : 1 +>2 : 2 + +f1(1, 2, 3, 4); +>f1(1, 2, 3, 4) : any +>f1 : { (a: number): any; (a: number, b: number, c: number): any; } +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + +declare function f2(); +>f2 : { (): any; (a: number, b: number): any; (a: number, b: number, c: number, d: number): any; (a: number, b: number, c: number, d: number, e: number, f: number): any; } + +declare function f2(a: number, b: number); +>f2 : { (): any; (a: number, b: number): any; (a: number, b: number, c: number, d: number): any; (a: number, b: number, c: number, d: number, e: number, f: number): any; } +>a : number +>b : number + +declare function f2(a: number, b: number, c: number, d: number); +>f2 : { (): any; (a: number, b: number): any; (a: number, b: number, c: number, d: number): any; (a: number, b: number, c: number, d: number, e: number, f: number): any; } +>a : number +>b : number +>c : number +>d : number + +declare function f2(a: number, b: number, c: number, d: number, e: number, f: number); +>f2 : { (): any; (a: number, b: number): any; (a: number, b: number, c: number, d: number): any; (a: number, b: number, c: number, d: number, e: number, f: number): any; } +>a : number +>b : number +>c : number +>d : number +>e : number +>f : number + +f2(1); +>f2(1) : any +>f2 : { (): any; (a: number, b: number): any; (a: number, b: number, c: number, d: number): any; (a: number, b: number, c: number, d: number, e: number, f: number): any; } +>1 : 1 + +f2(1, 2, 3); +>f2(1, 2, 3) : any +>f2 : { (): any; (a: number, b: number): any; (a: number, b: number, c: number, d: number): any; (a: number, b: number, c: number, d: number, e: number, f: number): any; } +>1 : 1 +>2 : 2 +>3 : 3 + +f2(1, 2, 3, 4, 5); +>f2(1, 2, 3, 4, 5) : any +>f2 : { (): any; (a: number, b: number): any; (a: number, b: number, c: number, d: number): any; (a: number, b: number, c: number, d: number, e: number, f: number): any; } +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 + +f2(1, 2, 3, 4, 5, 6, 7); +>f2(1, 2, 3, 4, 5, 6, 7) : any +>f2 : { (): any; (a: number, b: number): any; (a: number, b: number, c: number, d: number): any; (a: number, b: number, c: number, d: number, e: number, f: number): any; } +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>6 : 6 +>7 : 7 + diff --git a/tests/baselines/reference/fuzzy.errors.txt b/tests/baselines/reference/fuzzy.errors.txt index c3f05fd7f2f04..173683297f983 100644 --- a/tests/baselines/reference/fuzzy.errors.txt +++ b/tests/baselines/reference/fuzzy.errors.txt @@ -1,9 +1,7 @@ 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,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'. +tests/cases/compiler/fuzzy.ts(21,34): error TS2322: Type 'this' is not assignable to type 'I'. + Type 'C' is not assignable to type 'I'. tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' cannot be converted to type 'R'. Property 'anything' is missing in type '{ oneI: this; }'. @@ -33,11 +31,10 @@ 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'. -!!! error TS2322: Type 'C' is not assignable to type 'I'. + ~~~~ +!!! error TS2322: Type 'this' is not assignable to type 'I'. +!!! error TS2322: Type 'C' is not assignable to type 'I'. +!!! related TS6500 tests/cases/compiler/fuzzy.ts:10:9: The expected type comes from property 'oneI' which is declared here on type 'R' } worksToo():R { diff --git a/tests/baselines/reference/genericAssignmentCompatWithInterfaces1.errors.txt b/tests/baselines/reference/genericAssignmentCompatWithInterfaces1.errors.txt index 63679ff03b74d..cd035498740d1 100644 --- a/tests/baselines/reference/genericAssignmentCompatWithInterfaces1.errors.txt +++ b/tests/baselines/reference/genericAssignmentCompatWithInterfaces1.errors.txt @@ -1,10 +1,8 @@ -tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts(12,5): error TS2322: Type '{ x: A; }' is not assignable to type 'I'. - Types of property 'x' are incompatible. - Type 'A' is not assignable to type 'Comparable'. - Types of property 'compareTo' are incompatible. - Type '(other: number) => number' is not assignable to type '(other: string) => number'. - Types of parameters 'other' and 'other' are incompatible. - Type 'string' is not assignable to type 'number'. +tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts(12,23): error TS2322: Type 'A' is not assignable to type 'Comparable'. + Types of property 'compareTo' are incompatible. + Type '(other: number) => number' is not assignable to type '(other: string) => number'. + Types of parameters 'other' and 'other' are incompatible. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts(13,5): error TS2322: Type '{ x: A; }' is not assignable to type 'I'. Types of property 'x' are incompatible. Type 'A' is not assignable to type 'Comparable'. @@ -29,14 +27,13 @@ tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts(17,5): error TS23 class A implements Comparable { compareTo(other: T) { return 1; } } var z = { x: new A() }; var a1: I = { x: new A() }; - ~~ -!!! error TS2322: Type '{ x: A; }' is not assignable to type 'I'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'A' is not assignable to type 'Comparable'. -!!! error TS2322: Types of property 'compareTo' are incompatible. -!!! error TS2322: Type '(other: number) => number' is not assignable to type '(other: string) => number'. -!!! error TS2322: Types of parameters 'other' and 'other' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. + ~ +!!! error TS2322: Type 'A' is not assignable to type 'Comparable'. +!!! error TS2322: Types of property 'compareTo' are incompatible. +!!! error TS2322: Type '(other: number) => number' is not assignable to type '(other: string) => number'. +!!! error TS2322: Types of parameters 'other' and 'other' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! related TS6500 tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts:5:5: The expected type comes from property 'x' which is declared here on type 'I' var a2: I = function (): { x: A } { ~~ !!! error TS2322: Type '{ x: A; }' is not assignable to type 'I'. diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index 65920596c456b..1136022e2fe42 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -3,15 +3,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup Type '4' is not assignable to type '2'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,1): error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'. Type '{ a: string; }' is not assignable to type 'number'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. - Type '{}' is not assignable to type 'string'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,14): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,17): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,14): error TS2322: Type '{}' is not assignable to type 'string'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,18): error TS2322: Type '{}' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(24,1): error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. Property '1' is missing in type '[{}]'. -==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts (5 errors) ==== +==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts (7 errors) ==== interface I { tuple1: [T, U]; } @@ -41,13 +41,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup // error i1.tuple1 = [5, "foo"]; - ~~~~~~~~~ -!!! error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + ~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. i1.tuple1 = [{}, {}]; - ~~~~~~~~~ -!!! error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. -!!! error TS2322: Type '{}' is not assignable to type 'string'. + ~~ +!!! error TS2322: Type '{}' is not assignable to type 'string'. + ~~ +!!! error TS2322: Type '{}' is not assignable to type 'number'. i2.tuple1 = [{}]; ~~~~~~~~~ !!! error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt index d259a2d2e27be..d11f49bbec9e2 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt @@ -6,9 +6,11 @@ tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(2,20) class A extends B { } ~ !!! error TS2449: Class 'B' used before its declaration. +!!! related TS2728 tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts:2:7: 'B' is declared here. class B extends C { } ~ !!! error TS2449: Class 'C' used before its declaration. +!!! related TS2728 tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts:3:7: 'C' is declared here. class C { constructor(p: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/genericRestArity.errors.txt b/tests/baselines/reference/genericRestArity.errors.txt new file mode 100644 index 0000000000000..71b814e324fab --- /dev/null +++ b/tests/baselines/reference/genericRestArity.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/types/rest/genericRestArity.ts(7,1): error TS2554: Expected 3 arguments, but got 1. +tests/cases/conformance/types/rest/genericRestArity.ts(8,1): error TS2554: Expected 3 arguments, but got 8. + + +==== tests/cases/conformance/types/rest/genericRestArity.ts (2 errors) ==== + // Repro from #25559 + + declare function call( + handler: (...args: TS) => void, + ...args: TS): void; + + call((x: number, y: number) => x + y); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 3 arguments, but got 1. + call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 3 arguments, but got 8. + \ No newline at end of file diff --git a/tests/baselines/reference/genericRestArity.js b/tests/baselines/reference/genericRestArity.js new file mode 100644 index 0000000000000..a59ab66e1a8ad --- /dev/null +++ b/tests/baselines/reference/genericRestArity.js @@ -0,0 +1,15 @@ +//// [genericRestArity.ts] +// Repro from #25559 + +declare function call( + handler: (...args: TS) => void, + ...args: TS): void; + +call((x: number, y: number) => x + y); +call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); + + +//// [genericRestArity.js] +// Repro from #25559 +call(function (x, y) { return x + y; }); +call(function (x, y) { return x + y; }, 1, 2, 3, 4, 5, 6, 7); diff --git a/tests/baselines/reference/genericRestArity.symbols b/tests/baselines/reference/genericRestArity.symbols new file mode 100644 index 0000000000000..6529235602923 --- /dev/null +++ b/tests/baselines/reference/genericRestArity.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/types/rest/genericRestArity.ts === +// Repro from #25559 + +declare function call( +>call : Symbol(call, Decl(genericRestArity.ts, 0, 0)) +>TS : Symbol(TS, Decl(genericRestArity.ts, 2, 22)) + + handler: (...args: TS) => void, +>handler : Symbol(handler, Decl(genericRestArity.ts, 2, 44)) +>args : Symbol(args, Decl(genericRestArity.ts, 3, 14)) +>TS : Symbol(TS, Decl(genericRestArity.ts, 2, 22)) + + ...args: TS): void; +>args : Symbol(args, Decl(genericRestArity.ts, 3, 35)) +>TS : Symbol(TS, Decl(genericRestArity.ts, 2, 22)) + +call((x: number, y: number) => x + y); +>call : Symbol(call, Decl(genericRestArity.ts, 0, 0)) +>x : Symbol(x, Decl(genericRestArity.ts, 6, 6)) +>y : Symbol(y, Decl(genericRestArity.ts, 6, 16)) +>x : Symbol(x, Decl(genericRestArity.ts, 6, 6)) +>y : Symbol(y, Decl(genericRestArity.ts, 6, 16)) + +call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); +>call : Symbol(call, Decl(genericRestArity.ts, 0, 0)) +>x : Symbol(x, Decl(genericRestArity.ts, 7, 6)) +>y : Symbol(y, Decl(genericRestArity.ts, 7, 16)) +>x : Symbol(x, Decl(genericRestArity.ts, 7, 6)) +>y : Symbol(y, Decl(genericRestArity.ts, 7, 16)) + diff --git a/tests/baselines/reference/genericRestArity.types b/tests/baselines/reference/genericRestArity.types new file mode 100644 index 0000000000000..61bd75d947012 --- /dev/null +++ b/tests/baselines/reference/genericRestArity.types @@ -0,0 +1,43 @@ +=== tests/cases/conformance/types/rest/genericRestArity.ts === +// Repro from #25559 + +declare function call( +>call : (handler: (...args: TS) => void, ...args: TS) => void +>TS : TS + + handler: (...args: TS) => void, +>handler : (...args: TS) => void +>args : TS +>TS : TS + + ...args: TS): void; +>args : TS +>TS : TS + +call((x: number, y: number) => x + y); +>call((x: number, y: number) => x + y) : any +>call : (handler: (...args: TS) => void, ...args: TS) => void +>(x: number, y: number) => x + y : (x: number, y: number) => number +>x : number +>y : number +>x + y : number +>x : number +>y : number + +call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); +>call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7) : any +>call : (handler: (...args: TS) => void, ...args: TS) => void +>(x: number, y: number) => x + y : (x: number, y: number) => number +>x : number +>y : number +>x + y : number +>x : number +>y : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>6 : 6 +>7 : 7 + diff --git a/tests/baselines/reference/genericRestArityStrict.errors.txt b/tests/baselines/reference/genericRestArityStrict.errors.txt new file mode 100644 index 0000000000000..9a77f8d8498f6 --- /dev/null +++ b/tests/baselines/reference/genericRestArityStrict.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/types/rest/genericRestArityStrict.ts(7,6): error TS2345: Argument of type '(x: number, y: number) => number' is not assignable to parameter of type '() => void'. + + +==== tests/cases/conformance/types/rest/genericRestArityStrict.ts (1 errors) ==== + // Repro from #25559 + + declare function call( + handler: (...args: TS) => void, + ...args: TS): void; + + call((x: number, y: number) => x + y); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(x: number, y: number) => number' is not assignable to parameter of type '() => void'. + call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); + \ No newline at end of file diff --git a/tests/baselines/reference/genericRestArityStrict.js b/tests/baselines/reference/genericRestArityStrict.js new file mode 100644 index 0000000000000..5628eada2f563 --- /dev/null +++ b/tests/baselines/reference/genericRestArityStrict.js @@ -0,0 +1,16 @@ +//// [genericRestArityStrict.ts] +// Repro from #25559 + +declare function call( + handler: (...args: TS) => void, + ...args: TS): void; + +call((x: number, y: number) => x + y); +call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); + + +//// [genericRestArityStrict.js] +"use strict"; +// Repro from #25559 +call(function (x, y) { return x + y; }); +call(function (x, y) { return x + y; }, 1, 2, 3, 4, 5, 6, 7); diff --git a/tests/baselines/reference/genericRestArityStrict.symbols b/tests/baselines/reference/genericRestArityStrict.symbols new file mode 100644 index 0000000000000..df51a85f95dbf --- /dev/null +++ b/tests/baselines/reference/genericRestArityStrict.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/types/rest/genericRestArityStrict.ts === +// Repro from #25559 + +declare function call( +>call : Symbol(call, Decl(genericRestArityStrict.ts, 0, 0)) +>TS : Symbol(TS, Decl(genericRestArityStrict.ts, 2, 22)) + + handler: (...args: TS) => void, +>handler : Symbol(handler, Decl(genericRestArityStrict.ts, 2, 44)) +>args : Symbol(args, Decl(genericRestArityStrict.ts, 3, 14)) +>TS : Symbol(TS, Decl(genericRestArityStrict.ts, 2, 22)) + + ...args: TS): void; +>args : Symbol(args, Decl(genericRestArityStrict.ts, 3, 35)) +>TS : Symbol(TS, Decl(genericRestArityStrict.ts, 2, 22)) + +call((x: number, y: number) => x + y); +>call : Symbol(call, Decl(genericRestArityStrict.ts, 0, 0)) +>x : Symbol(x, Decl(genericRestArityStrict.ts, 6, 6)) +>y : Symbol(y, Decl(genericRestArityStrict.ts, 6, 16)) +>x : Symbol(x, Decl(genericRestArityStrict.ts, 6, 6)) +>y : Symbol(y, Decl(genericRestArityStrict.ts, 6, 16)) + +call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); +>call : Symbol(call, Decl(genericRestArityStrict.ts, 0, 0)) +>x : Symbol(x, Decl(genericRestArityStrict.ts, 7, 6)) +>y : Symbol(y, Decl(genericRestArityStrict.ts, 7, 16)) +>x : Symbol(x, Decl(genericRestArityStrict.ts, 7, 6)) +>y : Symbol(y, Decl(genericRestArityStrict.ts, 7, 16)) + diff --git a/tests/baselines/reference/genericRestArityStrict.types b/tests/baselines/reference/genericRestArityStrict.types new file mode 100644 index 0000000000000..53c784d093848 --- /dev/null +++ b/tests/baselines/reference/genericRestArityStrict.types @@ -0,0 +1,43 @@ +=== tests/cases/conformance/types/rest/genericRestArityStrict.ts === +// Repro from #25559 + +declare function call( +>call : (handler: (...args: TS) => void, ...args: TS) => void +>TS : TS + + handler: (...args: TS) => void, +>handler : (...args: TS) => void +>args : TS +>TS : TS + + ...args: TS): void; +>args : TS +>TS : TS + +call((x: number, y: number) => x + y); +>call((x: number, y: number) => x + y) : any +>call : (handler: (...args: TS) => void, ...args: TS) => void +>(x: number, y: number) => x + y : (x: number, y: number) => number +>x : number +>y : number +>x + y : number +>x : number +>y : number + +call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); +>call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7) : void +>call : (handler: (...args: TS) => void, ...args: TS) => void +>(x: number, y: number) => x + y : (x: number, y: number) => number +>x : number +>y : number +>x + y : number +>x : number +>y : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>6 : 6 +>7 : 7 + diff --git a/tests/baselines/reference/genericRestTypes.js b/tests/baselines/reference/genericRestTypes.js new file mode 100644 index 0000000000000..f932032af56c3 --- /dev/null +++ b/tests/baselines/reference/genericRestTypes.js @@ -0,0 +1,19 @@ +//// [genericRestTypes.ts] +// Repro from #25793 + +// Gets the parameters of a function type as a tuple +type Parameters any> = T extends (...args: infer U) => any ? U : never; +// Removes the first element from a tuple +type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; + +type MyFunctionType = (foo: number, bar: string) => boolean; + +type Explicit = (...args: Tail>) => ReturnType; // (bar: string) => boolean + +type Bind1 any> = (...args: Tail>) => ReturnType; +type Generic = Bind1; // (bar: string) => boolean + + +//// [genericRestTypes.js] +"use strict"; +// Repro from #25793 diff --git a/tests/baselines/reference/genericRestTypes.symbols b/tests/baselines/reference/genericRestTypes.symbols new file mode 100644 index 0000000000000..77bc400b5dbbd --- /dev/null +++ b/tests/baselines/reference/genericRestTypes.symbols @@ -0,0 +1,55 @@ +=== tests/cases/compiler/genericRestTypes.ts === +// Repro from #25793 + +// Gets the parameters of a function type as a tuple +type Parameters any> = T extends (...args: infer U) => any ? U : never; +>Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) +>T : Symbol(T, Decl(genericRestTypes.ts, 3, 16)) +>args : Symbol(args, Decl(genericRestTypes.ts, 3, 27)) +>T : Symbol(T, Decl(genericRestTypes.ts, 3, 16)) +>args : Symbol(args, Decl(genericRestTypes.ts, 3, 64)) +>U : Symbol(U, Decl(genericRestTypes.ts, 3, 78)) +>U : Symbol(U, Decl(genericRestTypes.ts, 3, 78)) + +// Removes the first element from a tuple +type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) +>T : Symbol(T, Decl(genericRestTypes.ts, 5, 10)) +>args : Symbol(args, Decl(genericRestTypes.ts, 5, 31)) +>T : Symbol(T, Decl(genericRestTypes.ts, 5, 10)) +>head : Symbol(head, Decl(genericRestTypes.ts, 5, 61)) +>tail : Symbol(tail, Decl(genericRestTypes.ts, 5, 71)) +>U : Symbol(U, Decl(genericRestTypes.ts, 5, 86)) +>U : Symbol(U, Decl(genericRestTypes.ts, 5, 86)) + +type MyFunctionType = (foo: number, bar: string) => boolean; +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) +>foo : Symbol(foo, Decl(genericRestTypes.ts, 7, 23)) +>bar : Symbol(bar, Decl(genericRestTypes.ts, 7, 35)) + +type Explicit = (...args: Tail>) => ReturnType; // (bar: string) => boolean +>Explicit : Symbol(Explicit, Decl(genericRestTypes.ts, 7, 60)) +>args : Symbol(args, Decl(genericRestTypes.ts, 9, 17)) +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) +>Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) + +type Bind1 any> = (...args: Tail>) => ReturnType; +>Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 9, 90)) +>T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) +>head : Symbol(head, Decl(genericRestTypes.ts, 11, 22)) +>tail : Symbol(tail, Decl(genericRestTypes.ts, 11, 32)) +>args : Symbol(args, Decl(genericRestTypes.ts, 11, 60)) +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) +>Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) +>T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) + +type Generic = Bind1; // (bar: string) => boolean +>Generic : Symbol(Generic, Decl(genericRestTypes.ts, 11, 107)) +>Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 9, 90)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) + diff --git a/tests/baselines/reference/genericRestTypes.types b/tests/baselines/reference/genericRestTypes.types new file mode 100644 index 0000000000000..6fc523bd7c92a --- /dev/null +++ b/tests/baselines/reference/genericRestTypes.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/genericRestTypes.ts === +// Repro from #25793 + +// Gets the parameters of a function type as a tuple +type Parameters any> = T extends (...args: infer U) => any ? U : never; +>Parameters : Parameters +>T : T +>args : any[] +>T : T +>args : U +>U : U +>U : U + +// Removes the first element from a tuple +type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; +>Tail : Tail +>T : T +>args : T +>T : T +>head : any +>tail : U +>U : U +>U : U + +type MyFunctionType = (foo: number, bar: string) => boolean; +>MyFunctionType : MyFunctionType +>foo : number +>bar : string + +type Explicit = (...args: Tail>) => ReturnType; // (bar: string) => boolean +>Explicit : Explicit +>args : [string] +>Tail : Tail +>Parameters : Parameters +>MyFunctionType : MyFunctionType +>ReturnType : ReturnType +>MyFunctionType : MyFunctionType + +type Bind1 any> = (...args: Tail>) => ReturnType; +>Bind1 : Bind1 +>T : T +>head : any +>tail : any[] +>args : Tail> +>Tail : Tail +>Parameters : Parameters +>T : T +>ReturnType : ReturnType +>T : T + +type Generic = Bind1; // (bar: string) => boolean +>Generic : Bind1 +>Bind1 : Bind1 +>MyFunctionType : MyFunctionType + diff --git a/tests/baselines/reference/getEmitOutput-pp.baseline b/tests/baselines/reference/getEmitOutput-pp.baseline index 82243870b2940..d3e9e977f58a7 100644 --- a/tests/baselines/reference/getEmitOutput-pp.baseline +++ b/tests/baselines/reference/getEmitOutput-pp.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/shims-pp/inputFile1.js var x = 5; var Bar = /** @class */ (function () { @@ -6,6 +7,7 @@ var Bar = /** @class */ (function () { } return Bar; }()); + FileName : /tests/cases/fourslash/shims-pp/inputFile1.d.ts declare var x: number; declare class Bar { @@ -14,6 +16,7 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/shims-pp/inputFile2.js var x1 = "hello world"; var Foo = /** @class */ (function () { @@ -21,6 +24,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : /tests/cases/fourslash/shims-pp/inputFile2.d.ts declare var x1: string; declare class Foo { diff --git a/tests/baselines/reference/getEmitOutput.baseline b/tests/baselines/reference/getEmitOutput.baseline index 9fa32d4dfe89a..1b029eefd126d 100644 --- a/tests/baselines/reference/getEmitOutput.baseline +++ b/tests/baselines/reference/getEmitOutput.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/shims/inputFile1.js var x = 5; var Bar = /** @class */ (function () { @@ -6,6 +7,7 @@ var Bar = /** @class */ (function () { } return Bar; }()); + FileName : /tests/cases/fourslash/shims/inputFile1.d.ts declare var x: number; declare class Bar { @@ -14,6 +16,7 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/shims/inputFile2.js var x1 = "hello world"; var Foo = /** @class */ (function () { @@ -21,6 +24,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : /tests/cases/fourslash/shims/inputFile2.d.ts declare var x1: string; declare class Foo { diff --git a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline index ac2d4850bb426..9208d6fb4f915 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js var x = 5; var Bar = /** @class */ (function () { @@ -6,6 +7,7 @@ var Bar = /** @class */ (function () { } return Bar; }()); + FileName : /tests/cases/fourslash/inputFile1.d.ts declare var x: number; declare class Bar { @@ -14,6 +16,7 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js var x1 = "hello world"; var Foo = /** @class */ (function () { @@ -21,6 +24,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : /tests/cases/fourslash/inputFile2.d.ts declare var x1: string; declare class Foo { diff --git a/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline b/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline index 18e8920ba72ee..0e19223306afe 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingleFile.js var x = 5; var Bar = /** @class */ (function () { @@ -12,6 +13,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : declSingleFile.d.ts declare var x: number; declare class Bar { diff --git a/tests/baselines/reference/getEmitOutputExternalModule.baseline b/tests/baselines/reference/getEmitOutputExternalModule.baseline index bd4162854f870..c577fb5679233 100644 --- a/tests/baselines/reference/getEmitOutputExternalModule.baseline +++ b/tests/baselines/reference/getEmitOutputExternalModule.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingleFile.js var x = 5; var Bar = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputExternalModule2.baseline b/tests/baselines/reference/getEmitOutputExternalModule2.baseline index 3aff8629acf4e..dfbe9bf061d71 100644 --- a/tests/baselines/reference/getEmitOutputExternalModule2.baseline +++ b/tests/baselines/reference/getEmitOutputExternalModule2.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingleFile.js var x = 5; var Bar = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputMapRoots.baseline b/tests/baselines/reference/getEmitOutputMapRoots.baseline index 4b4a9b0395bd7..67a136a3456fd 100644 --- a/tests/baselines/reference/getEmitOutputMapRoots.baseline +++ b/tests/baselines/reference/getEmitOutputMapRoots.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : declSingleFile.js.map -{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : declSingleFile.js +{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : declSingleFile.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputNoErrors.baseline b/tests/baselines/reference/getEmitOutputNoErrors.baseline index 8cf9b0f143d93..8dea3c96fe61d 100644 --- a/tests/baselines/reference/getEmitOutputNoErrors.baseline +++ b/tests/baselines/reference/getEmitOutputNoErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var x; var M = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline index b913e00e7984d..e37174aa2323c 100644 --- a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline +++ b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js var x; var Foo = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputOut.baseline b/tests/baselines/reference/getEmitOutputOut.baseline index 9508b6d55708e..26bb4e1b69328 100644 --- a/tests/baselines/reference/getEmitOutputOut.baseline +++ b/tests/baselines/reference/getEmitOutputOut.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : out.js /// var foo; diff --git a/tests/baselines/reference/getEmitOutputOutFile.baseline b/tests/baselines/reference/getEmitOutputOutFile.baseline index c683d963f0e4d..ce3454c4ed404 100644 --- a/tests/baselines/reference/getEmitOutputOutFile.baseline +++ b/tests/baselines/reference/getEmitOutputOutFile.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : outFile.js var x = 5; var Bar = /** @class */ (function () { @@ -12,6 +13,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : outFile.d.ts declare var x: number; declare class Bar { diff --git a/tests/baselines/reference/getEmitOutputSingleFile.baseline b/tests/baselines/reference/getEmitOutputSingleFile.baseline index fd370667bc529..929cd9d7a7dfa 100644 --- a/tests/baselines/reference/getEmitOutputSingleFile.baseline +++ b/tests/baselines/reference/getEmitOutputSingleFile.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : outputDir/singleFile.js var x; var Bar = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputSingleFile2.baseline b/tests/baselines/reference/getEmitOutputSingleFile2.baseline index 18e8920ba72ee..0e19223306afe 100644 --- a/tests/baselines/reference/getEmitOutputSingleFile2.baseline +++ b/tests/baselines/reference/getEmitOutputSingleFile2.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingleFile.js var x = 5; var Bar = /** @class */ (function () { @@ -12,6 +13,7 @@ var Foo = /** @class */ (function () { } return Foo; }()); + FileName : declSingleFile.d.ts declare var x: number; declare class Bar { diff --git a/tests/baselines/reference/getEmitOutputSourceMap.baseline b/tests/baselines/reference/getEmitOutputSourceMap.baseline index e1e65087e6d49..5ef3f843b236b 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js.map -{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile.js +{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputSourceMap2.baseline b/tests/baselines/reference/getEmitOutputSourceMap2.baseline index ccd11b1fec01c..f9a3455ba774f 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap2.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap2.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : sample/outDir/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : sample/outDir/inputFile1.js +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : sample/outDir/inputFile1.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { @@ -10,8 +12,10 @@ var M = /** @class */ (function () { }()); //# sourceMappingURL=inputFile1.js.map EmitSkipped: false + FileName : sample/outDir/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,IAAI,KAAK,KAAK,SAAS,EAAE;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC;CACb"}FileName : sample/outDir/inputFile2.js +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,IAAI,KAAK,KAAK,SAAS,EAAE;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC;CACb"} +FileName : sample/outDir/inputFile2.js var intro = "hello world"; if (intro !== undefined) { var k = 10; diff --git a/tests/baselines/reference/getEmitOutputSourceRoot.baseline b/tests/baselines/reference/getEmitOutputSourceRoot.baseline index ddd6568b70439..a5185984a6ff6 100644 --- a/tests/baselines/reference/getEmitOutputSourceRoot.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRoot.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js.map -{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile.js +{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline index f6d9cb184e64a..a8013f697ca90 100644 --- a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js +{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile1.js var x = 109; var foo = "hello world"; var M = /** @class */ (function () { @@ -10,8 +12,10 @@ var M = /** @class */ (function () { }()); //# sourceMappingURL=inputFile1.js.map EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile2.js +{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile2.js var bar = "hello world Typescript"; var C = /** @class */ (function () { function C() { diff --git a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline index 5a04550370805..0e15fe43aca59 100644 --- a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline +++ b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile1.js // regular ts file var t = 5; var Bar = /** @class */ (function () { @@ -8,7 +10,8 @@ var Bar = /** @class */ (function () { } return Bar; }()); -//# sourceMappingURL=inputFile1.js.mapFileName : /tests/cases/fourslash/inputFile1.d.ts +//# sourceMappingURL=inputFile1.js.map +FileName : /tests/cases/fourslash/inputFile1.d.ts declare var t: number; declare class Bar { x: string; @@ -16,11 +19,14 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.jsx.map -{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : /tests/cases/fourslash/inputFile2.jsx +{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"} +FileName : /tests/cases/fourslash/inputFile2.jsx var y = "my div"; var x =
; -//# sourceMappingURL=inputFile2.jsx.mapFileName : /tests/cases/fourslash/inputFile2.d.ts +//# sourceMappingURL=inputFile2.jsx.map +FileName : /tests/cases/fourslash/inputFile2.d.ts declare var y: string; declare var x: any; diff --git a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline index 4f5b8f65d2257..071d18992ea30 100644 --- a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline +++ b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"} +FileName : /tests/cases/fourslash/inputFile1.js // regular ts file var t = 5; var Bar = /** @class */ (function () { @@ -8,7 +10,8 @@ var Bar = /** @class */ (function () { } return Bar; }()); -//# sourceMappingURL=inputFile1.js.mapFileName : /tests/cases/fourslash/inputFile1.d.ts +//# sourceMappingURL=inputFile1.js.map +FileName : /tests/cases/fourslash/inputFile1.d.ts declare var t: number; declare class Bar { x: string; @@ -16,11 +19,14 @@ declare class Bar { } EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,6BAAK,IAAI,EAAG,CAAC,GAAI,CAAA"}FileName : /tests/cases/fourslash/inputFile2.js +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,6BAAK,IAAI,EAAG,CAAC,GAAI,CAAA"} +FileName : /tests/cases/fourslash/inputFile2.js var y = "my div"; var x = React.createElement("div", { name: y }); -//# sourceMappingURL=inputFile2.js.mapFileName : /tests/cases/fourslash/inputFile2.d.ts +//# sourceMappingURL=inputFile2.js.map +FileName : /tests/cases/fourslash/inputFile2.d.ts declare var React: any; declare var y: string; declare var x: any; diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline index fa07a2af00ec0..0176f4b628ffb 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline @@ -1,6 +1,7 @@ EmitSkipped: false EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js var x1 = "hello world"; var Foo = /** @class */ (function () { diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline index b22067dc31809..86a6519b4b0b7 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline @@ -1,6 +1,7 @@ EmitSkipped: false EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile2.js "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -12,6 +13,7 @@ var Foo = /** @class */ (function () { exports.Foo = Foo; EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile3.js var x = "hello"; diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline index 1ce3d9f33c3b1..cd1f2739e3326 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : declSingle.js var x = "hello"; var x1 = 1000; diff --git a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline index 6609554a299ae..b011e5885e3ab 100644 --- a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js // File contains early errors. All outputs should be skipped. var uninitialized_const_error; diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline index d2b26ca48c89b..7ad60f361bb01 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var M; (function (M) { @@ -9,6 +10,7 @@ var M; }()); M.foo = new C(); })(M || (M = {})); + FileName : /tests/cases/fourslash/inputFile.d.ts declare module M { class C { diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline index 77131f89dd5ef..46ba9652cc7db 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js define(["require", "exports"], function (require, exports) { "use strict"; @@ -13,6 +14,7 @@ define(["require", "exports"], function (require, exports) { M.foo = new C(); })(M = exports.M || (exports.M = {})); }); + FileName : /tests/cases/fourslash/inputFile.d.ts class C { } diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline index 55a58ea041f34..7ada814a55e89 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var x = "hello world"; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline index b5848da34570e..739ef23319140 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline @@ -1,6 +1,8 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var x = "hello world"; + FileName : /tests/cases/fourslash/inputFile.d.ts declare var x: number; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline index 4c22a7e3f9386..2fb3cdd921059 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline @@ -1,8 +1,10 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js // File to emit, does not contain semantic errors // expected to be emitted correctelly regardless of the semantic errors in the other file var noErrors = true; + FileName : /tests/cases/fourslash/inputFile1.d.ts declare var noErrors: boolean; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline index 6a58015c1b3bc..0d5ab3f674741 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline @@ -1,10 +1,12 @@ EmitSkipped: false + FileName : out.js // File to emit, does not contain semantic errors, but --out is passed // expected to not generate declarations because of the semantic errors in the other file var noErrors = true; // File not emitted, and contains semantic errors var semanticError = "string"; + FileName : out.d.ts declare var noErrors: boolean; declare var semanticError: boolean; diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline index f51782cc75d5c..1ec89e66d5a55 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile1.js // File to emit, does not contain syntactic errors // expected to be emitted correctelly regardless of the syntactic errors in the other file diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline index 0f526b85b4f6e..f429d4e1295c2 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : out.js // File to emit, does not contain syntactic errors, but --out is passed // expected to not generate outputs because of the syntactic errors in the other file. diff --git a/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline b/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline index 8aa81ba60ce6a..f84b9e810c93c 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline @@ -1,4 +1,5 @@ EmitSkipped: false + FileName : /tests/cases/fourslash/inputFile.js var x; diff --git a/tests/baselines/reference/importTypeAmbientMissing.errors.txt b/tests/baselines/reference/importTypeAmbientMissing.errors.txt index 99743a05100f0..89beac01c37c0 100644 --- a/tests/baselines/reference/importTypeAmbientMissing.errors.txt +++ b/tests/baselines/reference/importTypeAmbientMissing.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/import/importTypeAmbientMissing.ts(8,10): error TS2307: Cannot find module 'fo'. +tests/cases/conformance/types/import/importTypeAmbientMissing.ts(8,17): error TS2307: Cannot find module 'fo'. ==== tests/cases/conformance/types/import/importTypeAmbientMissing.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/types/import/importTypeAmbientMissing.ts(8,10): error TS export = Point; } const x: import("fo") = { x: 0, y: 0 }; // typo, error - ~~~~~~~~~~~~ + ~~~~ !!! error TS2307: Cannot find module 'fo'. \ No newline at end of file diff --git a/tests/baselines/reference/importTypeInJSDoc.types b/tests/baselines/reference/importTypeInJSDoc.types index d76f7aac6f614..3f905c967b87f 100644 --- a/tests/baselines/reference/importTypeInJSDoc.types +++ b/tests/baselines/reference/importTypeInJSDoc.types @@ -59,8 +59,8 @@ a = new Foo({doer: Foo.Bar}); >Bar : (x: string, y?: number) => void const q = /** @type {import("./externs").Bar} */({ doer: q => q }); ->q : MyClass.Bar ->({ doer: q => q }) : MyClass.Bar +>q : import("tests/cases/conformance/types/import/externs").Bar +>({ doer: q => q }) : import("tests/cases/conformance/types/import/externs").Bar >{ doer: q => q } : { doer: (q: string) => string; } >doer : (q: string) => string >q => q : (q: string) => string diff --git a/tests/baselines/reference/importTypeLocalMissing.errors.txt b/tests/baselines/reference/importTypeLocalMissing.errors.txt index 82b813668eaf6..7c5081aa99576 100644 --- a/tests/baselines/reference/importTypeLocalMissing.errors.txt +++ b/tests/baselines/reference/importTypeLocalMissing.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/import/usage.ts(1,17): error TS2307: Cannot find module './fo'. -tests/cases/conformance/types/import/usage.ts(2,15): error TS2307: Cannot find module './fo2'. +tests/cases/conformance/types/import/usage.ts(1,24): error TS2307: Cannot find module './fo'. +tests/cases/conformance/types/import/usage.ts(2,22): error TS2307: Cannot find module './fo2'. tests/cases/conformance/types/import/usage.ts(3,36): error TS2694: Namespace '"tests/cases/conformance/types/import/foo2".Bar' has no exported member 'Q'. -tests/cases/conformance/types/import/usage.ts(10,18): error TS2307: Cannot find module './fo2'. +tests/cases/conformance/types/import/usage.ts(10,32): error TS2307: Cannot find module './fo2'. ==== tests/cases/conformance/types/import/foo.ts (0 errors) ==== @@ -34,10 +34,10 @@ tests/cases/conformance/types/import/usage.ts(10,18): error TS2307: Cannot find ==== tests/cases/conformance/types/import/usage.ts (4 errors) ==== export const x: import("./fo") = { x: 0, y: 0 }; - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS2307: Cannot find module './fo'. export let y: import("./fo2").Bar.I = { a: "", b: 0 }; - ~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS2307: Cannot find module './fo2'. export let z: import("./foo2").Bar.Q = { a: "", b: 0 }; ~ @@ -49,7 +49,7 @@ tests/cases/conformance/types/import/usage.ts(10,18): error TS2307: Cannot find } export let shim: typeof import("./fo2") = { - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS2307: Cannot find module './fo2'. Bar: Bar2 }; diff --git a/tests/baselines/reference/importUsedAsTypeWithErrors.errors.txt b/tests/baselines/reference/importUsedAsTypeWithErrors.errors.txt new file mode 100644 index 0000000000000..7d86ce7624ad0 --- /dev/null +++ b/tests/baselines/reference/importUsedAsTypeWithErrors.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/main.ts(1,17): error TS1340: Module './test' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./test')'? + + +==== tests/cases/compiler/test.ts (0 errors) ==== + export interface T { + value: string + } + +==== tests/cases/compiler/main.ts (1 errors) ==== + export const a: import("./test") = null; + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './test' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./test')'? + \ No newline at end of file diff --git a/tests/baselines/reference/importUsedAsTypeWithErrors.js b/tests/baselines/reference/importUsedAsTypeWithErrors.js new file mode 100644 index 0000000000000..add7e6b28521b --- /dev/null +++ b/tests/baselines/reference/importUsedAsTypeWithErrors.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/importUsedAsTypeWithErrors.ts] //// + +//// [test.ts] +export interface T { + value: string +} + +//// [main.ts] +export const a: import("./test") = null; + + +//// [test.js] +"use strict"; +exports.__esModule = true; +//// [main.js] +"use strict"; +exports.__esModule = true; +exports.a = null; diff --git a/tests/baselines/reference/importUsedAsTypeWithErrors.symbols b/tests/baselines/reference/importUsedAsTypeWithErrors.symbols new file mode 100644 index 0000000000000..b6d4017ea6c57 --- /dev/null +++ b/tests/baselines/reference/importUsedAsTypeWithErrors.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/test.ts === +export interface T { +>T : Symbol(T, Decl(test.ts, 0, 0)) + + value: string +>value : Symbol(T.value, Decl(test.ts, 0, 20)) +} + +=== tests/cases/compiler/main.ts === +export const a: import("./test") = null; +>a : Symbol(a, Decl(main.ts, 0, 12)) + diff --git a/tests/baselines/reference/importUsedAsTypeWithErrors.types b/tests/baselines/reference/importUsedAsTypeWithErrors.types new file mode 100644 index 0000000000000..a41de4f658e48 --- /dev/null +++ b/tests/baselines/reference/importUsedAsTypeWithErrors.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/test.ts === +export interface T { +>T : T + + value: string +>value : string +} + +=== tests/cases/compiler/main.ts === +export const a: import("./test") = null; +>a : any +>null : null + diff --git a/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.errors.txt b/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.errors.txt index 5300c97a576a6..ac068bfba74c3 100644 --- a/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.errors.txt +++ b/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.errors.txt @@ -1,11 +1,17 @@ +tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts(2,24): error TS2313: Type parameter 'T' has a circular constraint. tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts(2,32): error TS2313: Type parameter 'P' has a circular constraint. +tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts(3,5): error TS2365: Operator '+=' cannot be applied to types 'number' and 'T[K]'. -==== tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts (1 errors) ==== +==== tests/cases/compiler/incorrectRecursiveMappedTypeConstraint.ts (3 errors) ==== // #17847 function sum(n: number, v: T, k: K) { + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2313: Type parameter 'T' has a circular constraint. ~ !!! error TS2313: Type parameter 'P' has a circular constraint. n += v[k]; + ~~~~~~~~~ +!!! error TS2365: Operator '+=' cannot be applied to types 'number' and 'T[K]'. } \ No newline at end of file diff --git a/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.types b/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.types index b658995621655..a388d2b536bd8 100644 --- a/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.types +++ b/tests/baselines/reference/incorrectRecursiveMappedTypeConstraint.types @@ -14,7 +14,7 @@ function sum(n: number, v: T, >K : K n += v[k]; ->n += v[k] : number +>n += v[k] : any >n : number >v[k] : T[K] >v : T diff --git a/tests/baselines/reference/indexedAccessImplicitlyAny.errors.txt b/tests/baselines/reference/indexedAccessImplicitlyAny.errors.txt index ae950b5e69c35..70901726b6732 100644 --- a/tests/baselines/reference/indexedAccessImplicitlyAny.errors.txt +++ b/tests/baselines/reference/indexedAccessImplicitlyAny.errors.txt @@ -8,6 +8,7 @@ tests/cases/compiler/indexedAccessImplicitlyAny.ts(4,3): error TS2551: Property i.foo; ~~~ !!! error TS2551: Property 'foo' does not exist on type 'I'. Did you mean 'foof'? +!!! related TS2728 tests/cases/compiler/indexedAccessImplicitlyAny.ts:1:15: 'foof' is declared here. i["foo"]; ~~~~~ !!! error TS2551: Property 'foo' does not exist on type 'I'. Did you mean 'foof'? \ No newline at end of file diff --git a/tests/baselines/reference/indirectSelfReference.errors.txt b/tests/baselines/reference/indirectSelfReference.errors.txt index 0339dd8ed08aa..45ed557244a84 100644 --- a/tests/baselines/reference/indirectSelfReference.errors.txt +++ b/tests/baselines/reference/indirectSelfReference.errors.txt @@ -9,6 +9,7 @@ tests/cases/compiler/indirectSelfReference.ts(2,7): error TS2506: 'b' is referen !!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. ~ !!! error TS2449: Class 'b' used before its declaration. +!!! related TS2728 tests/cases/compiler/indirectSelfReference.ts:2:7: 'b' is declared here. class b extends a{ } ~ !!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt index d1cdbf1da580f..db0c5d8c97587 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt @@ -9,6 +9,7 @@ tests/cases/compiler/indirectSelfReferenceGeneric.ts(2,7): error TS2506: 'b' is !!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. ~ !!! error TS2449: Class 'b' used before its declaration. +!!! related TS2728 tests/cases/compiler/indirectSelfReferenceGeneric.ts:2:7: 'b' is declared here. class b extends a { } ~ !!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/infinitelyExpandingTypes1.errors.txt b/tests/baselines/reference/infinitelyExpandingTypes1.errors.txt index e188c8da45f64..af21b4c12bd99 100644 --- a/tests/baselines/reference/infinitelyExpandingTypes1.errors.txt +++ b/tests/baselines/reference/infinitelyExpandingTypes1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/infinitelyExpandingTypes1.ts(21,1): error TS2365: Operator '==' cannot be applied to types 'List' and 'List'. +tests/cases/compiler/infinitelyExpandingTypes1.ts(21,1): error TS2367: This condition will always return 'false' since the types 'List' and 'List' have no overlap. ==== tests/cases/compiler/infinitelyExpandingTypes1.ts (1 errors) ==== @@ -24,6 +24,6 @@ tests/cases/compiler/infinitelyExpandingTypes1.ts(21,1): error TS2365: Operator l == l2; // should error; ~~~~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'List' and 'List'. +!!! error TS2367: This condition will always return 'false' since the types 'List' and 'List' have no overlap. l == l; // should not error \ No newline at end of file diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.errors.txt b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.errors.txt index b4f6fcd9157b7..40cc18accd81a 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.errors.txt +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.errors.txt @@ -6,7 +6,6 @@ tests/cases/conformance/jsx/inline/index.tsx(21,22): error TS2322: Type '{ child Types of property 'children' are incompatible. Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element[]' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element[]'. Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element'. -tests/cases/conformance/jsx/inline/index.tsx(21,40): error TS2605: JSX element type 'MyClass' is not a constructor function for JSX elements. tests/cases/conformance/jsx/inline/index.tsx(21,40): error TS2605: JSX element type 'MyClass' is not a constructor function for JSX elements. Property '__domBrand' is missing in type 'MyClass'. tests/cases/conformance/jsx/inline/index.tsx(21,63): error TS2605: JSX element type 'MyClass' is not a constructor function for JSX elements. @@ -77,7 +76,7 @@ tests/cases/conformance/jsx/inline/index.tsx(24,23): error TS2322: Type '{ child export default -==== tests/cases/conformance/jsx/inline/index.tsx (7 errors) ==== +==== tests/cases/conformance/jsx/inline/index.tsx (6 errors) ==== /** @jsx dom */ import { dom } from "./renderer" import prerendered, {MySFC, MyClass, tree} from "./component"; @@ -111,8 +110,6 @@ tests/cases/conformance/jsx/inline/index.tsx(24,23): error TS2322: Type '{ child !!! error TS2322: Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element[]' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element[]'. !!! error TS2322: Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element'. ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2605: JSX element type 'MyClass' is not a constructor function for JSX elements. - ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2605: JSX element type 'MyClass' is not a constructor function for JSX elements. !!! error TS2605: Property '__domBrand' is missing in type 'MyClass'. ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/invalidTypeOfTarget.errors.txt b/tests/baselines/reference/invalidTypeOfTarget.errors.txt index 04bf724e4b968..b6da9a1eb7767 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.errors.txt +++ b/tests/baselines/reference/invalidTypeOfTarget.errors.txt @@ -36,6 +36,7 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts var x7: typeof function f() { }; ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? +!!! related TS2728 /.ts/lib.es5.d.ts:316:15: 'Function' is declared here. ~ !!! error TS1005: ',' expected. ~ diff --git a/tests/baselines/reference/iterableArrayPattern16.errors.txt b/tests/baselines/reference/iterableArrayPattern16.errors.txt index ba5531a0a54b5..b07d8c976a506 100644 --- a/tests/baselines/reference/iterableArrayPattern16.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern16.errors.txt @@ -14,6 +14,7 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,12): error !!! error TS2345: Property '0' is missing in type 'FooIterator'. ~~~~~~~~~~~~~~~~~~~ !!! error TS2449: Class 'FooIteratorIterator' used before its declaration. +!!! related TS2728 tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts:18:7: 'FooIteratorIterator' is declared here. class Bar { x } class Foo extends Bar { y } class FooIterator { diff --git a/tests/baselines/reference/javascriptCommonjsModule.symbols b/tests/baselines/reference/javascriptCommonjsModule.symbols index 923e0b3467b9f..da5d60593f4c9 100644 --- a/tests/baselines/reference/javascriptCommonjsModule.symbols +++ b/tests/baselines/reference/javascriptCommonjsModule.symbols @@ -7,6 +7,7 @@ class Bar extends Foo {} >Foo : Symbol(Foo, Decl(index.js, 0, 0)) module.exports = Bar; +>module.exports : Symbol("tests/cases/compiler/index", Decl(index.js, 0, 0)) >module : Symbol(export=, Decl(index.js, 2, 24)) >exports : Symbol(export=, Decl(index.js, 2, 24)) >Bar : Symbol(Bar, Decl(index.js, 0, 12)) diff --git a/tests/baselines/reference/javascriptCommonjsModule.types b/tests/baselines/reference/javascriptCommonjsModule.types index 88126ce473727..feee6cb3ddf95 100644 --- a/tests/baselines/reference/javascriptCommonjsModule.types +++ b/tests/baselines/reference/javascriptCommonjsModule.types @@ -8,8 +8,8 @@ class Bar extends Foo {} module.exports = Bar; >module.exports = Bar : typeof Bar ->module.exports : any ->module : any ->exports : any +>module.exports : typeof Bar +>module : { "tests/cases/compiler/index": typeof Bar; } +>exports : typeof Bar >Bar : typeof Bar diff --git a/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.symbols b/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.symbols index 6cb2e235ce2cd..3b1f9b780f996 100644 --- a/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.symbols +++ b/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.symbols @@ -1,5 +1,6 @@ === tests/cases/compiler/foo.js === module.exports = function () { +>module.exports : Symbol("tests/cases/compiler/foo", Decl(foo.js, 0, 0)) >module : Symbol(export=, Decl(foo.js, 0, 0)) >exports : Symbol(export=, Decl(foo.js, 0, 0)) diff --git a/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.types b/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.types index fc1fad7f8611b..08378166f7c7a 100644 --- a/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.types +++ b/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.types @@ -1,9 +1,9 @@ === tests/cases/compiler/foo.js === module.exports = function () { >module.exports = function () { class A { } return { c: A.b = 1, }} : () => { [x: string]: any; c: number; } ->module.exports : any ->module : any ->exports : any +>module.exports : () => { [x: string]: any; c: number; } +>module : { "tests/cases/compiler/foo": () => { [x: string]: any; c: number; }; } +>exports : () => { [x: string]: any; c: number; } >function () { class A { } return { c: A.b = 1, }} : () => { [x: string]: any; c: number; } class A { } diff --git a/tests/baselines/reference/jsFileCompilationBindErrors.errors.txt b/tests/baselines/reference/jsFileCompilationBindErrors.errors.txt index eeae7053333ed..64bd79d7fd970 100644 --- a/tests/baselines/reference/jsFileCompilationBindErrors.errors.txt +++ b/tests/baselines/reference/jsFileCompilationBindErrors.errors.txt @@ -15,7 +15,7 @@ tests/cases/compiler/a.js(11,9): error TS1100: Invalid use of 'arguments' in str function f() { return; return; // Error: Unreachable code detected. - ~~~~~~ + ~~~~~~~ !!! error TS7027: Unreachable code detected. } diff --git a/tests/baselines/reference/jsFileCompilationBindReachabilityErrors.errors.txt b/tests/baselines/reference/jsFileCompilationBindReachabilityErrors.errors.txt index a883e66e6072f..c2c572aa3042b 100644 --- a/tests/baselines/reference/jsFileCompilationBindReachabilityErrors.errors.txt +++ b/tests/baselines/reference/jsFileCompilationBindReachabilityErrors.errors.txt @@ -22,7 +22,7 @@ tests/cases/compiler/a.js(19,1): error TS7028: Unused label. function bar2() { } var x = 10; // error - ~~~ + ~~~~~~~~~~~ !!! error TS7027: Unreachable code detected. } diff --git a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.errors.txt b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.errors.txt index b88c73e043918..6fc8df185006c 100644 --- a/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.errors.txt +++ b/tests/baselines/reference/jsFileCompilationLetDeclarationOrder2.errors.txt @@ -8,6 +8,7 @@ tests/cases/compiler/a.ts(2,1): error TS2448: Block-scoped variable 'a' used bef a = 10; ~ !!! error TS2448: Block-scoped variable 'a' used before its declaration. +!!! related TS2728 tests/cases/compiler/b.js:1:5: 'a' is declared here. ==== tests/cases/compiler/b.js (0 errors) ==== let a = 10; b = 30; diff --git a/tests/baselines/reference/jsdocImportType.symbols b/tests/baselines/reference/jsdocImportType.symbols index 657ad6801f1cc..dbe46e966e315 100644 --- a/tests/baselines/reference/jsdocImportType.symbols +++ b/tests/baselines/reference/jsdocImportType.symbols @@ -49,7 +49,7 @@ class Chunk { } } module.exports = Chunk; ->module.exports : Symbol(exports, Decl(types.d.ts, 2, 21)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0)) >module : Symbol(export=, Decl(mod1.js, 5, 1)) >exports : Symbol(export=, Decl(mod1.js, 5, 1)) >Chunk : Symbol(Chunk, Decl(mod1.js, 0, 0)) diff --git a/tests/baselines/reference/jsdocImportType.types b/tests/baselines/reference/jsdocImportType.types index b2ac2764cd584..a5d3844388a4c 100644 --- a/tests/baselines/reference/jsdocImportType.types +++ b/tests/baselines/reference/jsdocImportType.types @@ -53,8 +53,8 @@ class Chunk { } module.exports = Chunk; >module.exports = Chunk : typeof Chunk ->module.exports : any ->module : { exports: any; } ->exports : any +>module.exports : typeof Chunk +>module : { "tests/cases/conformance/jsdoc/mod1": typeof Chunk; } +>exports : typeof Chunk >Chunk : typeof Chunk diff --git a/tests/baselines/reference/jsdocImportType2.symbols b/tests/baselines/reference/jsdocImportType2.symbols index e67d250ca3d60..a7ed5cc3d41c5 100644 --- a/tests/baselines/reference/jsdocImportType2.symbols +++ b/tests/baselines/reference/jsdocImportType2.symbols @@ -39,7 +39,7 @@ declare var module: { exports: any }; === tests/cases/conformance/jsdoc/mod1.js === /// module.exports = class Chunk { ->module.exports : Symbol(exports, Decl(types.d.ts, 2, 21)) +>module.exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0)) >module : Symbol(export=, Decl(mod1.js, 0, 0)) >exports : Symbol(export=, Decl(mod1.js, 0, 0)) >Chunk : Symbol(Chunk, Decl(mod1.js, 1, 16)) diff --git a/tests/baselines/reference/jsdocImportType2.types b/tests/baselines/reference/jsdocImportType2.types index c0dfb2d925a24..817b754069aae 100644 --- a/tests/baselines/reference/jsdocImportType2.types +++ b/tests/baselines/reference/jsdocImportType2.types @@ -41,9 +41,9 @@ declare var module: { exports: any }; /// module.exports = class Chunk { >module.exports = class Chunk { constructor() { this.chunk = 1; }} : typeof Chunk ->module.exports : any ->module : { exports: any; } ->exports : any +>module.exports : typeof Chunk +>module : { "tests/cases/conformance/jsdoc/mod1": typeof Chunk; } +>exports : typeof Chunk >class Chunk { constructor() { this.chunk = 1; }} : typeof Chunk >Chunk : typeof Chunk diff --git a/tests/baselines/reference/jsdocParseHigherOrderFunction.symbols b/tests/baselines/reference/jsdocParseHigherOrderFunction.symbols new file mode 100644 index 0000000000000..2876b16268713 --- /dev/null +++ b/tests/baselines/reference/jsdocParseHigherOrderFunction.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsdoc/paren.js === +/** @type {function((string), function((string)): string): string} */ +var x = (s, id) => id(s) +>x : Symbol(x, Decl(paren.js, 1, 3)) +>s : Symbol(s, Decl(paren.js, 1, 9)) +>id : Symbol(id, Decl(paren.js, 1, 11)) +>id : Symbol(id, Decl(paren.js, 1, 11)) +>s : Symbol(s, Decl(paren.js, 1, 9)) + diff --git a/tests/baselines/reference/jsdocParseHigherOrderFunction.types b/tests/baselines/reference/jsdocParseHigherOrderFunction.types new file mode 100644 index 0000000000000..08e4e0bc6a456 --- /dev/null +++ b/tests/baselines/reference/jsdocParseHigherOrderFunction.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/paren.js === +/** @type {function((string), function((string)): string): string} */ +var x = (s, id) => id(s) +>x : (arg0: string, arg1: (arg0: string) => string) => string +>(s, id) => id(s) : (s: string, id: (arg0: string) => string) => string +>s : string +>id : (arg0: string) => string +>id(s) : string +>id : (arg0: string) => string +>s : string + diff --git a/tests/baselines/reference/jsdocParseParenthesizedJSDocParameter.symbols b/tests/baselines/reference/jsdocParseParenthesizedJSDocParameter.symbols new file mode 100644 index 0000000000000..b870f8b72409b --- /dev/null +++ b/tests/baselines/reference/jsdocParseParenthesizedJSDocParameter.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsdoc/paren.js === +/** @type {function((string)): string} */ +var x = s => s.toString() +>x : Symbol(x, Decl(paren.js, 1, 3)) +>s : Symbol(s, Decl(paren.js, 1, 7)) +>s.toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --)) +>s : Symbol(s, Decl(paren.js, 1, 7)) +>toString : Symbol(String.toString, Decl(lib.es5.d.ts, --, --)) + diff --git a/tests/baselines/reference/jsdocParseParenthesizedJSDocParameter.types b/tests/baselines/reference/jsdocParseParenthesizedJSDocParameter.types new file mode 100644 index 0000000000000..aa5a5d477e6fa --- /dev/null +++ b/tests/baselines/reference/jsdocParseParenthesizedJSDocParameter.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/paren.js === +/** @type {function((string)): string} */ +var x = s => s.toString() +>x : (arg0: string) => string +>s => s.toString() : (s: string) => string +>s : string +>s.toString() : string +>s.toString : () => string +>s : string +>toString : () => string + diff --git a/tests/baselines/reference/jsdocTypeFromChainedAssignment2.symbols b/tests/baselines/reference/jsdocTypeFromChainedAssignment2.symbols index b85eafa6925e3..35747a423a4d4 100644 --- a/tests/baselines/reference/jsdocTypeFromChainedAssignment2.symbols +++ b/tests/baselines/reference/jsdocTypeFromChainedAssignment2.symbols @@ -41,11 +41,15 @@ exports.f = exports.g = function fg(n) { } /** @param {string} mom */ module.exports.h = module.exports.i = function hi(mom) { +>module.exports.h : Symbol(h, Decl(mod.js, 3, 1)) >module.exports : Symbol(h, Decl(mod.js, 3, 1)) ->module : Symbol(module) +>module : Symbol(module, Decl(mod.js, 3, 1), Decl(mod.js, 5, 18)) +>exports : Symbol("tests/cases/conformance/jsdoc/mod", Decl(mod.js, 0, 0)) >h : Symbol(h, Decl(mod.js, 3, 1)) +>module.exports.i : Symbol(i, Decl(mod.js, 5, 18)) >module.exports : Symbol(i, Decl(mod.js, 5, 18)) ->module : Symbol(module) +>module : Symbol(module, Decl(mod.js, 3, 1), Decl(mod.js, 5, 18)) +>exports : Symbol("tests/cases/conformance/jsdoc/mod", Decl(mod.js, 0, 0)) >i : Symbol(i, Decl(mod.js, 5, 18)) >hi : Symbol(hi, Decl(mod.js, 5, 37)) >mom : Symbol(mom, Decl(mod.js, 5, 50)) diff --git a/tests/baselines/reference/jsdocTypeFromChainedAssignment2.types b/tests/baselines/reference/jsdocTypeFromChainedAssignment2.types index de2a38cce7981..a236e922e9fab 100644 --- a/tests/baselines/reference/jsdocTypeFromChainedAssignment2.types +++ b/tests/baselines/reference/jsdocTypeFromChainedAssignment2.types @@ -56,17 +56,17 @@ exports.f = exports.g = function fg(n) { /** @param {string} mom */ module.exports.h = module.exports.i = function hi(mom) { >module.exports.h = module.exports.i = function hi(mom) { return `hi, ${mom}!`;} : (mom: string) => string ->module.exports.h : any ->module.exports : any ->module : any ->exports : any ->h : any +>module.exports.h : (mom: string) => string +>module.exports : typeof import("tests/cases/conformance/jsdoc/mod") +>module : { "tests/cases/conformance/jsdoc/mod": typeof import("tests/cases/conformance/jsdoc/mod"); } +>exports : typeof import("tests/cases/conformance/jsdoc/mod") +>h : (mom: string) => string >module.exports.i = function hi(mom) { return `hi, ${mom}!`;} : (mom: string) => string ->module.exports.i : any ->module.exports : any ->module : any ->exports : any ->i : any +>module.exports.i : (mom: string) => string +>module.exports : typeof import("tests/cases/conformance/jsdoc/mod") +>module : { "tests/cases/conformance/jsdoc/mod": typeof import("tests/cases/conformance/jsdoc/mod"); } +>exports : typeof import("tests/cases/conformance/jsdoc/mod") +>i : (mom: string) => string >function hi(mom) { return `hi, ${mom}!`;} : (mom: string) => string >hi : (mom: string) => string >mom : string diff --git a/tests/baselines/reference/jsdocTypeReferenceUseBeforeDef.symbols b/tests/baselines/reference/jsdocTypeReferenceUseBeforeDef.symbols new file mode 100644 index 0000000000000..798c892f5206c --- /dev/null +++ b/tests/baselines/reference/jsdocTypeReferenceUseBeforeDef.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsdoc/bug25097.js === +/** @type {C | null} */ +const c = null +>c : Symbol(c, Decl(bug25097.js, 1, 5)) + +class C { +>C : Symbol(C, Decl(bug25097.js, 1, 14)) +} + diff --git a/tests/baselines/reference/jsdocTypeReferenceUseBeforeDef.types b/tests/baselines/reference/jsdocTypeReferenceUseBeforeDef.types new file mode 100644 index 0000000000000..0a79a140c7d4b --- /dev/null +++ b/tests/baselines/reference/jsdocTypeReferenceUseBeforeDef.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/jsdoc/bug25097.js === +/** @type {C | null} */ +const c = null +>c : C +>null : null + +class C { +>C : C +} + diff --git a/tests/baselines/reference/jsxChildrenGenericContextualTypes.errors.txt b/tests/baselines/reference/jsxChildrenGenericContextualTypes.errors.txt index 632264144dd36..9c9b85fd04d9f 100644 --- a/tests/baselines/reference/jsxChildrenGenericContextualTypes.errors.txt +++ b/tests/baselines/reference/jsxChildrenGenericContextualTypes.errors.txt @@ -1,6 +1,5 @@ -tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(20,31): error TS2326: Types of property 'children' are incompatible. - Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: IntrinsicAttributes & LitProps<"x">) => "x"'. - Type '"y"' is not assignable to type '"x"'. +tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(20,31): error TS2322: Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: IntrinsicAttributes & LitProps<"x">) => "x"'. + Type '"y"' is not assignable to type '"x"'. tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(21,19): error TS2322: Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x" | "y">'. Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x" | "y">'. Types of property 'children' are incompatible. @@ -39,10 +38,10 @@ tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(22,21): error TS2322: // Should error const arg = "y"} /> - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2326: Types of property 'children' are incompatible. -!!! error TS2326: Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: IntrinsicAttributes & LitProps<"x">) => "x"'. -!!! error TS2326: Type '"y"' is not assignable to type '"x"'. + ~~~~~~~~ +!!! error TS2322: Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: IntrinsicAttributes & LitProps<"x">) => "x"'. +!!! error TS2322: Type '"y"' is not assignable to type '"x"'. +!!! related TS6500 tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx:13:34: The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & LitProps<"x">' const argchild = {p => "y"} ~~~~~~~ !!! error TS2322: Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x" | "y">'. diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 1a65dbb038964..0c3939df6a8b3 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -88,7 +88,7 @@ type K10 = keyof Shape; // "name" | "width" | "height" | "visible" >Shape : Shape type K11 = keyof Shape[]; // "length" | "toString" | ... ->K11 : number | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight" +>K11 : number | "length" | "toString" | "toLocaleString" | "pop" | "push" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight" >Shape : Shape type K12 = keyof Dictionary; // string @@ -108,7 +108,7 @@ type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ... >E : E type K16 = keyof [string, number]; // "0" | "1" | "length" | "toString" | ... ->K16 : number | "0" | "1" | "length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight" +>K16 : number | "0" | "1" | "length" | "toString" | "toLocaleString" | "pop" | "push" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight" type K17 = keyof (Shape | Item); // "name" >K17 : "name" diff --git a/tests/baselines/reference/labeledStatementWithLabel.errors.txt b/tests/baselines/reference/labeledStatementWithLabel.errors.txt new file mode 100644 index 0000000000000..c7259e484eaaa --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel.ts(11,8): error TS1235: A namespace declaration is only allowed in a namespace or module. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel.ts(12,8): error TS1235: A namespace declaration is only allowed in a namespace or module. + + +==== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel.ts (2 errors) ==== + label: function fn() { } + label: function* gen() { } + label: async function gen1() { } + label: enum E {} + label: interface I {} + label: class C { } + label: var a = 1; + label: let b = 1; + label: const c = 1; + + label: module M { } + ~~~~~~ +!!! error TS1235: A namespace declaration is only allowed in a namespace or module. + label: namespace N {} + ~~~~~~~~~ +!!! error TS1235: A namespace declaration is only allowed in a namespace or module. + label: type T = {} + \ No newline at end of file diff --git a/tests/baselines/reference/labeledStatementWithLabel.js b/tests/baselines/reference/labeledStatementWithLabel.js new file mode 100644 index 0000000000000..4d5dc499e2573 --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel.js @@ -0,0 +1,80 @@ +//// [labeledStatementWithLabel.ts] +label: function fn() { } +label: function* gen() { } +label: async function gen1() { } +label: enum E {} +label: interface I {} +label: class C { } +label: var a = 1; +label: let b = 1; +label: const c = 1; + +label: module M { } +label: namespace N {} +label: type T = {} + + +//// [labeledStatementWithLabel.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 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, 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 }; + } +}; +label: function fn() { } +label: function gen() { return __generator(this, function (_a) { + return [2 /*return*/]; +}); } +label: function gen1() { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); +} +label: { + var E; + (function (E) { + })(E || (E = {})); +} +label: +label: { + var C = /** @class */ (function () { + function C() { + } + return C; + }()); +} +label: var a = 1; +label: var b = 1; +label: var c = 1; +label: +label: +label: diff --git a/tests/baselines/reference/labeledStatementWithLabel.symbols b/tests/baselines/reference/labeledStatementWithLabel.symbols new file mode 100644 index 0000000000000..ab019c20d51dc --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel.ts === +label: function fn() { } +>fn : Symbol(fn, Decl(labeledStatementWithLabel.ts, 0, 6)) + +label: function* gen() { } +>gen : Symbol(gen, Decl(labeledStatementWithLabel.ts, 1, 6)) + +label: async function gen1() { } +>gen1 : Symbol(gen1, Decl(labeledStatementWithLabel.ts, 2, 6)) + +label: enum E {} +>E : Symbol(E, Decl(labeledStatementWithLabel.ts, 3, 6)) + +label: interface I {} +>I : Symbol(I, Decl(labeledStatementWithLabel.ts, 4, 6)) + +label: class C { } +>C : Symbol(C, Decl(labeledStatementWithLabel.ts, 5, 6)) + +label: var a = 1; +>a : Symbol(a, Decl(labeledStatementWithLabel.ts, 6, 10)) + +label: let b = 1; +>b : Symbol(b, Decl(labeledStatementWithLabel.ts, 7, 10)) + +label: const c = 1; +>c : Symbol(c, Decl(labeledStatementWithLabel.ts, 8, 12)) + +label: module M { } +>M : Symbol(M, Decl(labeledStatementWithLabel.ts, 10, 6)) + +label: namespace N {} +>N : Symbol(N, Decl(labeledStatementWithLabel.ts, 11, 6)) + +label: type T = {} +>T : Symbol(T, Decl(labeledStatementWithLabel.ts, 12, 6)) + diff --git a/tests/baselines/reference/labeledStatementWithLabel.types b/tests/baselines/reference/labeledStatementWithLabel.types new file mode 100644 index 0000000000000..9a1c12becf526 --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel.types @@ -0,0 +1,52 @@ +=== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel.ts === +label: function fn() { } +>label : any +>fn : () => void + +label: function* gen() { } +>label : any +>gen : () => IterableIterator + +label: async function gen1() { } +>label : any +>gen1 : () => Promise + +label: enum E {} +>label : any +>E : E + +label: interface I {} +>label : any +>I : I + +label: class C { } +>label : any +>C : C + +label: var a = 1; +>label : any +>a : number +>1 : 1 + +label: let b = 1; +>label : any +>b : number +>1 : 1 + +label: const c = 1; +>label : any +>c : 1 +>1 : 1 + +label: module M { } +>label : any +>M : any + +label: namespace N {} +>label : any +>N : any + +label: type T = {} +>label : any +>T : {} + diff --git a/tests/baselines/reference/labeledStatementWithLabel_es2015.errors.txt b/tests/baselines/reference/labeledStatementWithLabel_es2015.errors.txt new file mode 100644 index 0000000000000..95c136b953de6 --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel_es2015.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_es2015.ts(11,8): error TS1235: A namespace declaration is only allowed in a namespace or module. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_es2015.ts(12,8): error TS1235: A namespace declaration is only allowed in a namespace or module. + + +==== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_es2015.ts (2 errors) ==== + label: function fn() { } + label: function* gen() { } + label: async function gen1() { } + label: enum E {} + label: interface I {} + label: class C { } + label: var a = 1; + label: let b = 1; + label: const c = 1; + + label: module M { } + ~~~~~~ +!!! error TS1235: A namespace declaration is only allowed in a namespace or module. + label: namespace N {} + ~~~~~~~~~ +!!! error TS1235: A namespace declaration is only allowed in a namespace or module. + label: type T = {} + \ No newline at end of file diff --git a/tests/baselines/reference/labeledStatementWithLabel_es2015.js b/tests/baselines/reference/labeledStatementWithLabel_es2015.js new file mode 100644 index 0000000000000..e2eea4c53be0b --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel_es2015.js @@ -0,0 +1,44 @@ +//// [labeledStatementWithLabel_es2015.ts] +label: function fn() { } +label: function* gen() { } +label: async function gen1() { } +label: enum E {} +label: interface I {} +label: class C { } +label: var a = 1; +label: let b = 1; +label: const c = 1; + +label: module M { } +label: namespace N {} +label: type T = {} + + +//// [labeledStatementWithLabel_es2015.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()); + }); +}; +label: function fn() { } +label: function* gen() { } +label: function gen1() { + return __awaiter(this, void 0, void 0, function* () { }); +} +label: { + var E; + (function (E) { + })(E || (E = {})); +} +label: +label: class C { +} +label: var a = 1; +label: let b = 1; +label: const c = 1; +label: +label: +label: diff --git a/tests/baselines/reference/labeledStatementWithLabel_es2015.symbols b/tests/baselines/reference/labeledStatementWithLabel_es2015.symbols new file mode 100644 index 0000000000000..3e776d1152b55 --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel_es2015.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_es2015.ts === +label: function fn() { } +>fn : Symbol(fn, Decl(labeledStatementWithLabel_es2015.ts, 0, 6)) + +label: function* gen() { } +>gen : Symbol(gen, Decl(labeledStatementWithLabel_es2015.ts, 1, 6)) + +label: async function gen1() { } +>gen1 : Symbol(gen1, Decl(labeledStatementWithLabel_es2015.ts, 2, 6)) + +label: enum E {} +>E : Symbol(E, Decl(labeledStatementWithLabel_es2015.ts, 3, 6)) + +label: interface I {} +>I : Symbol(I, Decl(labeledStatementWithLabel_es2015.ts, 4, 6)) + +label: class C { } +>C : Symbol(C, Decl(labeledStatementWithLabel_es2015.ts, 5, 6)) + +label: var a = 1; +>a : Symbol(a, Decl(labeledStatementWithLabel_es2015.ts, 6, 10)) + +label: let b = 1; +>b : Symbol(b, Decl(labeledStatementWithLabel_es2015.ts, 7, 10)) + +label: const c = 1; +>c : Symbol(c, Decl(labeledStatementWithLabel_es2015.ts, 8, 12)) + +label: module M { } +>M : Symbol(M, Decl(labeledStatementWithLabel_es2015.ts, 10, 6)) + +label: namespace N {} +>N : Symbol(N, Decl(labeledStatementWithLabel_es2015.ts, 11, 6)) + +label: type T = {} +>T : Symbol(T, Decl(labeledStatementWithLabel_es2015.ts, 12, 6)) + diff --git a/tests/baselines/reference/labeledStatementWithLabel_es2015.types b/tests/baselines/reference/labeledStatementWithLabel_es2015.types new file mode 100644 index 0000000000000..7f59d4f0fedf3 --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel_es2015.types @@ -0,0 +1,52 @@ +=== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_es2015.ts === +label: function fn() { } +>label : any +>fn : () => void + +label: function* gen() { } +>label : any +>gen : () => IterableIterator + +label: async function gen1() { } +>label : any +>gen1 : () => Promise + +label: enum E {} +>label : any +>E : E + +label: interface I {} +>label : any +>I : I + +label: class C { } +>label : any +>C : C + +label: var a = 1; +>label : any +>a : number +>1 : 1 + +label: let b = 1; +>label : any +>b : number +>1 : 1 + +label: const c = 1; +>label : any +>c : 1 +>1 : 1 + +label: module M { } +>label : any +>M : any + +label: namespace N {} +>label : any +>N : any + +label: type T = {} +>label : any +>T : {} + diff --git a/tests/baselines/reference/labeledStatementWithLabel_strict.errors.txt b/tests/baselines/reference/labeledStatementWithLabel_strict.errors.txt new file mode 100644 index 0000000000000..863604a083680 --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel_strict.errors.txt @@ -0,0 +1,60 @@ +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(2,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(3,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(4,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(5,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(6,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(7,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(8,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(9,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(10,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(12,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(12,8): error TS1235: A namespace declaration is only allowed in a namespace or module. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(13,1): error TS1344: 'A label is not allowed here. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(13,8): error TS1235: A namespace declaration is only allowed in a namespace or module. +tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts(14,1): error TS1344: 'A label is not allowed here. + + +==== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts (14 errors) ==== + "use strict" + label: function fn() { } + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + label: function* gen() { } + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + label: async function gen1() { } + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + label: enum E {} + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + label: interface I {} + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + label: class C { } + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + label: var a = 1; + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + label: let b = 1; + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + label: const c = 1; + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + + label: module M { } + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + ~~~~~~ +!!! error TS1235: A namespace declaration is only allowed in a namespace or module. + label: namespace N {} + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + ~~~~~~~~~ +!!! error TS1235: A namespace declaration is only allowed in a namespace or module. + label: type T = {} + ~~~~~ +!!! error TS1344: 'A label is not allowed here. + \ No newline at end of file diff --git a/tests/baselines/reference/labeledStatementWithLabel_strict.js b/tests/baselines/reference/labeledStatementWithLabel_strict.js new file mode 100644 index 0000000000000..c4ac2caed06fd --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel_strict.js @@ -0,0 +1,46 @@ +//// [labeledStatementWithLabel_strict.ts] +"use strict" +label: function fn() { } +label: function* gen() { } +label: async function gen1() { } +label: enum E {} +label: interface I {} +label: class C { } +label: var a = 1; +label: let b = 1; +label: const c = 1; + +label: module M { } +label: namespace N {} +label: type T = {} + + +//// [labeledStatementWithLabel_strict.js] +"use strict"; +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()); + }); +}; +label: function fn() { } +label: function* gen() { } +label: function gen1() { + return __awaiter(this, void 0, void 0, function* () { }); +} +label: { + var E; + (function (E) { + })(E || (E = {})); +} +label: +label: class C { +} +label: var a = 1; +label: let b = 1; +label: const c = 1; +label: +label: +label: diff --git a/tests/baselines/reference/labeledStatementWithLabel_strict.symbols b/tests/baselines/reference/labeledStatementWithLabel_strict.symbols new file mode 100644 index 0000000000000..c5a721824cc00 --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel_strict.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts === +"use strict" +label: function fn() { } +>fn : Symbol(fn, Decl(labeledStatementWithLabel_strict.ts, 1, 6)) + +label: function* gen() { } +>gen : Symbol(gen, Decl(labeledStatementWithLabel_strict.ts, 2, 6)) + +label: async function gen1() { } +>gen1 : Symbol(gen1, Decl(labeledStatementWithLabel_strict.ts, 3, 6)) + +label: enum E {} +>E : Symbol(E, Decl(labeledStatementWithLabel_strict.ts, 4, 6)) + +label: interface I {} +>I : Symbol(I, Decl(labeledStatementWithLabel_strict.ts, 5, 6)) + +label: class C { } +>C : Symbol(C, Decl(labeledStatementWithLabel_strict.ts, 6, 6)) + +label: var a = 1; +>a : Symbol(a, Decl(labeledStatementWithLabel_strict.ts, 7, 10)) + +label: let b = 1; +>b : Symbol(b, Decl(labeledStatementWithLabel_strict.ts, 8, 10)) + +label: const c = 1; +>c : Symbol(c, Decl(labeledStatementWithLabel_strict.ts, 9, 12)) + +label: module M { } +>M : Symbol(M, Decl(labeledStatementWithLabel_strict.ts, 11, 6)) + +label: namespace N {} +>N : Symbol(N, Decl(labeledStatementWithLabel_strict.ts, 12, 6)) + +label: type T = {} +>T : Symbol(T, Decl(labeledStatementWithLabel_strict.ts, 13, 6)) + diff --git a/tests/baselines/reference/labeledStatementWithLabel_strict.types b/tests/baselines/reference/labeledStatementWithLabel_strict.types new file mode 100644 index 0000000000000..02bce60c5b1ff --- /dev/null +++ b/tests/baselines/reference/labeledStatementWithLabel_strict.types @@ -0,0 +1,55 @@ +=== tests/cases/conformance/statements/labeledStatements/labeledStatementWithLabel_strict.ts === +"use strict" +>"use strict" : "use strict" + +label: function fn() { } +>label : any +>fn : () => void + +label: function* gen() { } +>label : any +>gen : () => IterableIterator + +label: async function gen1() { } +>label : any +>gen1 : () => Promise + +label: enum E {} +>label : any +>E : E + +label: interface I {} +>label : any +>I : I + +label: class C { } +>label : any +>C : C + +label: var a = 1; +>label : any +>a : number +>1 : 1 + +label: let b = 1; +>label : any +>b : number +>1 : 1 + +label: const c = 1; +>label : any +>c : 1 +>1 : 1 + +label: module M { } +>label : any +>M : any + +label: namespace N {} +>label : any +>N : any + +label: type T = {} +>label : any +>T : {} + diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates2.errors.txt b/tests/baselines/reference/letDeclarations-scopes-duplicates2.errors.txt index 6b07619781618..3c684608285cb 100644 --- a/tests/baselines/reference/letDeclarations-scopes-duplicates2.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates2.errors.txt @@ -6,8 +6,10 @@ tests/cases/compiler/file2.ts(1,5): error TS2451: Cannot redeclare block-scoped let var1 = 0; ~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file2.ts:1:5: 'var1' was also declared here. ==== tests/cases/compiler/file2.ts (1 errors) ==== let var1 = 0; ~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. \ No newline at end of file +!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file1.ts:1:5: 'var1' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates3.errors.txt b/tests/baselines/reference/letDeclarations-scopes-duplicates3.errors.txt index 2ce3fd1c41a66..a29219219521e 100644 --- a/tests/baselines/reference/letDeclarations-scopes-duplicates3.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates3.errors.txt @@ -6,8 +6,10 @@ tests/cases/compiler/file2.ts(1,7): error TS2451: Cannot redeclare block-scoped let var1 = 0; ~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file2.ts:1:7: 'var1' was also declared here. ==== tests/cases/compiler/file2.ts (1 errors) ==== const var1 = 0; ~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. \ No newline at end of file +!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file1.ts:1:5: 'var1' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates4.errors.txt b/tests/baselines/reference/letDeclarations-scopes-duplicates4.errors.txt index b276d6a35151a..4d59fe30ec8b5 100644 --- a/tests/baselines/reference/letDeclarations-scopes-duplicates4.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates4.errors.txt @@ -6,8 +6,10 @@ tests/cases/compiler/file2.ts(1,5): error TS2451: Cannot redeclare block-scoped const var1 = 0; ~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file2.ts:1:5: 'var1' was also declared here. ==== tests/cases/compiler/file2.ts (1 errors) ==== let var1 = 0; ~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. \ No newline at end of file +!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file1.ts:1:7: 'var1' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates5.errors.txt b/tests/baselines/reference/letDeclarations-scopes-duplicates5.errors.txt index 09955c14bc019..ca57232a2d939 100644 --- a/tests/baselines/reference/letDeclarations-scopes-duplicates5.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates5.errors.txt @@ -6,8 +6,10 @@ tests/cases/compiler/file2.ts(1,7): error TS2451: Cannot redeclare block-scoped const var1 = 0; ~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file2.ts:1:7: 'var1' was also declared here. ==== tests/cases/compiler/file2.ts (1 errors) ==== const var1 = 0; ~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. \ No newline at end of file +!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file1.ts:1:7: 'var1' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates6.errors.txt b/tests/baselines/reference/letDeclarations-scopes-duplicates6.errors.txt index 1d39bcde276c1..bd57b2c479e5a 100644 --- a/tests/baselines/reference/letDeclarations-scopes-duplicates6.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates6.errors.txt @@ -6,8 +6,10 @@ tests/cases/compiler/file2.ts(1,5): error TS2451: Cannot redeclare block-scoped var var1 = 0; ~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file2.ts:1:5: 'var1' was also declared here. ==== tests/cases/compiler/file2.ts (1 errors) ==== let var1 = 0; ~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. \ No newline at end of file +!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file1.ts:1:5: 'var1' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates7.errors.txt b/tests/baselines/reference/letDeclarations-scopes-duplicates7.errors.txt index bead743dc4ef3..c9e9f7baf2fd5 100644 --- a/tests/baselines/reference/letDeclarations-scopes-duplicates7.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates7.errors.txt @@ -6,8 +6,10 @@ tests/cases/compiler/file2.ts(1,5): error TS2451: Cannot redeclare block-scoped let var1 = 0; ~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file2.ts:1:5: 'var1' was also declared here. ==== tests/cases/compiler/file2.ts (1 errors) ==== var var1 = 0; ~~~~ -!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. \ No newline at end of file +!!! error TS2451: Cannot redeclare block-scoped variable 'var1'. +!!! related TS6203 tests/cases/compiler/file1.ts:1:5: 'var1' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-scopes2.errors.txt b/tests/baselines/reference/letDeclarations-scopes2.errors.txt index 5da8d99d397c1..b987e6a5e53b9 100644 --- a/tests/baselines/reference/letDeclarations-scopes2.errors.txt +++ b/tests/baselines/reference/letDeclarations-scopes2.errors.txt @@ -15,6 +15,7 @@ tests/cases/compiler/letDeclarations-scopes2.ts(25,1): error TS2304: Cannot find local2; // Error ~~~~~~ !!! error TS2552: Cannot find name 'local2'. Did you mean 'local'? +!!! related TS2728 tests/cases/compiler/letDeclarations-scopes2.ts:4:9: 'local' is declared here. { let local2 = 0; @@ -29,6 +30,7 @@ tests/cases/compiler/letDeclarations-scopes2.ts(25,1): error TS2304: Cannot find local2; // Error ~~~~~~ !!! error TS2552: Cannot find name 'local2'. Did you mean 'local'? +!!! related TS2728 tests/cases/compiler/letDeclarations-scopes2.ts:4:9: 'local' is declared here. } local; // Error diff --git a/tests/baselines/reference/letDeclarations-useBeforeDefinition.errors.txt b/tests/baselines/reference/letDeclarations-useBeforeDefinition.errors.txt index 69721a93b6339..f8b0ed9fbd42d 100644 --- a/tests/baselines/reference/letDeclarations-useBeforeDefinition.errors.txt +++ b/tests/baselines/reference/letDeclarations-useBeforeDefinition.errors.txt @@ -7,6 +7,7 @@ tests/cases/compiler/letDeclarations-useBeforeDefinition.ts(8,5): error TS2448: l1; ~~ !!! error TS2448: Block-scoped variable 'l1' used before its declaration. +!!! related TS2728 tests/cases/compiler/letDeclarations-useBeforeDefinition.ts:3:9: 'l1' is declared here. let l1; } @@ -15,6 +16,7 @@ tests/cases/compiler/letDeclarations-useBeforeDefinition.ts(8,5): error TS2448: v1; ~~ !!! error TS2448: Block-scoped variable 'v1' used before its declaration. +!!! related TS2728 tests/cases/compiler/letDeclarations-useBeforeDefinition.ts:9:9: 'v1' is declared here. let v1 = 0; } \ No newline at end of file diff --git a/tests/baselines/reference/letDeclarations-useBeforeDefinition2.errors.txt b/tests/baselines/reference/letDeclarations-useBeforeDefinition2.errors.txt index 8820af5cc7c04..6c5bfd04bc687 100644 --- a/tests/baselines/reference/letDeclarations-useBeforeDefinition2.errors.txt +++ b/tests/baselines/reference/letDeclarations-useBeforeDefinition2.errors.txt @@ -5,6 +5,7 @@ tests/cases/compiler/file1.ts(1,1): error TS2448: Block-scoped variable 'l' used l; ~ !!! error TS2448: Block-scoped variable 'l' used before its declaration. +!!! related TS2728 tests/cases/compiler/file2.ts:1:7: 'l' is declared here. ==== tests/cases/compiler/file2.ts (0 errors) ==== const l = 0; \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index f78c32531a486..99d8f9c7ad13d 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -37,15 +37,9 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(123,12): error TS2345: Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(124,14): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick'. Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(128,5): error TS2322: Type '{ a: string; }' is not assignable to type 'T2'. - Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number | undefined'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(129,5): error TS2322: Type '{ a: string; }' is not assignable to type 'Partial'. - Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number | undefined'. -tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,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(128,16): error TS2322: Type 'string' is not assignable to type 'number | undefined'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(129,25): error TS2322: Type 'string' is not assignable to type 'number | undefined'. +tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,39): error TS2322: Type 'string' is not assignable to type 'number | undefined'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,16): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'. Type 'T' is not assignable to type 'symbol'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: Type 'P' cannot be used to index type 'T'. @@ -239,20 +233,17 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: type T2 = { a?: number, [key: string]: any }; let x1: T2 = { a: 'no' }; // Error - ~~ -!!! error TS2322: Type '{ a: string; }' is not assignable to type 'T2'. -!!! error TS2322: Types of property 'a' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:126:13: The expected type comes from property 'a' which is declared here on type 'T2' let x2: Partial = { a: 'no' }; // Error - ~~ -!!! error TS2322: Type '{ a: string; }' is not assignable to type 'Partial'. -!!! error TS2322: Types of property 'a' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:126:13: The expected type comes from property 'a' which is declared here on type 'Partial' let x3: { [P in keyof T2]: T2[P]} = { a: 'no' }; // Error - ~~ -!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'. -!!! error TS2322: Types of property 'a' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. +!!! related TS6500 tests/cases/conformance/types/mapped/mappedTypeErrors.ts:126:13: The expected type comes from property 'a' which is declared here on type '{ [x: string]: any; a?: number | undefined; }' // Repro from #13044 diff --git a/tests/baselines/reference/maximum10SpellingSuggestions.errors.txt b/tests/baselines/reference/maximum10SpellingSuggestions.errors.txt index 8069d7bd1f5c7..9528ccec6fbdc 100644 --- a/tests/baselines/reference/maximum10SpellingSuggestions.errors.txt +++ b/tests/baselines/reference/maximum10SpellingSuggestions.errors.txt @@ -19,24 +19,34 @@ tests/cases/compiler/maximum10SpellingSuggestions.ts(5,6): error TS2304: Cannot bob; bob; bob; bob; bob; bob; bob; bob; bob; bob; ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. ~~~ !!! error TS2552: Cannot find name 'bob'. Did you mean 'blob'? +!!! related TS2728 tests/cases/compiler/maximum10SpellingSuggestions.ts:3:5: 'blob' is declared here. bob; bob; ~~~ !!! error TS2304: Cannot find name 'bob'. diff --git a/tests/baselines/reference/mergedDeclarations7.types b/tests/baselines/reference/mergedDeclarations7.types index 416b5e1221fd3..c02c96e342533 100644 --- a/tests/baselines/reference/mergedDeclarations7.types +++ b/tests/baselines/reference/mergedDeclarations7.types @@ -1,6 +1,6 @@ === tests/cases/compiler/passport.d.ts === declare module 'passport' { ->'passport' : typeof 'passport' +>'passport' : typeof import("passport") namespace passport { >passport : PassportStatic diff --git a/tests/baselines/reference/metadataImportType.errors.txt b/tests/baselines/reference/metadataImportType.errors.txt index 31824696a0ba7..8f3429a48975e 100644 --- a/tests/baselines/reference/metadataImportType.errors.txt +++ b/tests/baselines/reference/metadataImportType.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/metadataImportType.ts(2,6): error TS2304: Cannot find name 'test'. -tests/cases/compiler/metadataImportType.ts(3,8): error TS2307: Cannot find module './b'. +tests/cases/compiler/metadataImportType.ts(3,15): error TS2307: Cannot find module './b'. ==== tests/cases/compiler/metadataImportType.ts (2 errors) ==== @@ -8,6 +8,6 @@ tests/cases/compiler/metadataImportType.ts(3,8): error TS2307: Cannot find modul ~~~~ !!! error TS2304: Cannot find name 'test'. b: import('./b').B - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2307: Cannot find module './b'. } \ No newline at end of file diff --git a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.errors.txt b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.errors.txt index f5eda1fcf4a59..a77030bd5de3b 100644 --- a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.errors.txt +++ b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.errors.txt @@ -41,6 +41,7 @@ tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6FeaturesWithOnlyES5Lib.t Math.sign(1); ~~~~ !!! error TS2551: Property 'sign' does not exist on type 'Math'. Did you mean 'sin'? +!!! related TS2728 /.ts/lib.es5.d.ts:643:5: 'sin' is declared here. // Using ES6 object var o = { diff --git a/tests/baselines/reference/moduleAugmentationDuringSyntheticDefaultCheck.types b/tests/baselines/reference/moduleAugmentationDuringSyntheticDefaultCheck.types index 3c3875e80fc43..2d67f511a794d 100644 --- a/tests/baselines/reference/moduleAugmentationDuringSyntheticDefaultCheck.types +++ b/tests/baselines/reference/moduleAugmentationDuringSyntheticDefaultCheck.types @@ -6,9 +6,9 @@ import moment = require("moment-timezone"); === tests/cases/compiler/node_modules/moment/index.d.ts === declare function moment(): moment.Moment; ->moment : () => moment.Moment +>moment : () => import("omen").Moment >moment : any ->Moment : moment.Moment +>Moment : import("omen").Moment declare namespace moment { >moment : () => Moment @@ -22,7 +22,7 @@ declare namespace moment { } } export = moment; ->moment : () => moment.Moment +>moment : () => import("omen").Moment === tests/cases/compiler/node_modules/moment-timezone/index.d.ts === import * as moment from 'moment'; diff --git a/tests/baselines/reference/moduleExportAlias.symbols b/tests/baselines/reference/moduleExportAlias.symbols index 7d17348aa881c..b2d7e17a27f02 100644 --- a/tests/baselines/reference/moduleExportAlias.symbols +++ b/tests/baselines/reference/moduleExportAlias.symbols @@ -120,27 +120,39 @@ exports.func2 = function () { }; var moduleExportsAlias = module.exports; >moduleExportsAlias : Symbol(moduleExportsAlias, Decl(b.js, 4, 3)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) moduleExportsAlias.func3 = function () { }; +>moduleExportsAlias.func3 : Symbol(func3, Decl(b.js, 4, 40)) >moduleExportsAlias : Symbol(moduleExportsAlias, Decl(b.js, 4, 3)) +>func3 : Symbol(func3, Decl(b.js, 4, 40)) module.exports.func4 = function () { }; +>module.exports.func4 : Symbol(func4, Decl(b.js, 5, 43)) >module.exports : Symbol(func4, Decl(b.js, 5, 43)) ->module : Symbol(module) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >func4 : Symbol(func4, Decl(b.js, 5, 43)) var multipleDeclarationAlias1 = exports = module.exports; >multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias1.func5 = function () { }; +>multipleDeclarationAlias1.func5 : Symbol(func5, Decl(b.js, 8, 57)) >multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) +>func5 : Symbol(func5, Decl(b.js, 8, 57)) var multipleDeclarationAlias2 = module.exports = exports; >multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias2.func6 = function () { }; @@ -164,30 +176,44 @@ multipleDeclarationAlias3.func7 = function () { }; var multipleDeclarationAlias4 = someOtherVariable = module.exports; >multipleDeclarationAlias4 : Symbol(multipleDeclarationAlias4, Decl(b.js, 18, 3)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias4.func8 = function () { }; +>multipleDeclarationAlias4.func8 : Symbol(func8, Decl(b.js, 18, 67)) >multipleDeclarationAlias4 : Symbol(multipleDeclarationAlias4, Decl(b.js, 18, 3)) +>func8 : Symbol(func8, Decl(b.js, 18, 67)) var multipleDeclarationAlias5 = module.exports = exports = {}; >multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias5.func9 = function () { }; +>multipleDeclarationAlias5.func9 : Symbol(func9, Decl(b.js, 21, 62)) >multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) +>func9 : Symbol(func9, Decl(b.js, 21, 62)) var multipleDeclarationAlias6 = exports = module.exports = {}; >multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias6.func10 = function () { }; +>multipleDeclarationAlias6.func10 : Symbol(func10, Decl(b.js, 24, 62)) >multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) +>func10 : Symbol(func10, Decl(b.js, 24, 62)) exports = module.exports = someOtherVariable = {}; >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) exports.func11 = function () { }; @@ -196,13 +222,17 @@ exports.func11 = function () { }; >func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) module.exports.func12 = function () { }; +>module.exports.func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) >module.exports : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) ->module : Symbol(module) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = someOtherVariable = {}; >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) exports.func11 = function () { }; @@ -211,13 +241,17 @@ exports.func11 = function () { }; >func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) module.exports.func12 = function () { }; +>module.exports.func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) >module.exports : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) ->module : Symbol(module) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = {}; >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) exports.func13 = function () { }; >exports.func13 : Symbol(func13, Decl(b.js, 35, 30)) @@ -225,13 +259,17 @@ exports.func13 = function () { }; >func13 : Symbol(func13, Decl(b.js, 35, 30)) module.exports.func14 = function () { }; +>module.exports.func14 : Symbol(func14, Decl(b.js, 36, 33)) >module.exports : Symbol(func14, Decl(b.js, 36, 33)) ->module : Symbol(module) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >func14 : Symbol(func14, Decl(b.js, 36, 33)) exports = module.exports = {}; >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) exports.func15 = function () { }; >exports.func15 : Symbol(func15, Decl(b.js, 39, 30)) @@ -239,12 +277,16 @@ exports.func15 = function () { }; >func15 : Symbol(func15, Decl(b.js, 39, 30)) module.exports.func16 = function () { }; +>module.exports.func16 : Symbol(func16, Decl(b.js, 40, 33)) >module.exports : Symbol(func16, Decl(b.js, 40, 33)) ->module : Symbol(module) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >func16 : Symbol(func16, Decl(b.js, 40, 33)) module.exports = exports = {}; ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) exports.func17 = function () { }; @@ -253,12 +295,16 @@ exports.func17 = function () { }; >func17 : Symbol(func17, Decl(b.js, 43, 30)) module.exports.func18 = function () { }; +>module.exports.func18 : Symbol(func18, Decl(b.js, 44, 33)) >module.exports : Symbol(func18, Decl(b.js, 44, 33)) ->module : Symbol(module) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >func18 : Symbol(func18, Decl(b.js, 44, 33)) module.exports = {}; ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) exports.func19 = function () { }; >exports.func19 : Symbol(func19, Decl(b.js, 47, 20)) @@ -266,8 +312,10 @@ exports.func19 = function () { }; >func19 : Symbol(func19, Decl(b.js, 47, 20)) module.exports.func20 = function () { }; +>module.exports.func20 : Symbol(func20, Decl(b.js, 48, 33)) >module.exports : Symbol(func20, Decl(b.js, 48, 33)) ->module : Symbol(module) +>module : Symbol(module, Decl(b.js, 4, 24), Decl(b.js, 5, 43), Decl(b.js, 8, 41), Decl(b.js, 11, 31), Decl(b.js, 18, 51) ... and 14 more) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >func20 : Symbol(func20, Decl(b.js, 48, 33)) diff --git a/tests/baselines/reference/moduleExportAlias.types b/tests/baselines/reference/moduleExportAlias.types index 924f02d7fa866..4e52412620218 100644 --- a/tests/baselines/reference/moduleExportAlias.types +++ b/tests/baselines/reference/moduleExportAlias.types @@ -123,48 +123,48 @@ exports.func2 = function () { }; >function () { } : () => void var moduleExportsAlias = module.exports; ->moduleExportsAlias : any ->module.exports : any ->module : any ->exports : any +>moduleExportsAlias : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") moduleExportsAlias.func3 = function () { }; >moduleExportsAlias.func3 = function () { } : () => void ->moduleExportsAlias.func3 : any ->moduleExportsAlias : any ->func3 : any +>moduleExportsAlias.func3 : () => void +>moduleExportsAlias : typeof import("tests/cases/conformance/salsa/b") +>func3 : () => void >function () { } : () => void module.exports.func4 = function () { }; >module.exports.func4 = function () { } : () => void ->module.exports.func4 : any ->module.exports : any ->module : any ->exports : any ->func4 : any +>module.exports.func4 : () => void +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") +>func4 : () => void >function () { } : () => void var multipleDeclarationAlias1 = exports = module.exports; ->multipleDeclarationAlias1 : any ->exports = module.exports : any +>multipleDeclarationAlias1 : typeof import("tests/cases/conformance/salsa/b") +>exports = module.exports : typeof import("tests/cases/conformance/salsa/b") +>exports : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } >exports : typeof import("tests/cases/conformance/salsa/b") ->module.exports : any ->module : any ->exports : any multipleDeclarationAlias1.func5 = function () { }; >multipleDeclarationAlias1.func5 = function () { } : () => void ->multipleDeclarationAlias1.func5 : any ->multipleDeclarationAlias1 : any ->func5 : any +>multipleDeclarationAlias1.func5 : () => void +>multipleDeclarationAlias1 : typeof import("tests/cases/conformance/salsa/b") +>func5 : () => void >function () { } : () => void var multipleDeclarationAlias2 = module.exports = exports; >multipleDeclarationAlias2 : typeof import("tests/cases/conformance/salsa/b") >module.exports = exports : typeof import("tests/cases/conformance/salsa/b") ->module.exports : any ->module : any ->exports : any +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") >exports : typeof import("tests/cases/conformance/salsa/b") multipleDeclarationAlias2.func6 = function () { }; @@ -191,61 +191,61 @@ multipleDeclarationAlias3.func7 = function () { }; >function () { } : () => void var multipleDeclarationAlias4 = someOtherVariable = module.exports; ->multipleDeclarationAlias4 : any ->someOtherVariable = module.exports : any +>multipleDeclarationAlias4 : typeof import("tests/cases/conformance/salsa/b") +>someOtherVariable = module.exports : typeof import("tests/cases/conformance/salsa/b") >someOtherVariable : any ->module.exports : any ->module : any ->exports : any +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") multipleDeclarationAlias4.func8 = function () { }; >multipleDeclarationAlias4.func8 = function () { } : () => void ->multipleDeclarationAlias4.func8 : any ->multipleDeclarationAlias4 : any ->func8 : any +>multipleDeclarationAlias4.func8 : () => void +>multipleDeclarationAlias4 : typeof import("tests/cases/conformance/salsa/b") +>func8 : () => void >function () { } : () => void var multipleDeclarationAlias5 = module.exports = exports = {}; ->multipleDeclarationAlias5 : {} ->module.exports = exports = {} : {} ->module.exports : any ->module : any ->exports : any +>multipleDeclarationAlias5 : typeof import("tests/cases/conformance/salsa/b") +>module.exports = exports = {} : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") >exports = {} : {} >exports : typeof import("tests/cases/conformance/salsa/b") >{} : {} multipleDeclarationAlias5.func9 = function () { }; >multipleDeclarationAlias5.func9 = function () { } : () => void ->multipleDeclarationAlias5.func9 : any ->multipleDeclarationAlias5 : {} ->func9 : any +>multipleDeclarationAlias5.func9 : () => void +>multipleDeclarationAlias5 : typeof import("tests/cases/conformance/salsa/b") +>func9 : () => void >function () { } : () => void var multipleDeclarationAlias6 = exports = module.exports = {}; ->multipleDeclarationAlias6 : { [x: string]: any; } ->exports = module.exports = {} : { [x: string]: any; } +>multipleDeclarationAlias6 : typeof import("tests/cases/conformance/salsa/b") +>exports = module.exports = {} : typeof import("tests/cases/conformance/salsa/b") +>exports : typeof import("tests/cases/conformance/salsa/b") +>module.exports = {} : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } >exports : typeof import("tests/cases/conformance/salsa/b") ->module.exports = {} : { [x: string]: any; } ->module.exports : any ->module : any ->exports : any ->{} : { [x: string]: any; } +>{} : {} multipleDeclarationAlias6.func10 = function () { }; >multipleDeclarationAlias6.func10 = function () { } : () => void ->multipleDeclarationAlias6.func10 : any ->multipleDeclarationAlias6 : { [x: string]: any; } ->func10 : any +>multipleDeclarationAlias6.func10 : () => void +>multipleDeclarationAlias6 : typeof import("tests/cases/conformance/salsa/b") +>func10 : () => void >function () { } : () => void exports = module.exports = someOtherVariable = {}; ->exports = module.exports = someOtherVariable = {} : {} +>exports = module.exports = someOtherVariable = {} : typeof import("tests/cases/conformance/salsa/b") +>exports : typeof import("tests/cases/conformance/salsa/b") +>module.exports = someOtherVariable = {} : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } >exports : typeof import("tests/cases/conformance/salsa/b") ->module.exports = someOtherVariable = {} : {} ->module.exports : any ->module : any ->exports : any >someOtherVariable = {} : {} >someOtherVariable : any >{} : {} @@ -259,20 +259,20 @@ exports.func11 = function () { }; module.exports.func12 = function () { }; >module.exports.func12 = function () { } : () => void ->module.exports.func12 : any ->module.exports : any ->module : any ->exports : any ->func12 : any +>module.exports.func12 : () => void +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") +>func12 : () => void >function () { } : () => void exports = module.exports = someOtherVariable = {}; ->exports = module.exports = someOtherVariable = {} : {} +>exports = module.exports = someOtherVariable = {} : typeof import("tests/cases/conformance/salsa/b") +>exports : typeof import("tests/cases/conformance/salsa/b") +>module.exports = someOtherVariable = {} : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } >exports : typeof import("tests/cases/conformance/salsa/b") ->module.exports = someOtherVariable = {} : {} ->module.exports : any ->module : any ->exports : any >someOtherVariable = {} : {} >someOtherVariable : any >{} : {} @@ -286,21 +286,21 @@ exports.func11 = function () { }; module.exports.func12 = function () { }; >module.exports.func12 = function () { } : () => void ->module.exports.func12 : any ->module.exports : any ->module : any ->exports : any ->func12 : any +>module.exports.func12 : () => void +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") +>func12 : () => void >function () { } : () => void exports = module.exports = {}; ->exports = module.exports = {} : { [x: string]: any; } +>exports = module.exports = {} : typeof import("tests/cases/conformance/salsa/b") +>exports : typeof import("tests/cases/conformance/salsa/b") +>module.exports = {} : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } >exports : typeof import("tests/cases/conformance/salsa/b") ->module.exports = {} : { [x: string]: any; } ->module.exports : any ->module : any ->exports : any ->{} : { [x: string]: any; } +>{} : {} exports.func13 = function () { }; >exports.func13 = function () { } : () => void @@ -311,21 +311,21 @@ exports.func13 = function () { }; module.exports.func14 = function () { }; >module.exports.func14 = function () { } : () => void ->module.exports.func14 : any ->module.exports : any ->module : any ->exports : any ->func14 : any +>module.exports.func14 : () => void +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") +>func14 : () => void >function () { } : () => void exports = module.exports = {}; ->exports = module.exports = {} : { [x: string]: any; } +>exports = module.exports = {} : typeof import("tests/cases/conformance/salsa/b") +>exports : typeof import("tests/cases/conformance/salsa/b") +>module.exports = {} : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } >exports : typeof import("tests/cases/conformance/salsa/b") ->module.exports = {} : { [x: string]: any; } ->module.exports : any ->module : any ->exports : any ->{} : { [x: string]: any; } +>{} : {} exports.func15 = function () { }; >exports.func15 = function () { } : () => void @@ -336,18 +336,18 @@ exports.func15 = function () { }; module.exports.func16 = function () { }; >module.exports.func16 = function () { } : () => void ->module.exports.func16 : any ->module.exports : any ->module : any ->exports : any ->func16 : any +>module.exports.func16 : () => void +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") +>func16 : () => void >function () { } : () => void module.exports = exports = {}; ->module.exports = exports = {} : {} ->module.exports : any ->module : any ->exports : any +>module.exports = exports = {} : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") >exports = {} : {} >exports : typeof import("tests/cases/conformance/salsa/b") >{} : {} @@ -361,19 +361,19 @@ exports.func17 = function () { }; module.exports.func18 = function () { }; >module.exports.func18 = function () { } : () => void ->module.exports.func18 : any ->module.exports : any ->module : any ->exports : any ->func18 : any +>module.exports.func18 : () => void +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") +>func18 : () => void >function () { } : () => void module.exports = {}; ->module.exports = {} : { [x: string]: any; } ->module.exports : any ->module : any ->exports : any ->{} : { [x: string]: any; } +>module.exports = {} : typeof import("tests/cases/conformance/salsa/b") +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") +>{} : {} exports.func19 = function () { }; >exports.func19 = function () { } : () => void @@ -384,11 +384,11 @@ exports.func19 = function () { }; module.exports.func20 = function () { }; >module.exports.func20 = function () { } : () => void ->module.exports.func20 : any ->module.exports : any ->module : any ->exports : any ->func20 : any +>module.exports.func20 : () => void +>module.exports : typeof import("tests/cases/conformance/salsa/b") +>module : { "tests/cases/conformance/salsa/b": typeof import("tests/cases/conformance/salsa/b"); } +>exports : typeof import("tests/cases/conformance/salsa/b") +>func20 : () => void >function () { } : () => void diff --git a/tests/baselines/reference/moduleExportAlias2.symbols b/tests/baselines/reference/moduleExportAlias2.symbols index 52e089050b171..f6ebc315313d7 100644 --- a/tests/baselines/reference/moduleExportAlias2.symbols +++ b/tests/baselines/reference/moduleExportAlias2.symbols @@ -31,13 +31,13 @@ declare var module: { exports: any }; /// exports = module.exports = C >exports : Symbol("tests/cases/conformance/salsa/semver", Decl(semver.js, 0, 0)) ->module.exports : Symbol(exports, Decl(node.d.ts, 2, 21)) +>module.exports : Symbol("tests/cases/conformance/salsa/semver", Decl(semver.js, 0, 0)) >module : Symbol(export=, Decl(semver.js, 1, 9)) >exports : Symbol(export=, Decl(semver.js, 1, 9)) >C : Symbol(C, Decl(semver.js, 2, 22)) exports.f = n => n + 1 ->exports.f : Symbol(f, Decl(semver.js, 1, 28)) +>exports.f : Symbol(f) >exports : Symbol(f, Decl(semver.js, 1, 28)) >f : Symbol(f, Decl(semver.js, 1, 28)) >n : Symbol(n, Decl(semver.js, 2, 11)) diff --git a/tests/baselines/reference/moduleExportAlias2.types b/tests/baselines/reference/moduleExportAlias2.types index c76c2c33c4553..65f245a6f4f32 100644 --- a/tests/baselines/reference/moduleExportAlias2.types +++ b/tests/baselines/reference/moduleExportAlias2.types @@ -35,17 +35,17 @@ declare var module: { exports: any }; /// exports = module.exports = C >exports = module.exports = C : typeof C ->exports : typeof import("tests/cases/conformance/salsa/semver") +>exports : typeof C >module.exports = C : typeof C ->module.exports : any ->module : { exports: any; } ->exports : any +>module.exports : typeof C +>module : { "tests/cases/conformance/salsa/semver": typeof C; } +>exports : typeof C >C : typeof C exports.f = n => n + 1 >exports.f = n => n + 1 : (n: any) => any >exports.f : (n: any) => any ->exports : typeof import("tests/cases/conformance/salsa/semver") +>exports : typeof C >f : (n: any) => any >n => n + 1 : (n: any) => any >n : any diff --git a/tests/baselines/reference/moduleExportAlias3.symbols b/tests/baselines/reference/moduleExportAlias3.symbols index 740c3004d105a..5b68b27e606c1 100644 --- a/tests/baselines/reference/moduleExportAlias3.symbols +++ b/tests/baselines/reference/moduleExportAlias3.symbols @@ -4,6 +4,7 @@ class C { >C : Symbol(C, Decl(bug24062.js, 0, 0)) } module.exports = { +>module.exports : Symbol("tests/cases/conformance/salsa/bug24062", Decl(bug24062.js, 0, 0)) >module : Symbol(export=, Decl(bug24062.js, 2, 1)) >exports : Symbol(export=, Decl(bug24062.js, 2, 1)) diff --git a/tests/baselines/reference/moduleExportAlias3.types b/tests/baselines/reference/moduleExportAlias3.types index 872eb3ef76efd..23994aeca175f 100644 --- a/tests/baselines/reference/moduleExportAlias3.types +++ b/tests/baselines/reference/moduleExportAlias3.types @@ -5,9 +5,9 @@ class C { } module.exports = { >module.exports = { C} : { [x: string]: any; C: typeof C; } ->module.exports : any ->module : any ->exports : any +>module.exports : { [x: string]: any; C: typeof C; } +>module : { "tests/cases/conformance/salsa/bug24062": { [x: string]: any; C: typeof C; }; } +>exports : { [x: string]: any; C: typeof C; } >{ C} : { [x: string]: any; C: typeof C; } C diff --git a/tests/baselines/reference/moduleExportAlias4.symbols b/tests/baselines/reference/moduleExportAlias4.symbols index 859d3eeb0edfd..1d0cf0ce2bc81 100644 --- a/tests/baselines/reference/moduleExportAlias4.symbols +++ b/tests/baselines/reference/moduleExportAlias4.symbols @@ -6,13 +6,16 @@ var wat = require('./bug24024') >'./bug24024' : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0)) module.exports = class C {} +>module.exports : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0)) >module : Symbol(export=, Decl(bug24024.js, 1, 31)) >exports : Symbol(export=, Decl(bug24024.js, 1, 31)) >C : Symbol(C, Decl(bug24024.js, 2, 16)) module.exports.D = class D { } +>module.exports.D : Symbol(D) >module.exports : Symbol(D, Decl(bug24024.js, 2, 27)) ->module : Symbol(module) +>module : Symbol(module, Decl(bug24024.js, 1, 31), Decl(bug24024.js, 2, 27)) +>exports : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0)) >D : Symbol(D, Decl(bug24024.js, 2, 27)) >D : Symbol(D, Decl(bug24024.js, 3, 18)) diff --git a/tests/baselines/reference/moduleExportAlias4.types b/tests/baselines/reference/moduleExportAlias4.types index 33a7aac2cb468..744252781400b 100644 --- a/tests/baselines/reference/moduleExportAlias4.types +++ b/tests/baselines/reference/moduleExportAlias4.types @@ -8,19 +8,19 @@ var wat = require('./bug24024') module.exports = class C {} >module.exports = class C {} : typeof C ->module.exports : any ->module : any ->exports : any +>module.exports : typeof C +>module : { "tests/cases/conformance/salsa/bug24024": typeof C; } +>exports : typeof C >class C {} : typeof C >C : typeof C module.exports.D = class D { } >module.exports.D = class D { } : typeof D ->module.exports.D : any ->module.exports : any ->module : any ->exports : any ->D : any +>module.exports.D : typeof D +>module.exports : typeof C +>module : { "tests/cases/conformance/salsa/bug24024": typeof C; } +>exports : typeof C +>D : typeof D >class D { } : typeof D >D : typeof D diff --git a/tests/baselines/reference/moduleExportAlias5.symbols b/tests/baselines/reference/moduleExportAlias5.symbols index f856e9ae32ce8..cc9cd7212f471 100644 --- a/tests/baselines/reference/moduleExportAlias5.symbols +++ b/tests/baselines/reference/moduleExportAlias5.symbols @@ -5,6 +5,7 @@ const webpack = function (){ } exports = module.exports = webpack; >exports : Symbol("tests/cases/conformance/salsa/bug24754", Decl(bug24754.js, 0, 0)) +>module.exports : Symbol("tests/cases/conformance/salsa/bug24754", Decl(bug24754.js, 0, 0)) >module : Symbol(export=, Decl(bug24754.js, 3, 9)) >exports : Symbol(export=, Decl(bug24754.js, 3, 9)) >webpack : Symbol(webpack, Decl(bug24754.js, 1, 5)) diff --git a/tests/baselines/reference/moduleExportAlias5.types b/tests/baselines/reference/moduleExportAlias5.types index 47a5cb3ddfaad..b334331c639cd 100644 --- a/tests/baselines/reference/moduleExportAlias5.types +++ b/tests/baselines/reference/moduleExportAlias5.types @@ -5,18 +5,18 @@ const webpack = function (){ >function (){} : { (): void; WebpackOptionsDefaulter: number; } } exports = module.exports = webpack; ->exports = module.exports = webpack : { (): void; WebpackOptionsDefaulter: number; } ->exports : typeof import("tests/cases/conformance/salsa/bug24754") ->module.exports = webpack : { (): void; WebpackOptionsDefaulter: number; } ->module.exports : any ->module : any ->exports : any +>exports = module.exports = webpack : { (): void; WebpackOptionsDefaulter: number; version: number; } +>exports : { (): void; WebpackOptionsDefaulter: number; version: number; } +>module.exports = webpack : { (): void; WebpackOptionsDefaulter: number; version: number; } +>module.exports : { (): void; WebpackOptionsDefaulter: number; version: number; } +>module : { "tests/cases/conformance/salsa/bug24754": { (): void; WebpackOptionsDefaulter: number; version: number; }; } +>exports : { (): void; WebpackOptionsDefaulter: number; version: number; } >webpack : { (): void; WebpackOptionsDefaulter: number; } exports.version = 1001; >exports.version = 1001 : 1001 >exports.version : number ->exports : typeof import("tests/cases/conformance/salsa/bug24754") +>exports : { (): void; WebpackOptionsDefaulter: number; version: number; } >version : number >1001 : 1001 diff --git a/tests/baselines/reference/moduleExportAssignment.symbols b/tests/baselines/reference/moduleExportAssignment.symbols new file mode 100644 index 0000000000000..259f1cb99f880 --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment.symbols @@ -0,0 +1,68 @@ +=== tests/cases/conformance/salsa/use.js === +var npmlog = require('./npmlog') +>npmlog : Symbol(npmlog, Decl(use.js, 0, 3)) +>require : Symbol(require) +>'./npmlog' : Symbol("tests/cases/conformance/salsa/npmlog", Decl(npmlog.js, 0, 0)) + +npmlog.x +>npmlog.x : Symbol(x, Decl(npmlog.js, 7, 23)) +>npmlog : Symbol(npmlog, Decl(use.js, 0, 3)) +>x : Symbol(x, Decl(npmlog.js, 7, 23)) + +npmlog.on +>npmlog.on : Symbol(EE.on, Decl(npmlog.js, 0, 10)) +>npmlog : Symbol(npmlog, Decl(use.js, 0, 3)) +>on : Symbol(EE.on, Decl(npmlog.js, 0, 10)) + +=== tests/cases/conformance/salsa/npmlog.js === +class EE { +>EE : Symbol(EE, Decl(npmlog.js, 0, 0)) + + /** @param {string} s */ + on(s) { } +>on : Symbol(EE.on, Decl(npmlog.js, 0, 10)) +>s : Symbol(s, Decl(npmlog.js, 2, 7)) +} +var npmlog = module.exports = new EE() +>npmlog : Symbol(npmlog, Decl(npmlog.js, 4, 3)) +>module.exports : Symbol("tests/cases/conformance/salsa/npmlog", Decl(npmlog.js, 0, 0)) +>module : Symbol(npmlog, Decl(npmlog.js, 4, 12)) +>exports : Symbol(npmlog, Decl(npmlog.js, 4, 12)) +>EE : Symbol(EE, Decl(npmlog.js, 0, 0)) + +npmlog.on('hi') // both references should see EE.on +>npmlog.on : Symbol(EE.on, Decl(npmlog.js, 0, 10)) +>npmlog : Symbol(npmlog, Decl(npmlog.js, 4, 3)) +>on : Symbol(EE.on, Decl(npmlog.js, 0, 10)) + +module.exports.on('hi') // here too +>module.exports.on : Symbol(EE.on, Decl(npmlog.js, 0, 10)) +>module.exports : Symbol("tests/cases/conformance/salsa/npmlog", Decl(npmlog.js, 0, 0)) +>module : Symbol(module, Decl(npmlog.js, 4, 12), Decl(npmlog.js, 6, 15), Decl(npmlog.js, 9, 12), Decl(npmlog.js, 11, 8)) +>exports : Symbol("tests/cases/conformance/salsa/npmlog", Decl(npmlog.js, 0, 0)) +>on : Symbol(EE.on, Decl(npmlog.js, 0, 10)) + +npmlog.x = 1 +>npmlog.x : Symbol(x, Decl(npmlog.js, 7, 23)) +>npmlog : Symbol(npmlog, Decl(npmlog.js, 4, 3)) +>x : Symbol(x, Decl(npmlog.js, 7, 23)) + +module.exports.y = 2 +>module.exports.y : Symbol(y, Decl(npmlog.js, 9, 12)) +>module.exports : Symbol(y, Decl(npmlog.js, 9, 12)) +>module : Symbol(module, Decl(npmlog.js, 4, 12), Decl(npmlog.js, 6, 15), Decl(npmlog.js, 9, 12), Decl(npmlog.js, 11, 8)) +>exports : Symbol("tests/cases/conformance/salsa/npmlog", Decl(npmlog.js, 0, 0)) +>y : Symbol(y, Decl(npmlog.js, 9, 12)) + +npmlog.y +>npmlog.y : Symbol(y, Decl(npmlog.js, 9, 12)) +>npmlog : Symbol(npmlog, Decl(npmlog.js, 4, 3)) +>y : Symbol(y, Decl(npmlog.js, 9, 12)) + +module.exports.x +>module.exports.x : Symbol(x, Decl(npmlog.js, 7, 23)) +>module.exports : Symbol("tests/cases/conformance/salsa/npmlog", Decl(npmlog.js, 0, 0)) +>module : Symbol(module, Decl(npmlog.js, 4, 12), Decl(npmlog.js, 6, 15), Decl(npmlog.js, 9, 12), Decl(npmlog.js, 11, 8)) +>exports : Symbol("tests/cases/conformance/salsa/npmlog", Decl(npmlog.js, 0, 0)) +>x : Symbol(x, Decl(npmlog.js, 7, 23)) + diff --git a/tests/baselines/reference/moduleExportAssignment.types b/tests/baselines/reference/moduleExportAssignment.types new file mode 100644 index 0000000000000..a1606ef7c45ef --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment.types @@ -0,0 +1,79 @@ +=== tests/cases/conformance/salsa/use.js === +var npmlog = require('./npmlog') +>npmlog : typeof EE +>require('./npmlog') : typeof EE +>require : any +>'./npmlog' : "./npmlog" + +npmlog.x +>npmlog.x : number +>npmlog : typeof EE +>x : number + +npmlog.on +>npmlog.on : (s: string) => void +>npmlog : typeof EE +>on : (s: string) => void + +=== tests/cases/conformance/salsa/npmlog.js === +class EE { +>EE : EE + + /** @param {string} s */ + on(s) { } +>on : (s: string) => void +>s : string +} +var npmlog = module.exports = new EE() +>npmlog : typeof EE +>module.exports = new EE() : typeof EE +>module.exports : typeof EE +>module : { "tests/cases/conformance/salsa/npmlog": typeof EE; } +>exports : typeof EE +>new EE() : EE +>EE : typeof EE + +npmlog.on('hi') // both references should see EE.on +>npmlog.on('hi') : void +>npmlog.on : (s: string) => void +>npmlog : typeof EE +>on : (s: string) => void +>'hi' : "hi" + +module.exports.on('hi') // here too +>module.exports.on('hi') : void +>module.exports.on : (s: string) => void +>module.exports : typeof EE +>module : { "tests/cases/conformance/salsa/npmlog": typeof EE; } +>exports : typeof EE +>on : (s: string) => void +>'hi' : "hi" + +npmlog.x = 1 +>npmlog.x = 1 : 1 +>npmlog.x : number +>npmlog : typeof EE +>x : number +>1 : 1 + +module.exports.y = 2 +>module.exports.y = 2 : 2 +>module.exports.y : number +>module.exports : typeof EE +>module : { "tests/cases/conformance/salsa/npmlog": typeof EE; } +>exports : typeof EE +>y : number +>2 : 2 + +npmlog.y +>npmlog.y : number +>npmlog : typeof EE +>y : number + +module.exports.x +>module.exports.x : number +>module.exports : typeof EE +>module : { "tests/cases/conformance/salsa/npmlog": typeof EE; } +>exports : typeof EE +>x : number + diff --git a/tests/baselines/reference/moduleExportAssignment2.symbols b/tests/baselines/reference/moduleExportAssignment2.symbols new file mode 100644 index 0000000000000..192ecd6a180e3 --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment2.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/salsa/npm.js === +var npm = module.exports = function (tree) { +>npm : Symbol(npm, Decl(npm.js, 0, 3)) +>module.exports : Symbol("tests/cases/conformance/salsa/npm", Decl(npm.js, 0, 0)) +>module : Symbol(npm, Decl(npm.js, 0, 9)) +>exports : Symbol(npm, Decl(npm.js, 0, 9)) +>tree : Symbol(tree, Decl(npm.js, 0, 37)) +} +module.exports.asReadInstalled = function (tree) { +>module.exports.asReadInstalled : Symbol(asReadInstalled, Decl(npm.js, 1, 1)) +>module.exports : Symbol(asReadInstalled, Decl(npm.js, 1, 1)) +>module : Symbol(module, Decl(npm.js, 0, 9), Decl(npm.js, 1, 1)) +>exports : Symbol("tests/cases/conformance/salsa/npm", Decl(npm.js, 0, 0)) +>asReadInstalled : Symbol(asReadInstalled, Decl(npm.js, 1, 1)) +>tree : Symbol(tree, Decl(npm.js, 2, 43)) + + npm(tree) // both references should be callable +>npm : Symbol(npm, Decl(npm.js, 0, 3)) +>tree : Symbol(tree, Decl(npm.js, 2, 43)) + + module.exports(tree) +>module.exports : Symbol("tests/cases/conformance/salsa/npm", Decl(npm.js, 0, 0)) +>module : Symbol(module, Decl(npm.js, 3, 13)) +>exports : Symbol("tests/cases/conformance/salsa/npm", Decl(npm.js, 0, 0)) +>tree : Symbol(tree, Decl(npm.js, 2, 43)) +} + diff --git a/tests/baselines/reference/moduleExportAssignment2.types b/tests/baselines/reference/moduleExportAssignment2.types new file mode 100644 index 0000000000000..1bc1dcb58dc6f --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment2.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/salsa/npm.js === +var npm = module.exports = function (tree) { +>npm : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>module.exports = function (tree) {} : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>module.exports : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>module : { "tests/cases/conformance/salsa/npm": { (tree: any): void; asReadInstalled: (tree: any) => void; }; } +>exports : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>function (tree) {} : (tree: any) => void +>tree : any +} +module.exports.asReadInstalled = function (tree) { +>module.exports.asReadInstalled = function (tree) { npm(tree) // both references should be callable module.exports(tree)} : (tree: any) => void +>module.exports.asReadInstalled : (tree: any) => void +>module.exports : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>module : { "tests/cases/conformance/salsa/npm": { (tree: any): void; asReadInstalled: (tree: any) => void; }; } +>exports : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>asReadInstalled : (tree: any) => void +>function (tree) { npm(tree) // both references should be callable module.exports(tree)} : (tree: any) => void +>tree : any + + npm(tree) // both references should be callable +>npm(tree) : void +>npm : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>tree : any + + module.exports(tree) +>module.exports(tree) : void +>module.exports : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>module : { "tests/cases/conformance/salsa/npm": { (tree: any): void; asReadInstalled: (tree: any) => void; }; } +>exports : { (tree: any): void; asReadInstalled: (tree: any) => void; } +>tree : any +} + diff --git a/tests/baselines/reference/moduleExportAssignment3.symbols b/tests/baselines/reference/moduleExportAssignment3.symbols new file mode 100644 index 0000000000000..48a8dc841f6a8 --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment3.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/salsa/npm.js === +var mod = require('./mod') +>mod : Symbol(mod, Decl(npm.js, 0, 3)) +>require : Symbol(require) +>'./mod' : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) + +mod() // should be callable from here too +>mod : Symbol(mod, Decl(npm.js, 0, 3)) + +=== tests/cases/conformance/salsa/mod.js === +module.exports = function x() { } +>module.exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) +>module : Symbol(export=, Decl(mod.js, 0, 0)) +>exports : Symbol(export=, Decl(mod.js, 0, 0)) +>x : Symbol(x, Decl(mod.js, 0, 16)) + +module.exports() // should be callable +>module.exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) +>module : Symbol(module, Decl(mod.js, 0, 0), Decl(mod.js, 0, 33)) +>exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) + diff --git a/tests/baselines/reference/moduleExportAssignment3.types b/tests/baselines/reference/moduleExportAssignment3.types new file mode 100644 index 0000000000000..649beaa4ee4de --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment3.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/salsa/npm.js === +var mod = require('./mod') +>mod : () => void +>require('./mod') : () => void +>require : any +>'./mod' : "./mod" + +mod() // should be callable from here too +>mod() : void +>mod : () => void + +=== tests/cases/conformance/salsa/mod.js === +module.exports = function x() { } +>module.exports = function x() { } : () => void +>module.exports : () => void +>module : { "tests/cases/conformance/salsa/mod": () => void; } +>exports : () => void +>function x() { } : () => void +>x : () => void + +module.exports() // should be callable +>module.exports() : void +>module.exports : () => void +>module : { "tests/cases/conformance/salsa/mod": () => void; } +>exports : () => void + diff --git a/tests/baselines/reference/moduleExportAssignment4.symbols b/tests/baselines/reference/moduleExportAssignment4.symbols new file mode 100644 index 0000000000000..530b452c200f0 --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment4.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/salsa/async.js === +exports.default = { m: 1, a: 1 } +>exports : Symbol(default, Decl(async.js, 0, 0)) +>default : Symbol(default, Decl(async.js, 0, 0)) +>m : Symbol(m, Decl(async.js, 0, 19)) +>a : Symbol(a, Decl(async.js, 0, 25)) + +module.exports = exports['default']; +>module.exports : Symbol("tests/cases/conformance/salsa/async", Decl(async.js, 0, 0)) +>module : Symbol(export=, Decl(async.js, 0, 32)) +>exports : Symbol(export=, Decl(async.js, 0, 32)) +>exports : Symbol("tests/cases/conformance/salsa/async", Decl(async.js, 0, 0)) + diff --git a/tests/baselines/reference/moduleExportAssignment4.types b/tests/baselines/reference/moduleExportAssignment4.types new file mode 100644 index 0000000000000..56e0e6463813c --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment4.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/salsa/async.js === +exports.default = { m: 1, a: 1 } +>exports.default = { m: 1, a: 1 } : { [x: string]: any; m: number; a: number; } +>exports.default : any +>exports : any +>default : any +>{ m: 1, a: 1 } : { [x: string]: any; m: number; a: number; } +>m : number +>1 : 1 +>a : number +>1 : 1 + +module.exports = exports['default']; +>module.exports = exports['default'] : any +>module.exports : any +>module : { "tests/cases/conformance/salsa/async": any; } +>exports : any +>exports['default'] : any +>exports : any +>'default' : "default" + diff --git a/tests/baselines/reference/moduleExportAssignment5.symbols b/tests/baselines/reference/moduleExportAssignment5.symbols new file mode 100644 index 0000000000000..d05a51e52fc42 --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment5.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/salsa/axios.js === +class Axios { +>Axios : Symbol(Axios, Decl(axios.js, 0, 0)) + + constructor() { + } + m() { } +>m : Symbol(Axios.m, Decl(axios.js, 2, 5)) +} +var axios = new Axios(); +>axios : Symbol(axios, Decl(axios.js, 5, 3)) +>Axios : Symbol(Axios, Decl(axios.js, 0, 0)) + +// none of the 3 references should have a use-before-def error +axios.m() +>axios.m : Symbol(Axios.m, Decl(axios.js, 2, 5)) +>axios : Symbol(axios, Decl(axios.js, 5, 3)) +>m : Symbol(Axios.m, Decl(axios.js, 2, 5)) + +module.exports = axios; +>module.exports : Symbol("tests/cases/conformance/salsa/axios", Decl(axios.js, 0, 0)) +>module : Symbol(export=, Decl(axios.js, 7, 9)) +>exports : Symbol(export=, Decl(axios.js, 7, 9)) +>axios : Symbol(axios, Decl(axios.js, 5, 3)) + +module.exports.default = axios; +>module.exports.default : Symbol(default, Decl(axios.js, 8, 23)) +>module.exports : Symbol(default, Decl(axios.js, 8, 23)) +>module : Symbol(module, Decl(axios.js, 7, 9), Decl(axios.js, 8, 23)) +>exports : Symbol("tests/cases/conformance/salsa/axios", Decl(axios.js, 0, 0)) +>default : Symbol(default, Decl(axios.js, 8, 23)) +>axios : Symbol(axios, Decl(axios.js, 5, 3)) + diff --git a/tests/baselines/reference/moduleExportAssignment5.types b/tests/baselines/reference/moduleExportAssignment5.types new file mode 100644 index 0000000000000..646cedfb4c4d8 --- /dev/null +++ b/tests/baselines/reference/moduleExportAssignment5.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/salsa/axios.js === +class Axios { +>Axios : Axios + + constructor() { + } + m() { } +>m : () => void +} +var axios = new Axios(); +>axios : Axios +>new Axios() : Axios +>Axios : typeof Axios + +// none of the 3 references should have a use-before-def error +axios.m() +>axios.m() : void +>axios.m : () => void +>axios : Axios +>m : () => void + +module.exports = axios; +>module.exports = axios : typeof Axios +>module.exports : typeof Axios +>module : { "tests/cases/conformance/salsa/axios": typeof Axios; } +>exports : typeof Axios +>axios : Axios + +module.exports.default = axios; +>module.exports.default = axios : Axios +>module.exports.default : Axios +>module.exports : typeof Axios +>module : { "tests/cases/conformance/salsa/axios": typeof Axios; } +>exports : typeof Axios +>default : Axios +>axios : Axios + diff --git a/tests/baselines/reference/moduleExportNestedNamespaces.symbols b/tests/baselines/reference/moduleExportNestedNamespaces.symbols index 566221b3a5629..f1c4d4ad981e2 100644 --- a/tests/baselines/reference/moduleExportNestedNamespaces.symbols +++ b/tests/baselines/reference/moduleExportNestedNamespaces.symbols @@ -1,21 +1,30 @@ === tests/cases/conformance/salsa/mod.js === module.exports.n = {}; +>module.exports.n : Symbol(n, Decl(mod.js, 0, 0), Decl(mod.js, 1, 15)) >module.exports : Symbol(n, Decl(mod.js, 0, 0), Decl(mod.js, 1, 15)) ->module : Symbol(module) +>module : Symbol(module, Decl(mod.js, 0, 0), Decl(mod.js, 0, 22), Decl(mod.js, 3, 1)) +>exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) >n : Symbol(n, Decl(mod.js, 0, 0), Decl(mod.js, 1, 15)) module.exports.n.K = function C() { +>module.exports.n.K : Symbol(n.K, Decl(mod.js, 0, 22)) >module.exports.n : Symbol(n.K, Decl(mod.js, 0, 22)) ->module : Symbol(module) +>module.exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) +>module : Symbol(module, Decl(mod.js, 0, 0), Decl(mod.js, 0, 22), Decl(mod.js, 3, 1)) +>exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) +>n : Symbol(n, Decl(mod.js, 0, 0), Decl(mod.js, 1, 15)) >K : Symbol(n.K, Decl(mod.js, 0, 22)) >C : Symbol(C, Decl(mod.js, 1, 20)) this.x = 10; +>this : Symbol(n, Decl(mod.js, 0, 0), Decl(mod.js, 1, 15)) >x : Symbol(C.x, Decl(mod.js, 1, 35)) } module.exports.Classic = class { +>module.exports.Classic : Symbol(Classic, Decl(mod.js, 3, 1)) >module.exports : Symbol(Classic, Decl(mod.js, 3, 1)) ->module : Symbol(module) +>module : Symbol(module, Decl(mod.js, 0, 0), Decl(mod.js, 0, 22), Decl(mod.js, 3, 1)) +>exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0)) >Classic : Symbol(Classic, Decl(mod.js, 3, 1)) constructor() { diff --git a/tests/baselines/reference/moduleExportNestedNamespaces.types b/tests/baselines/reference/moduleExportNestedNamespaces.types index def26bac423c7..0267a4a4f9709 100644 --- a/tests/baselines/reference/moduleExportNestedNamespaces.types +++ b/tests/baselines/reference/moduleExportNestedNamespaces.types @@ -1,39 +1,39 @@ === tests/cases/conformance/salsa/mod.js === module.exports.n = {}; ->module.exports.n = {} : any ->module.exports.n : any ->module.exports : any ->module : any ->exports : any ->n : any +>module.exports.n = {} : typeof n +>module.exports.n : typeof n +>module.exports : typeof import("tests/cases/conformance/salsa/mod") +>module : { "tests/cases/conformance/salsa/mod": typeof import("tests/cases/conformance/salsa/mod"); } +>exports : typeof import("tests/cases/conformance/salsa/mod") +>n : typeof n >{} : { [x: string]: any; } module.exports.n.K = function C() { >module.exports.n.K = function C() { this.x = 10;} : typeof C ->module.exports.n.K : any ->module.exports.n : any ->module.exports : any ->module : any ->exports : any ->n : any ->K : any +>module.exports.n.K : typeof C +>module.exports.n : typeof n +>module.exports : typeof import("tests/cases/conformance/salsa/mod") +>module : { "tests/cases/conformance/salsa/mod": typeof import("tests/cases/conformance/salsa/mod"); } +>exports : typeof import("tests/cases/conformance/salsa/mod") +>n : typeof n +>K : typeof C >function C() { this.x = 10;} : typeof C >C : typeof C this.x = 10; >this.x = 10 : 10 >this.x : any ->this : any +>this : typeof n >x : any >10 : 10 } module.exports.Classic = class { >module.exports.Classic = class { constructor() { this.p = 1 }} : typeof Classic ->module.exports.Classic : any ->module.exports : any ->module : any ->exports : any ->Classic : any +>module.exports.Classic : typeof Classic +>module.exports : typeof import("tests/cases/conformance/salsa/mod") +>module : { "tests/cases/conformance/salsa/mod": typeof import("tests/cases/conformance/salsa/mod"); } +>exports : typeof import("tests/cases/conformance/salsa/mod") +>Classic : typeof Classic >class { constructor() { this.p = 1 }} : typeof Classic constructor() { diff --git a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.symbols b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.symbols new file mode 100644 index 0000000000000..32d5aa0784a1e --- /dev/null +++ b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/salsa/axios.js === +var axios = {} +>axios : Symbol(axios, Decl(axios.js, 0, 3)) + +module.exports = axios // both assignments should be ok +>module.exports : Symbol("tests/cases/conformance/salsa/axios", Decl(axios.js, 0, 0)) +>module : Symbol(export=, Decl(axios.js, 0, 14)) +>exports : Symbol(export=, Decl(axios.js, 0, 14)) +>axios : Symbol(axios, Decl(axios.js, 0, 3)) + +module.exports.default = axios +>module.exports.default : Symbol(default) +>module.exports : Symbol(default, Decl(axios.js, 1, 22)) +>module : Symbol(module, Decl(axios.js, 0, 14), Decl(axios.js, 1, 22)) +>exports : Symbol("tests/cases/conformance/salsa/axios", Decl(axios.js, 0, 0)) +>default : Symbol(default, Decl(axios.js, 1, 22)) +>axios : Symbol(axios, Decl(axios.js, 0, 3)) + diff --git a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types new file mode 100644 index 0000000000000..a65961e4daa1d --- /dev/null +++ b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/salsa/axios.js === +var axios = {} +>axios : { [x: string]: any; default: { [x: string]: any; default: any; }; } +>{} : { [x: string]: any; } + +module.exports = axios // both assignments should be ok +>module.exports = axios : { [x: string]: any; default: any; } +>module.exports : { [x: string]: any; default: any; } +>module : { "tests/cases/conformance/salsa/axios": { [x: string]: any; default: any; }; } +>exports : { [x: string]: any; default: any; } +>axios : { [x: string]: any; default: { [x: string]: any; default: any; }; } + +module.exports.default = axios +>module.exports.default = axios : { [x: string]: any; default: { [x: string]: any; default: any; }; } +>module.exports.default : { [x: string]: any; default: any; } +>module.exports : { [x: string]: any; default: any; } +>module : { "tests/cases/conformance/salsa/axios": { [x: string]: any; default: any; }; } +>exports : { [x: string]: any; default: any; } +>default : { [x: string]: any; default: any; } +>axios : { [x: string]: any; default: { [x: string]: any; default: any; }; } + diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment.symbols index c5120a80571e3..d11a1b0d1a646 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment.symbols @@ -25,15 +25,16 @@ declare function require(name: string): any; === tests/cases/conformance/salsa/mod1.js === /// module.exports = function () { } ->module.exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module.exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >module : Symbol(export=, Decl(mod1.js, 0, 0)) >exports : Symbol(export=, Decl(mod1.js, 0, 0)) /** @param {number} a */ module.exports.f = function (a) { } +>module.exports.f : Symbol(f, Decl(mod1.js, 1, 32)) >module.exports : Symbol(f, Decl(mod1.js, 1, 32)) ->module : Symbol(module, Decl(requires.d.ts, 0, 11)) ->exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module : Symbol(module, Decl(mod1.js, 0, 0), Decl(mod1.js, 1, 32)) +>exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >f : Symbol(f, Decl(mod1.js, 1, 32)) >a : Symbol(a, Decl(mod1.js, 3, 29)) diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment.types b/tests/baselines/reference/moduleExportWithExportPropertyAssignment.types index b7170842c1f39..c608ae0a91f9e 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment.types +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment.types @@ -28,20 +28,20 @@ declare function require(name: string): any; === tests/cases/conformance/salsa/mod1.js === /// module.exports = function () { } ->module.exports = function () { } : () => void ->module.exports : any ->module : { exports: any; } ->exports : any +>module.exports = function () { } : { (): void; f: (a: number) => void; } +>module.exports : { (): void; f: (a: number) => void; } +>module : { "tests/cases/conformance/salsa/mod1": { (): void; f: (a: number) => void; }; } +>exports : { (): void; f: (a: number) => void; } >function () { } : () => void /** @param {number} a */ module.exports.f = function (a) { } >module.exports.f = function (a) { } : (a: number) => void ->module.exports.f : any ->module.exports : any ->module : { exports: any; } ->exports : any ->f : any +>module.exports.f : (a: number) => void +>module.exports : { (): void; f: (a: number) => void; } +>module : { "tests/cases/conformance/salsa/mod1": { (): void; f: (a: number) => void; }; } +>exports : { (): void; f: (a: number) => void; } +>f : (a: number) => void >function (a) { } : (a: number) => void >a : number diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.errors.txt b/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.errors.txt index 66cb517a25be7..4b0e72b999543 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.errors.txt +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/salsa/a.js(4,6): error TS2339: Property 'f' does not exist on type 'number'. +tests/cases/conformance/salsa/mod1.js(3,16): error TS2339: Property 'f' does not exist on type 'number'. ==== tests/cases/conformance/salsa/a.js (1 errors) ==== @@ -12,8 +13,10 @@ tests/cases/conformance/salsa/a.js(4,6): error TS2339: Property 'f' does not exi ==== tests/cases/conformance/salsa/requires.d.ts (0 errors) ==== declare var module: { exports: any }; declare function require(name: string): any; -==== tests/cases/conformance/salsa/mod1.js (0 errors) ==== +==== tests/cases/conformance/salsa/mod1.js (1 errors) ==== /// module.exports = 1 module.exports.f = function () { } + ~ +!!! error TS2339: Property 'f' does not exist on type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.symbols index 0806042409683..9ea285cef15a4 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.symbols @@ -25,13 +25,13 @@ declare function require(name: string): any; === tests/cases/conformance/salsa/mod1.js === /// module.exports = 1 ->module.exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module.exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >module : Symbol(export=, Decl(mod1.js, 0, 0)) >exports : Symbol(export=, Decl(mod1.js, 0, 0)) module.exports.f = function () { } >module.exports : Symbol(f, Decl(mod1.js, 1, 18)) ->module : Symbol(module, Decl(requires.d.ts, 0, 11)) ->exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module : Symbol(module, Decl(mod1.js, 0, 0), Decl(mod1.js, 1, 18)) +>exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >f : Symbol(f, Decl(mod1.js, 1, 18)) diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.types b/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.types index 8af94a05fa5c6..3e10c04bc6909 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.types +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment2.types @@ -31,18 +31,18 @@ declare function require(name: string): any; === tests/cases/conformance/salsa/mod1.js === /// module.exports = 1 ->module.exports = 1 : 1 ->module.exports : any ->module : { exports: any; } ->exports : any +>module.exports = 1 : number +>module.exports : number +>module : { "tests/cases/conformance/salsa/mod1": number; } +>exports : number >1 : 1 module.exports.f = function () { } >module.exports.f = function () { } : () => void >module.exports.f : any ->module.exports : any ->module : { exports: any; } ->exports : any +>module.exports : number +>module : { "tests/cases/conformance/salsa/mod1": number; } +>exports : number >f : any >function () { } : () => void diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols index 4f14c045d6462..750ee93cf0e3e 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols @@ -41,13 +41,14 @@ declare function require(name: string): any; === tests/cases/conformance/salsa/mod1.js === /// module.exports.bothBefore = 'string' +>module.exports.bothBefore : Symbol(bothBefore) >module.exports : Symbol(bothBefore, Decl(mod1.js, 0, 0)) ->module : Symbol(module, Decl(requires.d.ts, 0, 11)) ->exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module : Symbol(module, Decl(mod1.js, 0, 0), Decl(mod1.js, 1, 36), Decl(mod1.js, 6, 1), Decl(mod1.js, 7, 35)) +>exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >bothBefore : Symbol(bothBefore, Decl(mod1.js, 0, 0)) module.exports = { ->module.exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module.exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >module : Symbol(export=, Decl(mod1.js, 1, 36)) >exports : Symbol(export=, Decl(mod1.js, 1, 36)) @@ -61,14 +62,16 @@ module.exports = { >bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18)) } module.exports.bothAfter = 'string' +>module.exports.bothAfter : Symbol(bothAfter) >module.exports : Symbol(bothAfter, Decl(mod1.js, 6, 1)) ->module : Symbol(module, Decl(requires.d.ts, 0, 11)) ->exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module : Symbol(module, Decl(mod1.js, 0, 0), Decl(mod1.js, 1, 36), Decl(mod1.js, 6, 1), Decl(mod1.js, 7, 35)) +>exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >bothAfter : Symbol(bothAfter, Decl(mod1.js, 6, 1)) module.exports.justProperty = 'string' +>module.exports.justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35)) >module.exports : Symbol(justProperty, Decl(mod1.js, 7, 35)) ->module : Symbol(module, Decl(requires.d.ts, 0, 11)) ->exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module : Symbol(module, Decl(mod1.js, 0, 0), Decl(mod1.js, 1, 36), Decl(mod1.js, 6, 1), Decl(mod1.js, 7, 35)) +>exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >justProperty : Symbol(justProperty, Decl(mod1.js, 7, 35)) diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.types b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.types index 4d14bf647fd2c..71b7dbe7089c7 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.types +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.types @@ -50,18 +50,18 @@ declare function require(name: string): any; /// module.exports.bothBefore = 'string' >module.exports.bothBefore = 'string' : "string" ->module.exports.bothBefore : any ->module.exports : any ->module : { exports: any; } ->exports : any ->bothBefore : any +>module.exports.bothBefore : string | number +>module.exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module : { "tests/cases/conformance/salsa/mod1": { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } +>exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>bothBefore : string | number >'string' : "string" module.exports = { ->module.exports = { justExport: 1, bothBefore: 2, bothAfter: 3,} : { [x: string]: any; justExport: number; bothBefore: number; bothAfter: number; } ->module.exports : any ->module : { exports: any; } ->exports : any +>module.exports = { justExport: 1, bothBefore: 2, bothAfter: 3,} : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module.exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module : { "tests/cases/conformance/salsa/mod1": { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } +>exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >{ justExport: 1, bothBefore: 2, bothAfter: 3,} : { [x: string]: any; justExport: number; bothBefore: number; bothAfter: number; } justExport: 1, @@ -78,19 +78,19 @@ module.exports = { } module.exports.bothAfter = 'string' >module.exports.bothAfter = 'string' : "string" ->module.exports.bothAfter : any ->module.exports : any ->module : { exports: any; } ->exports : any ->bothAfter : any +>module.exports.bothAfter : string | number +>module.exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module : { "tests/cases/conformance/salsa/mod1": { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } +>exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>bothAfter : string | number >'string' : "string" module.exports.justProperty = 'string' >module.exports.justProperty = 'string' : "string" ->module.exports.justProperty : any ->module.exports : any ->module : { exports: any; } ->exports : any ->justProperty : any +>module.exports.justProperty : string +>module.exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module : { "tests/cases/conformance/salsa/mod1": { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } +>exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>justProperty : string >'string' : "string" diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.errors.txt b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.errors.txt index 247c29e0ad3af..f44a5c2b47e86 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.errors.txt +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.errors.txt @@ -2,6 +2,10 @@ tests/cases/conformance/salsa/a.js(4,17): error TS2339: Property 'toFixed' does Property 'toFixed' does not exist on type 'string'. tests/cases/conformance/salsa/a.js(5,16): error TS2339: Property 'toFixed' does not exist on type 'string | number'. Property 'toFixed' does not exist on type 'string'. +tests/cases/conformance/salsa/mod1.js(2,1): error TS2323: Cannot redeclare exported variable 'bothBefore'. +tests/cases/conformance/salsa/mod1.js(4,1): error TS2323: Cannot redeclare exported variable 'bothBefore'. +tests/cases/conformance/salsa/mod1.js(5,1): error TS2323: Cannot redeclare exported variable 'bothAfter'. +tests/cases/conformance/salsa/mod1.js(10,1): error TS2323: Cannot redeclare exported variable 'bothAfter'. ==== tests/cases/conformance/salsa/a.js (2 errors) ==== @@ -21,16 +25,24 @@ tests/cases/conformance/salsa/a.js(5,16): error TS2339: Property 'toFixed' does ==== tests/cases/conformance/salsa/requires.d.ts (0 errors) ==== declare var module: { exports: any }; declare function require(name: string): any; -==== tests/cases/conformance/salsa/mod1.js (0 errors) ==== +==== tests/cases/conformance/salsa/mod1.js (4 errors) ==== /// module.exports.bothBefore = 'string' + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'bothBefore'. A.justExport = 4 A.bothBefore = 2 + ~~~~~~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'bothBefore'. A.bothAfter = 3 + ~~~~~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'bothAfter'. module.exports = A function A() { this.p = 1 } module.exports.bothAfter = 'string' + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'bothAfter'. module.exports.justProperty = 'string' \ No newline at end of file diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols index 400885f4bd9cc..71be64164bc19 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols @@ -41,9 +41,10 @@ declare function require(name: string): any; === tests/cases/conformance/salsa/mod1.js === /// module.exports.bothBefore = 'string' +>module.exports.bothBefore : Symbol(bothBefore) >module.exports : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) ->module : Symbol(module, Decl(requires.d.ts, 0, 11)) ->exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module : Symbol(module, Decl(mod1.js, 0, 0), Decl(mod1.js, 4, 15), Decl(mod1.js, 8, 1), Decl(mod1.js, 9, 35)) +>exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) A.justExport = 4 @@ -52,17 +53,17 @@ A.justExport = 4 >justExport : Symbol(A.justExport, Decl(mod1.js, 1, 36)) A.bothBefore = 2 ->A.bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16)) +>A.bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) >A : Symbol(A, Decl(mod1.js, 5, 18)) ->bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16)) +>bothBefore : Symbol(A.bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) A.bothAfter = 3 ->A.bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16)) +>A.bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) >A : Symbol(A, Decl(mod1.js, 5, 18)) ->bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16)) +>bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) module.exports = A ->module.exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module.exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >module : Symbol(export=, Decl(mod1.js, 4, 15)) >exports : Symbol(export=, Decl(mod1.js, 4, 15)) >A : Symbol(A, Decl(mod1.js, 5, 18)) @@ -74,14 +75,16 @@ function A() { >p : Symbol(A.p, Decl(mod1.js, 6, 14)) } module.exports.bothAfter = 'string' +>module.exports.bothAfter : Symbol(bothAfter) >module.exports : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) ->module : Symbol(module, Decl(requires.d.ts, 0, 11)) ->exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module : Symbol(module, Decl(mod1.js, 0, 0), Decl(mod1.js, 4, 15), Decl(mod1.js, 8, 1), Decl(mod1.js, 9, 35)) +>exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >bothAfter : Symbol(A.bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) module.exports.justProperty = 'string' +>module.exports.justProperty : Symbol(justProperty) >module.exports : Symbol(justProperty, Decl(mod1.js, 9, 35)) ->module : Symbol(module, Decl(requires.d.ts, 0, 11)) ->exports : Symbol(exports, Decl(requires.d.ts, 0, 21)) +>module : Symbol(module, Decl(mod1.js, 0, 0), Decl(mod1.js, 4, 15), Decl(mod1.js, 8, 1), Decl(mod1.js, 9, 35)) +>exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35)) diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types index f339118bf05ac..8c55a664fc2e9 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.types @@ -50,11 +50,11 @@ declare function require(name: string): any; /// module.exports.bothBefore = 'string' >module.exports.bothBefore = 'string' : "string" ->module.exports.bothBefore : any ->module.exports : any ->module : { exports: any; } ->exports : any ->bothBefore : any +>module.exports.bothBefore : string | number +>module.exports : typeof A +>module : { "tests/cases/conformance/salsa/mod1": typeof A; } +>exports : typeof A +>bothBefore : string | number >'string' : "string" A.justExport = 4 @@ -66,23 +66,23 @@ A.justExport = 4 A.bothBefore = 2 >A.bothBefore = 2 : 2 ->A.bothBefore : number +>A.bothBefore : string | number >A : typeof A ->bothBefore : number +>bothBefore : string | number >2 : 2 A.bothAfter = 3 >A.bothAfter = 3 : 3 ->A.bothAfter : number +>A.bothAfter : string | number >A : typeof A ->bothAfter : number +>bothAfter : string | number >3 : 3 module.exports = A >module.exports = A : typeof A ->module.exports : any ->module : { exports: any; } ->exports : any +>module.exports : typeof A +>module : { "tests/cases/conformance/salsa/mod1": typeof A; } +>exports : typeof A >A : typeof A function A() { @@ -97,19 +97,19 @@ function A() { } module.exports.bothAfter = 'string' >module.exports.bothAfter = 'string' : "string" ->module.exports.bothAfter : any ->module.exports : any ->module : { exports: any; } ->exports : any ->bothAfter : any +>module.exports.bothAfter : string | number +>module.exports : typeof A +>module : { "tests/cases/conformance/salsa/mod1": typeof A; } +>exports : typeof A +>bothAfter : string | number >'string' : "string" module.exports.justProperty = 'string' >module.exports.justProperty = 'string' : "string" ->module.exports.justProperty : any ->module.exports : any ->module : { exports: any; } ->exports : any ->justProperty : any +>module.exports.justProperty : string +>module.exports : typeof A +>module : { "tests/cases/conformance/salsa/mod1": typeof A; } +>exports : typeof A +>justProperty : string >'string' : "string" diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt index 248d4c3547370..699b65a4f6437 100644 --- a/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt @@ -16,6 +16,7 @@ tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(16,17) err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' ~~~~~~~ !!! error TS2551: Property 'doPanic' does not exist on type '{ type: "foo"; dontPanic(): any; }'. Did you mean 'dontPanic'? +!!! related TS2728 tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts:1:58: 'dontPanic' is declared here. } else if (err instanceof Error) { @@ -23,6 +24,7 @@ tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(16,17) err.massage; // ERROR: Property 'massage' does not exist on type 'Error' ~~~~~~~ !!! error TS2551: Property 'massage' does not exist on type 'Error'. Did you mean 'message'? +!!! related TS2728 /.ts/lib.es5.d.ts:904:5: 'message' is declared here. } else { diff --git a/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt index f846565190138..216211b2fa28a 100644 --- a/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt +++ b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt @@ -22,6 +22,7 @@ tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS x.mesage; ~~~~~~ !!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'? +!!! related TS2728 /.ts/lib.es5.d.ts:904:5: 'message' is declared here. } if (x instanceof Date) { @@ -29,5 +30,6 @@ tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS x.getHuors(); ~~~~~~~~ !!! error TS2551: Property 'getHuors' does not exist on type 'Date'. Did you mean 'getHours'? +!!! related TS2728 /.ts/lib.es5.d.ts:693:5: 'getHours' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt index 4865748f3325c..c35d3263b8fb2 100644 --- a/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt +++ b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt @@ -39,6 +39,7 @@ tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error x.mesage; ~~~~~~ !!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'? +!!! related TS2728 /.ts/lib.es5.d.ts:904:5: 'message' is declared here. } if (isDate(x)) { @@ -46,5 +47,6 @@ tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error x.getHuors(); ~~~~~~~~ !!! error TS2551: Property 'getHuors' does not exist on type 'Date'. Did you mean 'getHours'? +!!! related TS2728 /.ts/lib.es5.d.ts:693:5: 'getHours' is declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/nestedFreshLiteral.errors.txt b/tests/baselines/reference/nestedFreshLiteral.errors.txt index d68b398449d53..fc7fc8976990f 100644 --- a/tests/baselines/reference/nestedFreshLiteral.errors.txt +++ b/tests/baselines/reference/nestedFreshLiteral.errors.txt @@ -1,10 +1,7 @@ -tests/cases/compiler/nestedFreshLiteral.ts(12,21): error TS2322: Type '{ nested: { prop: { colour: string; }; }; }' is not assignable to type 'NestedCSSProps'. - Types of property 'nested' are incompatible. - Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector | undefined'. - Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'. - Types of property 'prop' are incompatible. - Type '{ colour: string; }' is not assignable to type 'CSSProps'. - Object literal may only specify known properties, but 'colour' does not exist in type 'CSSProps'. Did you mean to write 'color'? +tests/cases/compiler/nestedFreshLiteral.ts(12,21): error TS2322: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'. + Types of property 'prop' are incompatible. + Type '{ colour: string; }' is not assignable to type 'CSSProps'. + Object literal may only specify known properties, but 'colour' does not exist in type 'CSSProps'. Did you mean to write 'color'? ==== tests/cases/compiler/nestedFreshLiteral.ts (1 errors) ==== @@ -21,11 +18,9 @@ tests/cases/compiler/nestedFreshLiteral.ts(12,21): error TS2322: Type '{ nested: let stylen: NestedCSSProps = { nested: { prop: { colour: 'red' } } ~~~~~~~~~~~~~ -!!! error TS2322: Type '{ nested: { prop: { colour: string; }; }; }' is not assignable to type 'NestedCSSProps'. -!!! error TS2322: Types of property 'nested' are incompatible. -!!! error TS2322: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector | undefined'. -!!! error TS2322: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'. -!!! error TS2322: Types of property 'prop' are incompatible. -!!! error TS2322: Type '{ colour: string; }' is not assignable to type 'CSSProps'. -!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'CSSProps'. Did you mean to write 'color'? +!!! error TS2322: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'. +!!! error TS2322: Types of property 'prop' are incompatible. +!!! error TS2322: Type '{ colour: string; }' is not assignable to type 'CSSProps'. +!!! error TS2322: Object literal may only specify known properties, but 'colour' does not exist in type 'CSSProps'. Did you mean to write 'color'? +!!! related TS6500 tests/cases/compiler/nestedFreshLiteral.ts:5:3: The expected type comes from property 'nested' which is declared here on type 'NestedCSSProps' } \ No newline at end of file diff --git a/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.errors.txt b/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.errors.txt new file mode 100644 index 0000000000000..138a4a8415825 --- /dev/null +++ b/tests/baselines/reference/nestedRecursiveArraysOrObjectsError01.errors.txt @@ -0,0 +1,46 @@ +tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts(10,9): error TS2322: Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'Style'. + Type '{ foo: string; jj: number; }[][][]' is not assignable to type 'StyleArray'. + Types of property 'pop' are incompatible. + Type '() => { foo: string; jj: number; }[][]' is not assignable to type '() => Style'. + Type '{ foo: string; jj: number; }[][]' is not assignable to type 'Style'. + Type '{ foo: string; jj: number; }[][]' is not assignable to type 'StyleArray'. + Types of property 'pop' are incompatible. + Type '() => { foo: string; jj: number; }[]' is not assignable to type '() => Style'. + Type '{ foo: string; jj: number; }[]' is not assignable to type 'Style'. + Type '{ foo: string; jj: number; }[]' is not assignable to type 'StyleArray'. + Types of property 'pop' are incompatible. + Type '() => { foo: string; jj: number; }' is not assignable to type '() => Style'. + Type '{ foo: string; jj: number; }' is not assignable to type 'Style'. + Object literal may only specify known properties, and 'jj' does not exist in type 'Style'. + + +==== tests/cases/compiler/nestedRecursiveArraysOrObjectsError01.ts (1 errors) ==== + type Style = StyleBase | StyleArray; + interface StyleArray extends Array